Unstake your SUI native staking

Usage

// Unstake
const stakedSuiId = '0xb73a5f2fc8ee3ca60f5efcd93242921e7138ab25f02df1d59c45d94d96411623'
const result = await agent.unstake(stakedSuiId);

Parameters

ParameterTypeRequiredDescription
stakedSuiIdstringYesStakedID of the position to unstake

Example Prompts

Natural Language Prompts

"unstake this position 0xb73a5f2fc8ee3ca60f5efcd93242921e7138ab25f02df1d59c45d94d96411623"

LangChain Tool Prompts

{
 "stakedSuiId": "0xb73a5f2fc8ee3ca60f5efcd93242921e7138ab25f02df1d59c45d94d96411623",
}

Example Implementation

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

async function unStake(agent: SuiAgentKit) {
  try {
    const stakeId =
      "0xb73a5f2fc8ee3ca60f5efcd93242921e7138ab25f02df1d59c45d94d96411623";
    const result = await agent.unStake(stakeId);
    console.log("Unstake result:", result);
  } catch (error) {
    console.error("Unstake failed:", error);
  }
}

Implementation Details

  • Uses sui system for unstaking
  • Automatically handles transaction versioning
  • Includes proper transaction confirmation
  • Remove liquid staking position

Response Format

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

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

Error Handling

try {
  const stakeId =
      "0xb73a5f2fc8ee3ca60f5efcd93242921e7138ab25f02df1d59c45d94d96411623";
  const result = await agent.unStake(stakeId);
} catch (error) {
  if (error.message.includes("Insufficient balance")) {
    // Handle insufficient balance
  } else {
    // Handle other transaction failures
  }  
}

Best Practices

  1. Gas 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