This program implements an oracle-based DEX. Unlike a traditional AMM, it does not use an internal formula (like x*y=k) to determine prices. Instead, it relies on a trusted off-chain service (price-keeper-bot) to push AI-generated exchange rates on-chain via the update_oracle_price instruction. Swaps are then executed at this externally-provided oracle price.
- PDA Seeds:
["liquidity_pool", mint_a_pubkey, mint_b_pubkey] - Purpose: Stores the core data for a liquidity pool, including the AI-provided price.
- Fields:
mint_a: Pubkey- The mint address of the first token in the pair.mint_b: Pubkey- The mint address of the second token in the pair.oracle_authority: Pubkey- The public key of the trusted bot authorized to callupdate_oracle_price.oracle_price: u64- The AI-generated price of token A in terms of token B, with 9 decimals of precision.last_oracle_update: i64- The Unix timestamp of the last price update to prevent stale prices.vault_a_bump: u8- The bump seed for this pool's token vault formint_a.vault_b_bump: u8- The bump seed for this pool's token vault formint_b.
- Description: Initializes a new liquidity pool, setting the
oracle_authority. - Parameters:
oracle_authority: Pubkey
- Description: Allows a user to deposit tokens into the vaults to provide liquidity for swaps.
- Parameters:
amount_a: u64,amount_b: u64
- Description: This is a permissioned instruction. Only the
oracle_authoritycan call it. It updates theoracle_priceon-chain with a new value generated by the AI. - Parameters:
new_price: u64
- Description: Allows a user to swap tokens at the current
oracle_price. The transaction fails if liquidity is insufficient or the oracle price is considered stale. - Parameters:
amount_in: u64,min_amount_out: u64
SlippageExceeded,InsufficientLiquidity,Overflow,InvalidMintInvalidOracleAuthority: The signer ofupdate_oracle_priceis not the authorized authority.OraclePriceStale: The price has not been updated within the allowed time window.