1.1.1 • Published 2 months ago

@suilend/steamm-sdk v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

steamm-fe/sdk

A TypeScript SDK for interacting with the STEAMM program published on npm as @suilend/steamm-sdk.

Mainnet actions

To initiate the sdk:

import { MAINNET_CONFIG, SteammSDK } from "@suilend/steamm-sdk";

const sdk = new SteammSDK(MAINNET_CONFIG);

sdk.signer = keypair;

To fetch the pools:

const pools = await sdk.fetchPoolData();

Alternatively, one can fetch all pools for a dedicated pair:

// Note: type1 and type2 do not correspond to the token type's position in the pool
const pools = await sdk.fetchPoolData([coinType1, coinType2]);

To deposit liquidity:

await sdk.Pool.depositLiquidityEntry(
  {
    pool: pools[0].poolId,
    coinTypeA,
    coinTypeB,
    coinA: usdcCoin,
    coinB: suiCoin,
    maxA: BigInt("1000000000000000000"),
    maxB: BigInt("1000000000000000000"),
  },
  tx,
);

To perform a swap:

await sdk.Pool.swapEntry(
  {
    pool: pools[0].poolId,
    coinTypeA,
    coinTypeB,
    coinA: usdcCoin,
    coinB: suiCoin,
    a2b: false,
    amountIn: BigInt("10000000000000"),
    minAmountOut: BigInt("0"),
  },
  tx,
);

And to redeem liquidity:

await sdk.Pool.redeemLiquidityEntry(
  {
    pool: pools[0].poolId,
    coinTypeA,
    coinTypeB,
    lpCoin: lpToken,
    minA: BigInt("0"),
    minB: BigInt("0"),
  },
  tx,
);

For quotations:

Deposit:

const quote = await sdk.Pool.quoteDeposit({
  pool: pools[0].poolId,
  maxA: BigInt("1000000000000000000"),
  maxB: BigInt("1000000000000000000"),
});

Redeem:

const quote = await sdk.Pool.quoteRedeem({
  pool: pools[0].poolId,
  lpTokens: BigInt("1000000000000000000"),
});

Swap:

const quote = await sdk.Pool.quoteSwap({
  pool: pools[0].poolId,
  a2b: false,
  amountIn: BigInt("10000000000000"),
});

Got a suggestion, running into issues, or have a question? Join our #dev-support channel on Discord.


1.1.1

2 months ago

1.1.0

2 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.0

3 months ago

0.0.25

4 months ago

0.0.24

4 months ago

0.0.22

4 months ago

0.0.21

4 months ago

0.0.20

4 months ago

0.0.19

4 months ago

0.0.18

4 months ago

0.0.17

5 months ago

0.0.16

6 months ago

0.0.15

6 months ago

0.0.14

6 months ago

0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago