mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-26 22:51:14 +00:00
feat(amm): create TWAP price observations on behalf of the pool
Add a `CreatePriceObservations` instruction that registers a TWAP price-observations account for a pool over a time window, via a chained call to the configured TWAP oracle program. The pool acts as the price source: the AMM authorizes it with its pool PDA seed so the oracle ties the feed to that pool. The feed's initial tick is read from the pool's authoritative `CurrentTickAccount` (validated against its pool-derived PDA) rather than being supplied by the caller, so the feed cannot be seeded at a forged price — mirroring what `RecordTick` does. The clock is verified to be the canonical 1-block LEZ clock, and creation is rejected if the observations account already exists. To support the chained call, `AmmConfig` and the `Initialize` instruction are extended with a `twap_oracle_program_id` that the instruction reads.
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
"name": "token_program_id",
|
||||
"type": "program_id"
|
||||
},
|
||||
{
|
||||
"name": "twap_oracle_program_id",
|
||||
"type": "program_id"
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": "account_id"
|
||||
@@ -46,6 +50,12 @@
|
||||
"option": "program_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "twap_oracle_program_id",
|
||||
"type": {
|
||||
"option": "program_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "new_authority",
|
||||
"type": {
|
||||
@@ -54,6 +64,47 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "create_price_observations",
|
||||
"accounts": [
|
||||
{
|
||||
"name": "config",
|
||||
"writable": false,
|
||||
"signer": false,
|
||||
"init": false
|
||||
},
|
||||
{
|
||||
"name": "pool",
|
||||
"writable": false,
|
||||
"signer": false,
|
||||
"init": false
|
||||
},
|
||||
{
|
||||
"name": "current_tick_account",
|
||||
"writable": false,
|
||||
"signer": false,
|
||||
"init": false
|
||||
},
|
||||
{
|
||||
"name": "price_observations",
|
||||
"writable": false,
|
||||
"signer": false,
|
||||
"init": false
|
||||
},
|
||||
{
|
||||
"name": "clock",
|
||||
"writable": false,
|
||||
"signer": false,
|
||||
"init": false
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "window_duration",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "new_definition",
|
||||
"accounts": [
|
||||
@@ -470,6 +521,10 @@
|
||||
"name": "token_program_id",
|
||||
"type": "program_id"
|
||||
},
|
||||
{
|
||||
"name": "twap_oracle_program_id",
|
||||
"type": "program_id"
|
||||
},
|
||||
{
|
||||
"name": "authority",
|
||||
"type": "account_id"
|
||||
|
||||
Reference in New Issue
Block a user