Sui

Get Chain Total Staked and Staked Ratio

GET https://stake.nansen.ai/api/v1/noneth/sui/total_staked

Response
{
  "success": true,
  "error_code": 0,
  "result": {
    "totalStaked": "8080549257.345467127",
    "stakedRatio": "0.8080549257345467127",
    "swuStaked": "36707660.044502961"
  }
}

Get SUI Balances

GEThttps://stake.nansen.ai/api/v1/noneth/sui/delegator/available_balance/{address}

Path Parameters

NameTypeDescription

address

string

Account address

Headers

NameTypeDescription

X-UNAGII-AUTH-TOKEN

string

Access token

Response
{
    "success": true,
    "error_code": 0,
    "result": {
        "address": "0x429d0fb21e8f4dff411162524125ec00eaf03f50c177306c615d496d0567f819",
        "balance": "0.962998824",
        "lockedBalance": {}
    }
}

Get Delegations

GET https://stake.nansen.ai/api/v1/noneth/sui/delegator/delegations/{address}

This endpoint allows you to get all delegations for an address

Path Parameters

NameTypeDescription

address

string

Account address

Headers

NameTypeDescription

X-UNAGII-AUTH-TOKEN

string

Access token

Response
{
    "success": true,
    "error_code": 0,
    "result": [
        {
            "validator": {
                "name": "Nansen",
                "description": "Secured Staking Made Easy. Put Your Crypto to Work. Hassle Free.",
                "staked": "36707660.044502961",
                "commission": 0.05
            },
            "stakes": [
                {
                    "stakedSuiId": "0x00b7a5ba9ff16376a20bce02f60f255a02d2b75c9881c137a90a70519a0d9e70",
                    "stakeRequestEpoch": "22",
                    "stakeActiveEpoch": "23",
                    "principal": "1",
                    "status": "Active",
                    "estimatedReward": "0.051344734"
                },
                {
                    "stakedSuiId": "0x57fdb24a213960262a1bf4272f8cd738c6a88283311ad04a299d6e6e64b83339",
                    "stakeRequestEpoch": "22",
                    "stakeActiveEpoch": "23",
                    "principal": "1",
                    "status": "Active",
                    "estimatedReward": "0.051344734"
                }
            ]
        }
    ]
}

Build Staking Transaction

import SUI from "@mysten/sui.js";

const connection = new SUI.Connection({
  fullnode: SUI_FULL_NODE,
});
const provider = new SUI.JsonRpcProvider(connection);
const res = await provider.getCoins({
  owner: WALLET_ADDRESS,
  coinType: '0x2::sui::SUI',
});
const stakeAmount = new BN(amount).multipliedBy(1e9).toNumber();
const tx = await SUI.SuiSystemStateUtil.newRequestAddStakeTxn(
  provider,
  res.data.map(item => item.coinObjectId),
  stakeAmount,
  VALIDATOR_ADDRESS
);
const transaction = tx.serialize();

Build Unstake Transaction

const SUI_SYSTEM_ADDRESS = "0x3";
const SUI_SYSTEM_MODULE_NAME = "sui_system";
const WITHDRAW_STAKE_FUN_NAME = "request_withdraw_stake";
const SUI_SYSTEM_STATE_OBJECT_ID = SUI.normalizeSuiObjectId("0x5");
const tx = new TransactionBlock();
tx.moveCall({
  target: `${SUI_SYSTEM_ADDRESS}::${SUI_SYSTEM_MODULE_NAME}::${WITHDRAW_STAKE_FUN_NAME}`,
  arguments: [
    tx.object(SUI_SYSTEM_STATE_OBJECT_ID),
    tx.object(STAKE_ID),
  ],
});
const transaction = tx.serialize()