THORSwap SwapKit
Ask or search…
K
Links
🏗️

V1 Migration

This page contains information what's changed on the first stable release from alpha stage. It's mostly directed to partners whose decided to integrate SwapKit in it's alpha version.
With V1 release we change License of SwapKit packages from MIT to Apache License 2.0. For exact comparison you can check those links:

Package name changes

With v1 we change naming of packages with additional change of organisation name. This both cuts out clearly a alpha versions from official release & keep naming of SDK simpler.
@thorswap-lib packages will be deprecated and will beremoved in future
Alpha Version
V1 Stable
@thorswap-lib/swapkit-sdk
@swapkit/sdk
@thorswap-lib/swapkit-core
@swapkit/core
@thorswap-lib/swapkit-api
@swapkit/api
@thorswap-lib/swapkit-entities
DEPRECATED - use @swapkit/helpers
@thorswap-lib/tokens
@swapkit/tokes
@thorswap-lib/types
@swapkit/types
@thorswap-lib/toolbox-cosmos
@swapkit/toolbox-cosmos
@thorswap-lib/toolbox-evm
@swapkit/toolbox-evm
@thorswap-lib/toolbox-utxo
@swapkit/toolbox-utxo
@thorswap-lib/evm-web3-wallets
@swapkit/wallet-evm-extensions
@thorswap-lib/keplr
@swapkit/wallet-keplr
@thorswap-lib/keystore
@swapkit/wallet-keystore
@thorswap-lib/ledger
@swapkit/wallet-ledger
@thorswap-lib/trezor
@swapkit/wallet-trezor
@thorswap-lib/walletconnect
@swapkit/wallet-wc
@thorswap-lib/xdefi
@swapkit/wallet-xdefi

Entities migration

SwapKit previously operated on entities like Amount Asset & AssetAmount internally to handle calculations & other manipulation. With v1 we came up with one AssetValue which handles a couple of things out of the box:

Easy chain gas token sync initialisation

Initialisation of chain gas assets - together with value

Static & Async token initialisation from lists or directly from contract

For Synchronous initialisation you have to install Tokens(TODO) package.
Initialisation of any asset via new fromIdentifier & fromIdentifierAsync methods
They also validate if asset has proper format and starts with chain supported via SwapKit
TypeScript can utilise over static token lists when installed which can heavily improve Developer Experience
TypeScript helps with providing proper identifiers to all tokens supported & listed via SwapKit API

Ethers v6 & BigInt

With v1 we also introduce migration from old ethers v5 to v6 which forces us to utilise BigInt JavaScript Implementation instead of BigNumber. New AssetValue implementation covers that and also has stored precision via native JS BigInt which reduces number of dependencies needed to run & library size. Click here to open AssetValue methods reference for more information.

Core method renames

We found current methods in alpha not self-explanatory enough, often complicate to use and sometimes implementing same thing in 2 methods because of older legacy code. With v1 release we renamed some of the methods and changed it's parameters to utilise new AssetValue entity which will help handle assets, values, decimals & arithmetics.
Old
New
New Params
approveAsset
approveAssetValue
(val: AssetValue) => Promise<string | true>
approveAssetForContract
approveAssetValue
(val: AssetValue) => Promise<string | true>
isAssetApproved
isAssetValueApproved
(val: AssetValue, contract?: string) => Promise<boolean>
isAssetApprovedForContract
isAssetValueApproved
(val: AssetValue, contract?: string) => Promise<boolean>
addSavings
savings
({ assetValue: AssetValue; memo?: string } & (
| { type: 'add'; percent?: undefined }
| { type: 'withdraw'; percent: number }
)) => Promise<string> | throw SwapKitError
withdrawSavings
savings
({ assetValue: AssetValue; memo?: string } & (
| { type: 'add'; percent?: undefined }
| { type: 'withdraw'; percent: number }
)) => Promise<string> | throw SwapKitError
openLoan
loan
({
assetValue: AssetValue;
memo?: string;
minAmount: AssetValue;
type: 'open' | 'close';
}) => Promise<string> | throw SwapKitError
closeLoan
loan
({
assetValue: AssetValue;
memo?: string;
minAmount: AssetValue;
type: 'open' | 'close';
}) => Promise<string> | throw SwapKitError
bond
nodeAction
({ address: string } & (
| { type: 'bond' | 'unbond'; assetValue: AssetValue }
| { type: 'leave'; assetValue?: undefined }
)) => Promise<string> | throw SwapKitError
unbond
nodeAction
({ address: string } & (
| { type: 'bond' | 'unbond'; assetValue: AssetValue }
| { type: 'leave'; assetValue?: undefined }
)) => Promise<string> | throw SwapKitError
leave
nodeAction
({ address: string } & (
| { type: 'bond' | 'unbond'; assetValue: AssetValue }
| { type: 'leave'; assetValue?: undefined }
)) => Promise<string> | throw SwapKitError