1.1.1 • Published 6 months ago

@suilend/steamm-sdk v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 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

6 months ago

1.1.0

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.0

6 months ago

0.0.25

7 months ago

0.0.24

7 months ago

0.0.22

7 months ago

0.0.21

7 months ago

0.0.20

7 months ago

0.0.19

7 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago