Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new command to set swap platform fee #414

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions contracts/svm/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use {
InitializeArgs,
SetRouterSplitArgs,
SetSplitsArgs,
SetSwapPlatformFeeArgs,
},
std::str::FromStr,
};
Expand Down Expand Up @@ -131,6 +132,16 @@ enum Commands {
/// The split to use for this specific router, in bps.
split_router: u64,
},
SetSwapPlatformFee {
#[arg(long)]
/// Path to the private key json file for the admin.
/// This account will be used as the transaction payer as well.
admin: String,

#[arg(long)]
/// The portion of the bid that goes to the platform, in bps.
fee_bps: u64,
},
WithdrawFees {
#[arg(long)]
/// Path to the private key json file for the admin.
Expand Down Expand Up @@ -289,6 +300,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Set router {:?} split to {:?} bps", router, split_router);
println!("Transaction signature {:?}", result);
}
Commands::SetSwapPlatformFee { admin, fee_bps } => {
let payer = read_keypair_file(admin)?;
let client = Client::new_with_options(cluster, &payer, CommitmentConfig::confirmed());
let program = client.program(program_id)?;

let result = program
.request()
.accounts(accounts::SetSplits {
admin: payer.pubkey(),
express_relay_metadata,
})
.args(instruction::SetSwapPlatformFee {
data: SetSwapPlatformFeeArgs {
swap_platform_fee_bps: fee_bps,
},
})
.signer(&payer)
.send()?;
println!("Set swap platform fee to {:?} bps", fee_bps);
println!("Transaction signature {:?}", result);
}
Commands::WithdrawFees {
admin,
fee_receiver,
Expand Down Expand Up @@ -320,6 +352,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Fee receiver relayer {:?}", metadata.fee_receiver_relayer);
println!("Split router default {:?}", metadata.split_router_default);
println!("Split relayer {:?}", metadata.split_relayer);
println!("Swap platform fee {:?}", metadata.swap_platform_fee_bps);
}
Commands::GetRouterSplit { router } => {
let keypair = Keypair::new();
Expand Down
Loading