Function decrease_limit_order_instructions

Source
pub async fn decrease_limit_order_instructions(
    rpc: &RpcClient,
    limit_order_mint: Pubkey,
    amount: u64,
    authority: Option<Pubkey>,
) -> Result<DecreaseLimitOrderInstruction, Box<dyn Error>>
Expand description

Generates instructions to decrease a limit order.

Decrease the existing limit order in a concentrated liquidity pool. Both input and output tokens are removed proportionally.

§Arguments

  • rpc - A reference to a Solana RPC client for fetching accounts and pool data.
  • amount - The share by which the limit order needs to be reduced.
  • limit_order_mint - The public key of the NFT mint address representing the limit order to be decreased.
  • authority - An optional public key of the account authorizing the transaction. Defaults to the global funder if not provided.

§Returns

A Result containing DecreaseLimitOrderInstruction on success:

  • instructions - A vector of Instruction objects required to execute the limit order closure.
  • additional_signers - A vector of Keypair objects representing additional signers required for the instructions.

§Errors

This function will return an error if:

  • The authority account is invalid or missing.
  • The limit order account is not found or have invalid data.
  • Any RPC request to the blockchain fails.

§Example

use fusionamm_sdk::decrease_limit_order_instructions;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_pubkey::pubkey;
use solana_keypair::Keypair;
use solana_signer::Signer;

#[tokio::main]
async fn main() {
    let rpc = RpcClient::new("https://api.mainnet.solana.com".to_string());
    let wallet = Keypair::new(); // Load your wallet here

    let limit_order_mint_address = pubkey!("HqoV7Qv27REUtmd9UKSJGGmCRNx3531t33bDG1BUfo9K");
    let authority = Some(wallet.pubkey());
    let amount = 1_000_000;

    let result = decrease_limit_order_instructions(
        &rpc,
        limit_order_mint_address,
        amount,
        authority,
    )
    .await
    .unwrap();

    println!("Number of Instructions: {}", result.instructions.len());
}