feat(swap): add Oxedium single-sided liquidity protocol#34
feat(swap): add Oxedium single-sided liquidity protocol#34zelmkhan wants to merge 9 commits intoblueshift-gg:masterfrom
Conversation
Implements the `Swap` trait for the Oxedium protocol (oxe3zgfkaGph4X5bv4RZRFUcQXZcXxK9fxDizCtPZv7), a single-sided liquidity AMM on Solana that uses Pyth oracle prices for cross-vault token swaps. - Add `crates/swap/oxedium` crate with `OxediumSwapAccounts` (16 accounts) and `Oxedium` struct implementing `Swap<'info>` - Instruction data: 8-byte Anchor discriminator + amount_in + minimum_out (24 bytes) - No extra swap data required (`type Data = ()`) - Wire up `oxedium-swap` feature flag in root `Cargo.toml` - Export `oxedium` module in `src/lib.rs` - Add `SwapContext::Oxedium` variant and routing in `src/context.rs`
…gg#30) * Fix pinocchio GitHub link and typo in description * `program` -> `programs` in `Cargo.toml` description
* feat: add omnipair-swap feature * feat: add omnipair-swap client * chore: add fixtures for omnipair-swap * feat: add omnipair-swap cpi test * refactor: simplify code
BretasArthur1
left a comment
There was a problem hiding this comment.
Hey @zelmkhan overall looks good, but please remove claude as contributor from your history
e2eda4d to
35695d6
Compare
|
The 1. // broken — missing args, ), and }
(SwapContext::Oxedium(accounts), SwapData::Oxedium(())) => {
crate::oxedium::Oxedium::swap_signed(
// omnipair starts hereShould be a complete arm: #[cfg(feature = "oxedium-swap")]
(SwapContext::Oxedium(accounts), SwapData::Oxedium(())) => {
crate::oxedium::Oxedium::swap_signed(
accounts,
in_amount,
minimum_out_amount,
&(),
signer_seeds,
)
}2. #[cfg(feature = "oxedium-swap")]
if address_eq(detector_account.address(), &crate::oxedium::OXEDIUM_PROGRAM_ID) {
let n = crate::oxedium::OxediumSwapAccounts::NUM_ACCOUNTS;
if accounts.len() < n {
return Err(ProgramError::NotEnoughAccountKeys);
}
let (mine, rest) = accounts.split_at(n);
let ctx = crate::oxedium::OxediumSwapAccounts::try_from(mine)?;
return Ok((SwapContext::Oxedium(ctx), rest));
}Both fixes are just restructuring — copy the Omnipair pattern as a complete block rather than inserting lines into it. Also missing a test file ( |
Fix two broken match arms in context.rs: - Complete the swap_signed dispatch arm with proper arguments - Separate the oxedium and omnipair if-blocks in try_from_swap_context Add integration test with mainnet fixtures (accounts, .so, pyth oracles). Add beethoven-client support: - oxedium feature flag - OxediumSwapInput struct and build_accounts() - resolve() that derives vault PDAs and reads pyth accounts from RPC
|
@L0STE @BretasArthur1 Please check |
L0STE
left a comment
There was a problem hiding this comment.
LGTM, a few minor style nits:
src/context.rs: Missing blank line betweenOxediumandOmnipairvariants in bothSwapContextandSwapDataenums (every other variant has one)src/context.rs: Thetry_from_swap_dataarm for Oxedium is between Gamma and ScaleAmm, but the enum declaration puts it between ScaleVmm and Omnipair — would be easier to scan if they matchedcrates/swap/oxedium/src/lib.rs:285: The "no extra data" doc comment is on theNUM_ACCOUNTSimpl block rather than neartype Data = ()
- Add missing blank lines before Omnipair variants in SwapContext and SwapData enums - Reorder try_from_swap_data arms to match enum declaration order (Oxedium after ScaleVmm) - Move "no extra data" doc comment from NUM_ACCOUNTS impl block to type Data = ()
Summary
Adds swap support for the Oxedium single-sided liquidity protocol (
oV3SkLhiXSG946FaqDf1yNocFMhE1ZvomGsoWF8Mzap).Oxedium is an AMM where LPs deposit a single token into a vault and traders swap between vaults using Pyth oracle prices to determine the exchange rate.
crates/swap/oxediumcrate implementing theSwap<'info>traitOxediumSwapAccounts— 16 accounts (program sentinel + 15 instruction accounts)sha256("global:swap")[0..8]) +amount_in+minimum_out= 24 bytestype Data = ())oxedium-swapfeature flag in rootCargo.tomloxediummodule insrc/lib.rsSwapContext::Oxediumvariant and protocol-detection routing insrc/context.rsAccount layout
Test plan
cargo check --features oxedium-swapcompiles without errorscargo check(all features) compiles without errorstry_from_swap_contextwith Oxedium program ID as first account