Skip to content

feat: implement gasp sdk #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: eth-rollup-develop
Choose a base branch
from
Open

Conversation

matusbalascak
Copy link

@matusbalascak matusbalascak commented Apr 7, 2025

BREAKING CHANGE: This version is not compatible with any older ones

Breaking changes

Types

  • MainTokens -> Asset[]
  • TokenBalance -> Balance
  • TokenId -> string
  • Token -> Asset (now missing symbol and balance)

Methods

  • getAssetsInfo -> sdk.asset.getAssets
  • getAmountOfTokensInPool -> sdk.pool.getTvl
  • calculateBuyPrice -> sdk.market.calculateBuyPrice
  • getTotalIssuance -> sdk.asset.getIssuance

Working with the node API directly

SDK instance also exports complete node API that users can use to make transactions and fetch queries:

const sdk = await Gasp.create(...);

const result = await sdk.api.query.assetRegistry.metadata.entries();

await sdk.api.tx.market.multiswapAsset(...)

Signing transactions

Instead of calling signTx you now use:

const pk = "...";
const account = "0x.....";
const signer = sdk.signers.ethers.create(pk)

const tx = sdk.tx.create({ account, signer })

const extrinsic = sdk.api.tx.market.mintLiquidity(...);

const events = await tx.signAndSend({ extrinsic }).catch(console.error);
console.log(events)

What's not a part of this PR

  • SignTx logic refactor - I've made some minor changes to limit existing bugs that I've found, but it's gonna require some more work to refactor it properly
  • Staking functionality - Staking is working with MPL reserves and it's a bit trickier to build as it requires batching of transactions and some other logic depending on how much of the user's assets are in what 'state'. It can be included in the following priorities for the SDK

@matusbalascak matusbalascak force-pushed the feat/sdk-2.0 branch 2 times, most recently from b44c3b8 to 146f723 Compare April 14, 2025 21:50
BREAKING CHANGE: This version is not compatible with any older ones
@matusbalascak matusbalascak force-pushed the feat/sdk-2.0 branch 2 times, most recently from 475b867 to f7f2b62 Compare April 16, 2025 09:36
@matusbalascak matusbalascak marked this pull request as ready for review April 16, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant