# SpringSui Integration

Typescript monorepo (frontend, sdk, cli): <https://github.com/solendprotocol/springsui>&#x20;

Smart contracts: <https://github.com/solendprotocol/liquid-staking>&#x20;

The [cli](https://github.com/solendprotocol/springsui/blob/staging/cli/src/index.ts) has examples of calling every single instruction in the springsui smart contracts.

Click [here](https://github.com/solendprotocol/liquid-staking) to access the SpringSui Github repo.

### Examples

#### Minting sSui

```rust
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

```rust
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)

```rust
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 [Suilend Discord.](https://docs.suilend.fi/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suilend.fi/springsui/springsui-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
