Skip to content

Commit

Permalink
chore: add swap endpoint interface for sol vault swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-llimos committed Nov 29, 2024
1 parent d4f68cc commit 8cff95c
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion state-chain/chains/src/sol/sol_tx_core/program_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,37 @@ pub mod swap_endpoints {
agg_key: { signer: true, writable: true },
swap_endpoint_data_account: { signer: false, writable: true },
]
}
},
x_swap_native => XSwapNative {
args: [
swap_native_params: SwapNativeParams,
],
account_metas: [
data_account: { signer: false, writable: false },
agg_key: { signer: false, writable: true },
from: { signer: true, writable: true },
event_data_account: { signer: true, writable: true },
swap_endpoint_data_account: { signer: false, writable: true },
system_program: { signer: false, writable: false },
]
},
x_swap_token => XSwapToken {
args: [
swap_token_params: SwapTokenParams,
],
account_metas: [
data_account: { signer: false, writable: false },
token_vault_associated_token_account: { signer: false, writable: true },
from: { signer: true, writable: true },
from_token_account: { signer: false, writable: true },
event_data_account: { signer: true, writable: true },
swap_endpoint_data_account: { signer: false, writable: true },
token_supported_account: { signer: false, writable: false },
token_program: { signer: false, writable: false },
mint: { signer: false, writable: false },
system_program: { signer: false, writable: false },
]
},
},
types: [
CcmParams {
Expand All @@ -796,6 +826,23 @@ pub mod swap_endpoints {
historical_number_event_accounts: u128,
open_event_accounts: Vec<Pubkey>,
},
SwapNativeParams {
amount: u64,
dst_chain: u32,
dst_address: Vec<u8>,
dst_token: u32,
ccm_parameters: Option<CcmParams>,
cf_parameters: Vec<u8>,
},
SwapTokenParams {
amount: u64,
dst_chain: u32,
dst_address: Vec<u8>,
dst_token: u32,
ccm_parameters: Option<CcmParams>,
cf_parameters: Vec<u8>,
decimals: u8,
},
],
accounts: [
{
Expand All @@ -813,6 +860,9 @@ pub mod swap_endpoints {
types::SwapEvent::discriminator();
pub const SWAP_ENDPOINT_DATA_ACCOUNT_DISCRIMINATOR: [u8; ANCHOR_PROGRAM_DISCRIMINATOR_LENGTH] =
types::SwapEndpointDataAccount::discriminator();

pub type SwapNativeParams = types::SwapNativeParams;
pub type SwapTokenParams = types::SwapTokenParams;
}

#[cfg(test)]
Expand Down Expand Up @@ -849,6 +899,8 @@ mod idl {
Defined { name: String },
Option(Box<IdlFieldType>),
Vec(Box<IdlFieldType>),
SwapNativeParams,
SwapTokenParams,
}

impl std::fmt::Display for IdlFieldType {
Expand All @@ -865,6 +917,8 @@ mod idl {
IdlFieldType::Defined { name } => write!(f, "{}", name),
IdlFieldType::Option(ty) => write!(f, "Option<{}>", ty),
IdlFieldType::Vec(ty) => write!(f, "Vec<{}>", ty),
IdlFieldType::SwapNativeParams => write!(f, "SwapNativeParams"),
IdlFieldType::SwapTokenParams => write!(f, "SwapTokenParams"),
}
}
}
Expand Down

0 comments on commit 8cff95c

Please sign in to comment.