From d371787b368c8201443dbf08ad228ba77a37f8ad Mon Sep 17 00:00:00 2001 From: emerson Date: Mon, 21 Nov 2022 14:27:09 +0800 Subject: [PATCH] Update input wrapper --- programs/adapter-jupiter/src/lib.rs | 14 ++++++++------ target/idl/adapter_jupiter.json | 6 +----- target/types/adapter_jupiter.ts | 12 ++---------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/programs/adapter-jupiter/src/lib.rs b/programs/adapter-jupiter/src/lib.rs index c32605e..87c626e 100644 --- a/programs/adapter-jupiter/src/lib.rs +++ b/programs/adapter-jupiter/src/lib.rs @@ -13,6 +13,8 @@ declare_id!("ADPT8iF4A7BSUWQ8AsVwmcod2suFzA4bpYpJj7kUWK3E"); pub mod adapter_jupiter { use super::*; + const PLATEFORM_FEE: u8 = 0; + pub fn swap(ctx: Context, input: Vec) -> Result<()> { let discriminator: [u8; 8] = sighash("global", "route"); @@ -25,10 +27,11 @@ pub mod adapter_jupiter { let input_struct = SwapInputWrapper::deserialize(&mut input_bytes)?; msg!("Input: {:?}", input_struct); - let mut last_index: usize = 13; - for index in 0..input_struct.swap_config.len() { - if input_struct.swap_config[index] == 255 { + let mut last_index: usize = 14; + for index in input_struct.swap_config.len()..0 { + if input_struct.swap_config[index] != 0 { last_index = index; + break; } } @@ -40,7 +43,7 @@ pub mod adapter_jupiter { swap_data.append(&mut input_struct.in_amount.try_to_vec()?); swap_data.append(&mut input_struct.out_amount.try_to_vec()?); swap_data.append(&mut input_struct.slippage_bps.try_to_vec()?); - swap_data.append(&mut input_struct.platform_fee_bps.try_to_vec()?); + swap_data.append(&mut PLATEFORM_FEE.try_to_vec()?); let ix = Instruction { program_id: ctx.accounts.base_program_id.key(), @@ -77,8 +80,7 @@ pub struct SwapInputWrapper { pub in_amount: u64, pub out_amount: u64, pub slippage_bps: u16, - pub platform_fee_bps: u8, - pub swap_config: [u8; 13], + pub swap_config: [u8; 14], } // OutputWrapper needs to take up all the space of 32 bytes diff --git a/target/idl/adapter_jupiter.json b/target/idl/adapter_jupiter.json index 57d626e..40646b2 100644 --- a/target/idl/adapter_jupiter.json +++ b/target/idl/adapter_jupiter.json @@ -42,16 +42,12 @@ "name": "slippageBps", "type": "u16" }, - { - "name": "platformFeeBps", - "type": "u8" - }, { "name": "swapConfig", "type": { "array": [ "u8", - 13 + 14 ] } } diff --git a/target/types/adapter_jupiter.ts b/target/types/adapter_jupiter.ts index c463831..694c708 100644 --- a/target/types/adapter_jupiter.ts +++ b/target/types/adapter_jupiter.ts @@ -42,16 +42,12 @@ export type AdapterJupiter = { "name": "slippageBps", "type": "u16" }, - { - "name": "platformFeeBps", - "type": "u8" - }, { "name": "swapConfig", "type": { "array": [ "u8", - 13 + 14 ] } } @@ -129,16 +125,12 @@ export const IDL: AdapterJupiter = { "name": "slippageBps", "type": "u16" }, - { - "name": "platformFeeBps", - "type": "u8" - }, { "name": "swapConfig", "type": { "array": [ "u8", - 13 + 14 ] } }