Suilend
  • Introduction to Suilend & SEND
  • SEND
    • SEND DAO
    • Tokenomics & Mdrops
    • mSEND & SEND Cointypes
    • How to Redeem mSEND and Claim SEND
    • SEND from SLND/SAVE Conversion
    • mDrops Integration
    • Roadmap
  • Security
    • Suilend Audit
    • Risks
    • Liquidations
  • Ecosystem
    • Suilend Integration
  • SpringSui
    • Intro to SpringSui Standard
    • SpringSui Audit
    • SpringSui Integration
  • Steamm
    • STEAMM Beta
    • STEAMM Whitepaper
    • STEAMM Audit
  • STEAMM Integration
  • Campaigns
    • BYBIT x SEND Campaign (Ended)
    • Sui Wallet Deposit Campaign (Ended)
    • Rootlets x DEEP Challenge (Ended)
  • Rootlets
    • The Rootlets Manifesto
    • Rootlets Holder Snapshot
  • FAQ
    • What are S2 Points and Capsules?
    • How do I set up a Sui Wallet?
    • How do I bridge to Sui?
    • How do I wrap SOL to bridge to Sui?
    • How do I use Account History and Earnings?
    • What are Account NFTs?
    • Why am I not receiving rewards?
    • What are Isolated Assets?
    • How can I claim Account Rewards?
  • Archive
    • What are Suilend Points and Capsules?
Powered by GitBook
On this page
  1. SpringSui

SpringSui Integration

Links to relevant SpringSui codebase.

PreviousSpringSui AuditNextSTEAMM Beta

Last updated 15 days ago

Typescript monorepo (frontend, sdk, cli):

Smart contracts:

The has examples of calling every single instruction in the springsui smart contracts.

Examples

Minting sSui

const LIQUID_STAKING_INFO = {
  id: "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b",
  type: "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI",
  weightHookId:
    "0xbbafcb2d7399c0846f8185da3f273ad5b26b3b35993050affa44cfa890f1f144",
};

const client = new SuiClient({ url: RPC_URL });
const lstClient = await LstClient.initialize(client, LIQUID_STAKING_INFO);

const tx = new Transaction();
const [sui] = tx.splitCoins(tx.gas, [BigInt(options.amount)]);
const sSui = lstClient.mint(tx, sui);
tx.transferObjects([sSui], keypair.toSuiAddress());

const txResponse = await client.signAndExecuteTransaction({
  transaction: tx,
  signer: keypair,
  options: {
    showEvents: true,
    showEffects: true,
    showObjectChanges: true,
  },
});

Redeeming sSui

const LIQUID_STAKING_INFO = {
  id: "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b",
  type: "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI",
  weightHookId:
    "0xbbafcb2d7399c0846f8185da3f273ad5b26b3b35993050affa44cfa890f1f144",
};

const client = new SuiClient({ url: RPC_URL });

const lstCoins = await client.getCoins({
  owner: keypair.toSuiAddress(),
  coinType: LIQUID_STAKING_INFO.type,
  limit: 1000,
});

const tx = new Transaction();
const lstClient = await LstClient.initialize(client, LIQUID_STAKING_INFO);

if (lstCoins.data.length > 1) {
  tx.mergeCoins(
    lstCoins.data[0].coinObjectId,
    lstCoins.data.slice(1).map((c) => c.coinObjectId),
  );
}

const [lst] = tx.splitCoins(lstCoins.data[0].coinObjectId, [
  BigInt(options.amount),
]);
const sui = lstClient.redeemLst(tx, lst);

tx.transferObjects([sui], keypair.toSuiAddress());

const txResponse = await client.signAndExecuteTransaction({
  transaction: tx,
  signer: keypair,
  options: {
    showEvents: true,
    showEffects: true,
    showObjectChanges: true,
  },
});

Get the exchange rate of sSUI/SUI offchain (using the SDK)

import { fetchLiquidStakingInfo } from "@suilend/springsui-sdk";
import BigNumber from "bignumber.js";

const LIQUID_STAKING_INFO = {
  id: "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b",
  type: "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI",
  weightHookId:
    "0xbbafcb2d7399c0846f8185da3f273ad5b26b3b35993050affa44cfa890f1f144",
};

const SUI_DECIMALS = 9;
const SSUI_DECIMALS = 9;

const rawLiquidStakingInfo = await fetchLiquidStakingInfo(
    LIQUID_STAKING_INFO,
    suiClient,
  );

  const totalSuiSupply = new BigNumber(
    rawLiquidStakingInfo.storage.totalSuiSupply.toString(),
  ).div(10 ** SUI_DECIMALS);
  const totalLstSupply = new BigNumber(
    rawLiquidStakingInfo.lstTreasuryCap.totalSupply.value.toString(),
  ).div(10 ** SSUI_DECIMALS);

  const suiToLstExchangeRate = !totalSuiSupply.eq(0)
    ? totalLstSupply.div(totalSuiSupply)
    : new BigNumber(0);

Any other questions? Head to the SpringSui channel on the

https://github.com/solendprotocol/springsui
https://github.com/solendprotocol/liquid-staking
cli
Suilend Discord.