Withdraw your tokens from Suilend to your wallet.

Example Prompts

Natural Language Prompts

"withdraw 1 ssui"

LangChain Tool Prompts

// Withdraw 1 sSUI
{
 amount: 1;
 symbol: 'ssui';
}

Example Implementation

import { SuiAgentKit } from "@getnimbus/sui-agent-kit";

async function withdrawSuilend(agent: SuiAgentKit) {
  try {
    const result = await agent.withdrawSuilend({
      type: "UNSTAKING",
      amount: 1,
      symbol: "ssui",
    });
    console.log("Result:", result);
  } catch (error) {
    console.error("Withdraw failed:", error);
  }
}

Implementation Details

  • Check user balance
  • Initialize data from Suilend SDK
  • Prepare the transaction payload
  • Sign & execute the transaction

Response Format

// Successful response
{
  tx_hash: "DHGKz1EZDnDHbiRC2P3dZd7xuLnfGdncDaBvaExyTAfM",
  tx_status: "success",
}

// Error response
{
  tx_hash: "DHGKz1EZDnDHbiRC2P3dZd7xuLnfGdncDaBvaExyTAfM",
  tx_status: "failed",
}

Error Handling

try {
  const res = await agent.lendingSuilend({
    type: "UNSTAKING",
    amount: 1,
    symbol: "ssui",
  });
} catch (error) {
  // Handle error
}

Best Practices

  1. Balance Verification
  • Account for transaction fees
  1. Transaction Management
  • Monitor transaction status
  • Implement proper error handling
  • Use appropriate commitment levels
  1. Security
  • Verify transaction details
  • Double-check amounts
  • Keep private keys secure
  1. User Experience
  • Show transaction progress
  • Display staking rewards
  • get_holding: Check token balances