Rust crate for the Amm trait to integrate with dflow-core.
Amm trait implemenation:
- Create the AMM instance:
from_keyed_accountparse the pool/market account and create AMM for pool - Provide pool metadata:
label,program_id,key, andget_reserve_mintsto identify pool - Handle state updates:
get_accounts_to_updatelist accounts needed for quotes, thenupdateto deserialize and cache market/pool states - Provide quotes:
quoteto calculate swap output amounts based on current market/pool state - Generate swap instructions:
get_swap_and_account_metasto return the swap instruction type and required accounts
quote.in_amount <= quote_params.amount.
When implementing the quote method, use input capping if the requested input amount cannot be fully consumed (e.g., due to liquidity limits or other constraints). Return a Quote with in_amount less than the requested amount rather than returning an error or panicking.