@7kprotocol/sdk-ts 3.6.0 → 3.6.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -11
- package/lib/cjs/config/fetchClient.js +1 -9
- package/lib/cjs/constants/_7k.js +13 -10
- package/lib/cjs/constants/apiEndpoints.js +1 -1
- package/lib/cjs/features/metaAg/common.js +2 -2
- package/lib/cjs/features/metaAg/error.js +0 -4
- package/lib/cjs/features/metaAg/index.js +3 -8
- package/lib/cjs/features/prices/index.js +51 -20
- package/lib/cjs/index.js +1 -35
- package/lib/cjs/types/config/fetchClient.d.ts.map +1 -1
- package/lib/cjs/types/constants/_7k.d.ts +0 -3
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/common.d.ts +1 -1
- package/lib/cjs/types/features/metaAg/error.d.ts +1 -7
- package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/index.d.ts +1 -1
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/prices/index.d.ts +16 -2
- package/lib/cjs/types/features/prices/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +1 -32
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/metaAg.js +1 -3
- package/lib/cjs/types/types/metaAg.d.ts +2 -14
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/cjs/types/utils/sui.d.ts +0 -31
- package/lib/cjs/types/utils/sui.d.ts.map +1 -1
- package/lib/cjs/types/utils/swap.d.ts +15 -0
- package/lib/cjs/types/utils/swap.d.ts.map +1 -0
- package/lib/cjs/utils/sui.js +15 -154
- package/lib/cjs/utils/swap.js +37 -0
- package/lib/esm/config/fetchClient.js +1 -9
- package/lib/esm/constants/_7k.js +12 -9
- package/lib/esm/constants/apiEndpoints.js +1 -1
- package/lib/esm/features/metaAg/common.js +1 -1
- package/lib/esm/features/metaAg/error.js +0 -4
- package/lib/esm/features/metaAg/index.js +2 -7
- package/lib/esm/features/prices/index.js +52 -21
- package/lib/esm/index.mjs +3 -31
- package/lib/esm/types/config/fetchClient.d.ts.map +1 -1
- package/lib/esm/types/constants/_7k.d.ts +0 -3
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/common.d.ts +1 -1
- package/lib/esm/types/features/metaAg/error.d.ts +1 -7
- package/lib/esm/types/features/metaAg/error.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/index.d.ts +1 -1
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/prices/index.d.ts +16 -2
- package/lib/esm/types/features/prices/index.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +1 -32
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/metaAg.js +1 -3
- package/lib/esm/types/types/metaAg.d.ts +2 -14
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/types/utils/sui.d.ts +0 -31
- package/lib/esm/types/utils/sui.d.ts.map +1 -1
- package/lib/esm/types/utils/swap.d.ts +15 -0
- package/lib/esm/types/utils/swap.d.ts.map +1 -0
- package/lib/esm/utils/sui.js +17 -156
- package/lib/esm/utils/swap.js +33 -0
- package/package.json +1 -1
- package/lib/cjs/config/index.js +0 -67
- package/lib/cjs/features/metaAg/providers/bluefin7kLegacy.js +0 -68
- package/lib/cjs/features/swap/buildTx.js +0 -198
- package/lib/cjs/features/swap/buildTxV2.js +0 -229
- package/lib/cjs/features/swap/config.js +0 -154
- package/lib/cjs/features/swap/estimateGasFee.js +0 -44
- package/lib/cjs/features/swap/executeTx.js +0 -52
- package/lib/cjs/features/swap/getQuote.js +0 -95
- package/lib/cjs/features/swap/getSwapHistory.js +0 -21
- package/lib/cjs/features/swap/index.js +0 -22
- package/lib/cjs/libs/groupSwapRoutes.js +0 -60
- package/lib/cjs/libs/protocols/aftermath/index.js +0 -35
- package/lib/cjs/libs/protocols/base.js +0 -41
- package/lib/cjs/libs/protocols/bluefin/index.js +0 -38
- package/lib/cjs/libs/protocols/bluefinx/client.js +0 -41
- package/lib/cjs/libs/protocols/bluefinx/index.js +0 -48
- package/lib/cjs/libs/protocols/bluefinx/types.js +0 -10
- package/lib/cjs/libs/protocols/bluemove/index.js +0 -24
- package/lib/cjs/libs/protocols/cetus/index.js +0 -44
- package/lib/cjs/libs/protocols/cetus_dlmm.js +0 -48
- package/lib/cjs/libs/protocols/constants.js +0 -5
- package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +0 -30
- package/lib/cjs/libs/protocols/ferra_clmm.js +0 -44
- package/lib/cjs/libs/protocols/ferra_dlmm.js +0 -30
- package/lib/cjs/libs/protocols/flowx/index.js +0 -18
- package/lib/cjs/libs/protocols/flowxV3/index.js +0 -36
- package/lib/cjs/libs/protocols/fullsail/index.js +0 -39
- package/lib/cjs/libs/protocols/haedal_pmm/index.js +0 -31
- package/lib/cjs/libs/protocols/index.js +0 -55
- package/lib/cjs/libs/protocols/kriya/index.js +0 -30
- package/lib/cjs/libs/protocols/kriyaV3/index.js +0 -65
- package/lib/cjs/libs/protocols/magma/index.js +0 -40
- package/lib/cjs/libs/protocols/momentum/index.js +0 -49
- package/lib/cjs/libs/protocols/obric/index.js +0 -28
- package/lib/cjs/libs/protocols/sevenk/index.js +0 -55
- package/lib/cjs/libs/protocols/springsui/index.js +0 -24
- package/lib/cjs/libs/protocols/steamm/index.js +0 -160
- package/lib/cjs/libs/protocols/stsui/index.js +0 -24
- package/lib/cjs/libs/protocols/suiswap/index.js +0 -34
- package/lib/cjs/libs/protocols/turbos/index.js +0 -36
- package/lib/cjs/libs/protocols/utils.js +0 -7
- package/lib/cjs/libs/swapWithRoute.js +0 -22
- package/lib/cjs/types/aggregator.js +0 -19
- package/lib/cjs/types/config/index.d.ts +0 -30
- package/lib/cjs/types/config/index.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts +0 -11
- package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/buildTx.d.ts +0 -17
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/buildTxV2.d.ts +0 -20
- package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/config.d.ts +0 -4
- package/lib/cjs/types/features/swap/config.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/estimateGasFee.d.ts +0 -3
- package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/executeTx.d.ts +0 -24
- package/lib/cjs/types/features/swap/executeTx.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts +0 -27
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/getSwapHistory.d.ts +0 -22
- package/lib/cjs/types/features/swap/getSwapHistory.d.ts.map +0 -1
- package/lib/cjs/types/features/swap/index.d.ts +0 -7
- package/lib/cjs/types/features/swap/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/groupSwapRoutes.d.ts +0 -3
- package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/aftermath/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/aftermath/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/base.d.ts +0 -24
- package/lib/cjs/types/libs/protocols/base.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +0 -13
- package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +0 -17
- package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +0 -34
- package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/bluemove/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/bluemove/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/cetus/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/constants.d.ts +0 -3
- package/lib/cjs/types/libs/protocols/constants.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
- package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/flowx/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/flowx/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/fullsail/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/fullsail/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
- package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/index.d.ts +0 -53
- package/lib/cjs/types/libs/protocols/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/kriya/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/kriya/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/magma/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/momentum/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/obric/index.d.ts +0 -14
- package/lib/cjs/types/libs/protocols/obric/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/sevenk/index.d.ts +0 -18
- package/lib/cjs/types/libs/protocols/sevenk/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/springsui/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/springsui/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts +0 -28
- package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/stsui/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/stsui/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/suiswap/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/turbos/index.d.ts +0 -9
- package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/protocols/utils.d.ts +0 -2
- package/lib/cjs/types/libs/protocols/utils.d.ts.map +0 -1
- package/lib/cjs/types/libs/swapWithRoute.d.ts +0 -12
- package/lib/cjs/types/libs/swapWithRoute.d.ts.map +0 -1
- package/lib/cjs/types/sui.js +0 -2
- package/lib/cjs/types/tx.js +0 -2
- package/lib/cjs/types/types/aggregator.d.ts +0 -173
- package/lib/cjs/types/types/aggregator.d.ts.map +0 -1
- package/lib/cjs/types/types/sui.d.ts +0 -4
- package/lib/cjs/types/types/sui.d.ts.map +0 -1
- package/lib/cjs/types/types/tx.d.ts +0 -67
- package/lib/cjs/types/types/tx.d.ts.map +0 -1
- package/lib/cjs/types/types/utilities.d.ts +0 -5
- package/lib/cjs/types/types/utilities.d.ts.map +0 -1
- package/lib/cjs/types/utilities.js +0 -2
- package/lib/cjs/types/utils/number.d.ts +0 -2
- package/lib/cjs/types/utils/number.d.ts.map +0 -1
- package/lib/cjs/utils/number.js +0 -9
- package/lib/esm/config/index.js +0 -64
- package/lib/esm/features/metaAg/providers/bluefin7kLegacy.js +0 -66
- package/lib/esm/features/swap/buildTx.js +0 -188
- package/lib/esm/features/swap/buildTxV2.js +0 -223
- package/lib/esm/features/swap/config.js +0 -150
- package/lib/esm/features/swap/estimateGasFee.js +0 -41
- package/lib/esm/features/swap/executeTx.js +0 -48
- package/lib/esm/features/swap/getQuote.js +0 -91
- package/lib/esm/features/swap/getSwapHistory.js +0 -18
- package/lib/esm/features/swap/index.js +0 -6
- package/lib/esm/libs/groupSwapRoutes.js +0 -57
- package/lib/esm/libs/protocols/aftermath/index.js +0 -31
- package/lib/esm/libs/protocols/base.js +0 -42
- package/lib/esm/libs/protocols/bluefin/index.js +0 -34
- package/lib/esm/libs/protocols/bluefinx/client.js +0 -36
- package/lib/esm/libs/protocols/bluefinx/index.js +0 -44
- package/lib/esm/libs/protocols/bluefinx/types.js +0 -8
- package/lib/esm/libs/protocols/bluemove/index.js +0 -20
- package/lib/esm/libs/protocols/cetus/index.js +0 -40
- package/lib/esm/libs/protocols/cetus_dlmm.js +0 -44
- package/lib/esm/libs/protocols/constants.js +0 -2
- package/lib/esm/libs/protocols/deepbookV3/sponsored.js +0 -26
- package/lib/esm/libs/protocols/ferra_clmm.js +0 -40
- package/lib/esm/libs/protocols/ferra_dlmm.js +0 -26
- package/lib/esm/libs/protocols/flowx/index.js +0 -14
- package/lib/esm/libs/protocols/flowxV3/index.js +0 -32
- package/lib/esm/libs/protocols/fullsail/index.js +0 -35
- package/lib/esm/libs/protocols/haedal_pmm/index.js +0 -27
- package/lib/esm/libs/protocols/index.js +0 -52
- package/lib/esm/libs/protocols/kriya/index.js +0 -26
- package/lib/esm/libs/protocols/kriyaV3/index.js +0 -61
- package/lib/esm/libs/protocols/magma/index.js +0 -36
- package/lib/esm/libs/protocols/momentum/index.js +0 -45
- package/lib/esm/libs/protocols/obric/index.js +0 -24
- package/lib/esm/libs/protocols/sevenk/index.js +0 -51
- package/lib/esm/libs/protocols/springsui/index.js +0 -20
- package/lib/esm/libs/protocols/steamm/index.js +0 -156
- package/lib/esm/libs/protocols/stsui/index.js +0 -20
- package/lib/esm/libs/protocols/suiswap/index.js +0 -30
- package/lib/esm/libs/protocols/turbos/index.js +0 -32
- package/lib/esm/libs/protocols/utils.js +0 -4
- package/lib/esm/libs/swapWithRoute.js +0 -19
- package/lib/esm/types/aggregator.js +0 -14
- package/lib/esm/types/config/index.d.ts +0 -30
- package/lib/esm/types/config/index.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts +0 -11
- package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +0 -1
- package/lib/esm/types/features/swap/buildTx.d.ts +0 -17
- package/lib/esm/types/features/swap/buildTx.d.ts.map +0 -1
- package/lib/esm/types/features/swap/buildTxV2.d.ts +0 -20
- package/lib/esm/types/features/swap/buildTxV2.d.ts.map +0 -1
- package/lib/esm/types/features/swap/config.d.ts +0 -4
- package/lib/esm/types/features/swap/config.d.ts.map +0 -1
- package/lib/esm/types/features/swap/estimateGasFee.d.ts +0 -3
- package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +0 -1
- package/lib/esm/types/features/swap/executeTx.d.ts +0 -24
- package/lib/esm/types/features/swap/executeTx.d.ts.map +0 -1
- package/lib/esm/types/features/swap/getQuote.d.ts +0 -27
- package/lib/esm/types/features/swap/getQuote.d.ts.map +0 -1
- package/lib/esm/types/features/swap/getSwapHistory.d.ts +0 -22
- package/lib/esm/types/features/swap/getSwapHistory.d.ts.map +0 -1
- package/lib/esm/types/features/swap/index.d.ts +0 -7
- package/lib/esm/types/features/swap/index.d.ts.map +0 -1
- package/lib/esm/types/libs/groupSwapRoutes.d.ts +0 -3
- package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/aftermath/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/aftermath/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/base.d.ts +0 -24
- package/lib/esm/types/libs/protocols/base.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +0 -13
- package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +0 -17
- package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +0 -34
- package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/bluemove/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/bluemove/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/cetus/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts +0 -9
- package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/constants.d.ts +0 -3
- package/lib/esm/types/libs/protocols/constants.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
- package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/ferra_clmm.d.ts +0 -9
- package/lib/esm/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts +0 -9
- package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/flowx/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/flowx/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/flowxV3/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/fullsail/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/fullsail/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
- package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/index.d.ts +0 -53
- package/lib/esm/types/libs/protocols/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/kriya/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/kriya/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/magma/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/magma/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/momentum/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/obric/index.d.ts +0 -14
- package/lib/esm/types/libs/protocols/obric/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/sevenk/index.d.ts +0 -18
- package/lib/esm/types/libs/protocols/sevenk/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/springsui/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/springsui/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/steamm/index.d.ts +0 -28
- package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/stsui/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/stsui/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/suiswap/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/turbos/index.d.ts +0 -9
- package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +0 -1
- package/lib/esm/types/libs/protocols/utils.d.ts +0 -2
- package/lib/esm/types/libs/protocols/utils.d.ts.map +0 -1
- package/lib/esm/types/libs/swapWithRoute.d.ts +0 -12
- package/lib/esm/types/libs/swapWithRoute.d.ts.map +0 -1
- package/lib/esm/types/sui.js +0 -1
- package/lib/esm/types/tx.js +0 -1
- package/lib/esm/types/types/aggregator.d.ts +0 -173
- package/lib/esm/types/types/aggregator.d.ts.map +0 -1
- package/lib/esm/types/types/sui.d.ts +0 -4
- package/lib/esm/types/types/sui.d.ts.map +0 -1
- package/lib/esm/types/types/tx.d.ts +0 -67
- package/lib/esm/types/types/tx.d.ts.map +0 -1
- package/lib/esm/types/types/utilities.d.ts +0 -5
- package/lib/esm/types/types/utilities.d.ts.map +0 -1
- package/lib/esm/types/utilities.js +0 -1
- package/lib/esm/types/utils/number.d.ts +0 -2
- package/lib/esm/types/utils/number.d.ts.map +0 -1
- package/lib/esm/utils/number.js +0 -6
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
import { CoinStruct, SuiObjectResponseQuery } from "@mysten/sui/client";
|
|
2
1
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
3
|
-
type DataPage<T> = {
|
|
4
|
-
data: T[];
|
|
5
|
-
nextCursor?: any;
|
|
6
|
-
hasNextPage: boolean;
|
|
7
|
-
};
|
|
8
|
-
type PageQuery = {
|
|
9
|
-
cursor?: any;
|
|
10
|
-
limit?: number | null;
|
|
11
|
-
};
|
|
12
|
-
type PaginationArgs = "all" | PageQuery;
|
|
13
2
|
export declare const SuiUtils: {
|
|
14
3
|
getSuiCoin(amount: bigint | TransactionArgument, txb: Transaction): TransactionArgument;
|
|
15
|
-
mergeCoins(coinObjects: Array<string | TransactionArgument>, txb: Transaction): TransactionArgument | undefined;
|
|
16
4
|
getCoinValue(coinType: string, coinObject: string | TransactionArgument, txb: Transaction): TransactionArgument;
|
|
17
|
-
getExactCoinByAmount(coinType: string, coins: {
|
|
18
|
-
objectId: string;
|
|
19
|
-
balance: bigint;
|
|
20
|
-
}[], amount: bigint, txb: Transaction): {
|
|
21
|
-
$kind: "NestedResult";
|
|
22
|
-
NestedResult: [number, number];
|
|
23
|
-
};
|
|
24
|
-
mergeAllUserCoins(coinType: string, signerAddress: string): Promise<Transaction | undefined>;
|
|
25
|
-
mergeAllCoinsWithoutFetch(coins: CoinStruct[], coinType: string, txb: Transaction): void;
|
|
26
|
-
getAllUserCoins({ address, type }: {
|
|
27
|
-
type: string;
|
|
28
|
-
address: string;
|
|
29
|
-
}): Promise<CoinStruct[]>;
|
|
30
|
-
getCoinsGreaterThanAmount(amount: bigint, coins: {
|
|
31
|
-
objectId: string;
|
|
32
|
-
balance: bigint;
|
|
33
|
-
}[]): string[];
|
|
34
|
-
getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
|
|
35
5
|
isValidStructTag(value: string): boolean;
|
|
36
6
|
zeroBalance(tx: Transaction, coinType: string): {
|
|
37
7
|
$kind: "NestedResult";
|
|
@@ -54,5 +24,4 @@ export declare const SuiUtils: {
|
|
|
54
24
|
transferOrDestroyZeroCoin(tx: Transaction, coinType: string, coin: TransactionArgument, address: string): void;
|
|
55
25
|
};
|
|
56
26
|
export declare const isSystemAddress: (address: string) => boolean;
|
|
57
|
-
export {};
|
|
58
27
|
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAqB5E,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,WAAW,GACf,mBAAmB;2BAMV,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,WAAW,GACf,mBAAmB;4BAWE,MAAM;oBAQd,WAAW,YAAY,MAAM;;;;iBAQhC,WAAW,YAAY,MAAM;;;;wBASpC,WAAW,YACL,MAAM,cACJ,mBAAmB;;;;wBAU3B,WAAW,YACL,MAAM,WACP,mBAAmB;;;;2BAUxB,WAAW,YACL,MAAM,WACP,mBAAmB;oBASd,WAAW,YAAY,MAAM,QAAQ,mBAAmB;kCASlE,WAAW,YACL,MAAM,QACV,mBAAmB,WAChB,MAAM;CAQlB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,YAiB9C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate expected return amount after applying slippage, commission, and tip
|
|
3
|
+
* @param returnAmount - The raw return amount (with decimals)
|
|
4
|
+
* @param slippageBps - Slippage in basis points (1 bps = 0.01%)
|
|
5
|
+
* @param commissionBps - Commission in basis points
|
|
6
|
+
* @param tipBps - Tip in basis points (default: 0)
|
|
7
|
+
* @returns Object containing tipAmount, minAmount, commissionAmount, and expectedAmount
|
|
8
|
+
*/
|
|
9
|
+
export declare const getExpectedReturn: (returnAmount: string, slippageBps: number, commissionBps: number, tipBps?: number) => {
|
|
10
|
+
tipAmount: bigint;
|
|
11
|
+
minAmount: bigint;
|
|
12
|
+
commissionAmount: bigint;
|
|
13
|
+
expectedAmount: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=swap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../../../src/utils/swap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,eAAe,MAAM,EACrB,SAAQ,MAAU;;;;;CA8BnB,CAAC"}
|
package/lib/cjs/utils/sui.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSystemAddress = exports.SuiUtils = void 0;
|
|
4
|
-
const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
|
|
5
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
6
4
|
const utils_1 = require("@mysten/sui/utils");
|
|
7
|
-
const config_1 = require("../config");
|
|
8
5
|
const _7k_1 = require("../constants/_7k");
|
|
9
|
-
const token_1 = require("./token");
|
|
10
6
|
exports.SuiUtils = {
|
|
11
7
|
getSuiCoin(amount, txb) {
|
|
12
8
|
const [coin] = txb.splitCoins(txb.gas, [amount]);
|
|
13
9
|
return coin;
|
|
14
10
|
},
|
|
15
|
-
mergeCoins(coinObjects, txb) {
|
|
16
|
-
if (coinObjects.length == 1) {
|
|
17
|
-
return typeof coinObjects[0] == "string"
|
|
18
|
-
? txb.object(coinObjects[0])
|
|
19
|
-
: coinObjects[0];
|
|
20
|
-
}
|
|
21
|
-
const firstCoin = typeof coinObjects[0] == "string"
|
|
22
|
-
? txb.object(coinObjects[0])
|
|
23
|
-
: coinObjects[0];
|
|
24
|
-
txb.mergeCoins(
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
firstCoin, coinObjects
|
|
28
|
-
.slice(1)
|
|
29
|
-
.map((coin) => (typeof coin == "string" ? txb.object(coin) : coin)));
|
|
30
|
-
return firstCoin;
|
|
31
|
-
},
|
|
32
11
|
getCoinValue(coinType, coinObject, txb) {
|
|
33
12
|
const inputCoinObject = typeof coinObject == "string" ? txb.object(coinObject) : coinObject;
|
|
34
13
|
const [value] = txb.moveCall({
|
|
@@ -38,128 +17,6 @@ exports.SuiUtils = {
|
|
|
38
17
|
});
|
|
39
18
|
return value;
|
|
40
19
|
},
|
|
41
|
-
getExactCoinByAmount(coinType, coins, amount, txb) {
|
|
42
|
-
if ((0, token_1.checkIsSui)(coinType)) {
|
|
43
|
-
const [coinA] = txb.splitCoins(txb.gas, [amount]);
|
|
44
|
-
return coinA;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const coinsX = exports.SuiUtils.getCoinsGreaterThanAmount(amount, coins);
|
|
48
|
-
if (coinsX.length > 1) {
|
|
49
|
-
txb.mergeCoins(txb.object(coinsX[0]), coinsX.slice(1).map((coin) => txb.object(coin)));
|
|
50
|
-
}
|
|
51
|
-
const [coinA] = txb.splitCoins(txb.object(coinsX[0]), [amount]);
|
|
52
|
-
return coinA;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async mergeAllUserCoins(coinType, signerAddress) {
|
|
56
|
-
try {
|
|
57
|
-
const coins = await exports.SuiUtils.getAllUserCoins({
|
|
58
|
-
address: signerAddress,
|
|
59
|
-
type: coinType,
|
|
60
|
-
});
|
|
61
|
-
let totalBalance = BigInt(0);
|
|
62
|
-
coins.forEach((coin) => {
|
|
63
|
-
totalBalance += BigInt(coin.balance);
|
|
64
|
-
});
|
|
65
|
-
const txb = new transactions_1.Transaction();
|
|
66
|
-
if ((0, token_1.checkIsSui)(coinType)) {
|
|
67
|
-
totalBalance = totalBalance - BigInt("1000");
|
|
68
|
-
txb.splitCoins(txb.gas, [totalBalance]);
|
|
69
|
-
}
|
|
70
|
-
const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
|
|
71
|
-
if (coins.length > 1) {
|
|
72
|
-
txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
|
|
73
|
-
}
|
|
74
|
-
return txb;
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
console.log(error);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
mergeAllCoinsWithoutFetch(coins, coinType, txb) {
|
|
81
|
-
let totalBalance = BigInt(0);
|
|
82
|
-
coins.forEach((coin) => {
|
|
83
|
-
totalBalance += BigInt(coin.balance);
|
|
84
|
-
});
|
|
85
|
-
if ((0, token_1.checkIsSui)(coinType)) {
|
|
86
|
-
totalBalance = totalBalance - BigInt("1000");
|
|
87
|
-
txb.splitCoins(txb.gas, [totalBalance]);
|
|
88
|
-
}
|
|
89
|
-
const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
|
|
90
|
-
if (coins.length > 1) {
|
|
91
|
-
txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
async getAllUserCoins({ address, type }) {
|
|
95
|
-
let cursor = undefined;
|
|
96
|
-
let coins = [];
|
|
97
|
-
let iter = 0;
|
|
98
|
-
do {
|
|
99
|
-
try {
|
|
100
|
-
const res = await config_1.Config.getSuiClient().getCoins({
|
|
101
|
-
owner: address,
|
|
102
|
-
coinType: type,
|
|
103
|
-
cursor: cursor,
|
|
104
|
-
limit: 50,
|
|
105
|
-
});
|
|
106
|
-
coins = coins.concat(res.data);
|
|
107
|
-
cursor = res.nextCursor;
|
|
108
|
-
if (!res.hasNextPage || iter === 8) {
|
|
109
|
-
cursor = null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
console.log(error);
|
|
114
|
-
cursor = null;
|
|
115
|
-
}
|
|
116
|
-
iter++;
|
|
117
|
-
} while (cursor !== null);
|
|
118
|
-
return coins;
|
|
119
|
-
},
|
|
120
|
-
getCoinsGreaterThanAmount(amount, coins) {
|
|
121
|
-
const coinsWithBalance = [];
|
|
122
|
-
let collectedAmount = BigInt(0);
|
|
123
|
-
for (const coin of coins) {
|
|
124
|
-
if (collectedAmount < amount &&
|
|
125
|
-
!coinsWithBalance.includes(coin.objectId)) {
|
|
126
|
-
coinsWithBalance.push(coin.objectId);
|
|
127
|
-
collectedAmount = collectedAmount + coin.balance;
|
|
128
|
-
}
|
|
129
|
-
if (coin.balance === BigInt(0) &&
|
|
130
|
-
!coinsWithBalance.includes(coin.objectId))
|
|
131
|
-
coinsWithBalance.push(coin.objectId);
|
|
132
|
-
}
|
|
133
|
-
if (collectedAmount >= amount) {
|
|
134
|
-
return coinsWithBalance;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
throw new Error("Insufficient balance");
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
async getOwnedObjectsByPage(owner, query, paginationArgs = "all") {
|
|
141
|
-
let result = [];
|
|
142
|
-
let hasNextPage = true;
|
|
143
|
-
const queryAll = paginationArgs === "all";
|
|
144
|
-
let nextCursor = queryAll ? null : paginationArgs.cursor;
|
|
145
|
-
do {
|
|
146
|
-
const res = await config_1.Config.getSuiClient().getOwnedObjects({
|
|
147
|
-
owner,
|
|
148
|
-
...query,
|
|
149
|
-
cursor: nextCursor,
|
|
150
|
-
limit: queryAll ? null : paginationArgs.limit,
|
|
151
|
-
});
|
|
152
|
-
if (res.data) {
|
|
153
|
-
result = [...result, ...res.data];
|
|
154
|
-
hasNextPage = res.hasNextPage;
|
|
155
|
-
nextCursor = res.nextCursor;
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
hasNextPage = false;
|
|
159
|
-
}
|
|
160
|
-
} while (queryAll && hasNextPage);
|
|
161
|
-
return { data: result, nextCursor, hasNextPage };
|
|
162
|
-
},
|
|
163
20
|
isValidStructTag(value) {
|
|
164
21
|
try {
|
|
165
22
|
return !!(0, utils_1.parseStructTag)(value);
|
|
@@ -205,14 +62,14 @@ exports.SuiUtils = {
|
|
|
205
62
|
},
|
|
206
63
|
collectDust(tx, coinType, coin) {
|
|
207
64
|
tx.moveCall({
|
|
208
|
-
target: `${_7k_1.
|
|
65
|
+
target: `${_7k_1._7K_META_PACKAGE_ID}::vault::collect_dust`,
|
|
209
66
|
typeArguments: [coinType],
|
|
210
|
-
arguments: [tx.object(_7k_1.
|
|
67
|
+
arguments: [tx.object(_7k_1._7K_META_VAULT), tx.object(_7k_1._7K_META_CONFIG), coin],
|
|
211
68
|
});
|
|
212
69
|
},
|
|
213
70
|
transferOrDestroyZeroCoin(tx, coinType, coin, address) {
|
|
214
71
|
tx.moveCall({
|
|
215
|
-
target: `${_7k_1.
|
|
72
|
+
target: `${_7k_1._7K_META_PACKAGE_ID}::utils::transfer_or_destroy`,
|
|
216
73
|
typeArguments: [coinType],
|
|
217
74
|
arguments: [coin, tx.pure.address(address)],
|
|
218
75
|
});
|
|
@@ -221,15 +78,19 @@ exports.SuiUtils = {
|
|
|
221
78
|
const isSystemAddress = (address) => {
|
|
222
79
|
const addr = (0, utils_1.normalizeSuiAddress)(address);
|
|
223
80
|
const addresses = [
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
"
|
|
81
|
+
"0x0", // zero
|
|
82
|
+
"0x1", // std
|
|
83
|
+
"0x2", // sui framework
|
|
84
|
+
"0x3", // unkown but we reserved to be safe
|
|
85
|
+
"0x4", // unknown but we reserved to be safe
|
|
86
|
+
"0x5", // system state
|
|
87
|
+
"0x6", // time
|
|
88
|
+
"0x7", // unknown but we reserved to be safe
|
|
89
|
+
"0x8", // random
|
|
90
|
+
"0x9", // unknown but we reserved to be safe
|
|
91
|
+
"0x403", // coin deny list
|
|
92
|
+
"0xc", // coin registry
|
|
231
93
|
].map((v) => (0, utils_1.normalizeSuiAddress)(v));
|
|
232
94
|
return addresses.includes(addr);
|
|
233
95
|
};
|
|
234
96
|
exports.isSystemAddress = isSystemAddress;
|
|
235
|
-
console.log((0, exports.isSystemAddress)("0x0"));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExpectedReturn = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Calculate expected return amount after applying slippage, commission, and tip
|
|
6
|
+
* @param returnAmount - The raw return amount (with decimals)
|
|
7
|
+
* @param slippageBps - Slippage in basis points (1 bps = 0.01%)
|
|
8
|
+
* @param commissionBps - Commission in basis points
|
|
9
|
+
* @param tipBps - Tip in basis points (default: 0)
|
|
10
|
+
* @returns Object containing tipAmount, minAmount, commissionAmount, and expectedAmount
|
|
11
|
+
*/
|
|
12
|
+
const getExpectedReturn = (returnAmount, slippageBps, commissionBps, tipBps = 0) => {
|
|
13
|
+
if (slippageBps > 10000) {
|
|
14
|
+
throw new Error("Slippage must be less than 100%");
|
|
15
|
+
}
|
|
16
|
+
if (commissionBps > 10000) {
|
|
17
|
+
throw new Error("Commission must be less than 100%");
|
|
18
|
+
}
|
|
19
|
+
if (tipBps > 10000) {
|
|
20
|
+
throw new Error("Tip must be less than 100%");
|
|
21
|
+
}
|
|
22
|
+
const returnAmountWithDecimal = BigInt(returnAmount);
|
|
23
|
+
const tipAmountWithDecimal = (returnAmountWithDecimal * BigInt(tipBps || 0)) / 10000n;
|
|
24
|
+
const commissionAmountWithDecimal = ((returnAmountWithDecimal - tipAmountWithDecimal) * BigInt(commissionBps)) /
|
|
25
|
+
10000n;
|
|
26
|
+
const expectedReturnWithDecimal = returnAmountWithDecimal -
|
|
27
|
+
tipAmountWithDecimal -
|
|
28
|
+
commissionAmountWithDecimal;
|
|
29
|
+
const minAmountWithDecimal = (expectedReturnWithDecimal * BigInt(1e4 - slippageBps)) / 10000n;
|
|
30
|
+
return {
|
|
31
|
+
tipAmount: tipAmountWithDecimal,
|
|
32
|
+
minAmount: minAmountWithDecimal,
|
|
33
|
+
commissionAmount: commissionAmountWithDecimal,
|
|
34
|
+
expectedAmount: expectedReturnWithDecimal.toString(10),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.getExpectedReturn = getExpectedReturn;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { Config } from "./index";
|
|
2
1
|
export async function fetchClient(input, init) {
|
|
3
2
|
const headers = new Headers(init?.headers);
|
|
4
|
-
|
|
5
|
-
const bluefinXApiKey = (Config.getBluefinXApiKey() || "").trim();
|
|
6
|
-
if (apiKey) {
|
|
7
|
-
headers.set("apiKey", apiKey);
|
|
8
|
-
}
|
|
9
|
-
if (bluefinXApiKey) {
|
|
10
|
-
headers.set("Bluefin-X-API-Key", bluefinXApiKey);
|
|
11
|
-
}
|
|
3
|
+
// intercept the request and add the headers go here...
|
|
12
4
|
const modifiedInit = {
|
|
13
5
|
...init,
|
|
14
6
|
headers,
|
package/lib/esm/constants/_7k.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
export const _7K_PACKAGE_ID =
|
|
2
|
-
//
|
|
3
|
-
//legacy
|
|
4
|
-
//legacy
|
|
5
|
-
//legacy
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
//legacy v3: "
|
|
1
|
+
// export const _7K_PACKAGE_ID =
|
|
2
|
+
// "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
|
|
3
|
+
// //legacy V4: "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
|
|
4
|
+
// //legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
5
|
+
// //legacy V2: "0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f";
|
|
6
|
+
// //legacy V1: "0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc";
|
|
7
|
+
// export const _7K_CONFIG =
|
|
8
|
+
// "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
|
|
9
|
+
// //legacy v3: "0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee";
|
|
10
|
+
// export const _7K_VAULT =
|
|
11
|
+
// "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
|
|
12
|
+
// //legacy v3: "0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514";
|
|
10
13
|
export const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
11
14
|
export const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
12
15
|
export const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
|
|
2
2
|
import { _7K_META_CONFIG, _7K_META_PACKAGE_ID, _7K_META_PUBLISHED_AT, _7K_META_VAULT, } from "../../constants/_7k";
|
|
3
|
-
import { getExpectedReturn } from "
|
|
3
|
+
import { getExpectedReturn } from "../../utils/swap";
|
|
4
4
|
import { MetaAgError, MetaAgErrorCode } from "./error";
|
|
5
5
|
export const simulateSwapTx = async (tx, inspector, simulation) => {
|
|
6
6
|
const res = await timeout(() => inspector.devInspectTransactionBlock({
|
|
@@ -11,10 +11,6 @@ export var MetaAgErrorCode;
|
|
|
11
11
|
MetaAgErrorCode[MetaAgErrorCode["SIMULATION_FAILED"] = 1008] = "SIMULATION_FAILED";
|
|
12
12
|
// OKX error
|
|
13
13
|
MetaAgErrorCode[MetaAgErrorCode["OKX_FINALIZE_COMMAND_NOT_FOUND"] = 1100] = "OKX_FINALIZE_COMMAND_NOT_FOUND";
|
|
14
|
-
// BluefinX error
|
|
15
|
-
MetaAgErrorCode[MetaAgErrorCode["BLUEFINX_TRANSACTION_NOT_FOUND"] = 1200] = "BLUEFINX_TRANSACTION_NOT_FOUND";
|
|
16
|
-
MetaAgErrorCode[MetaAgErrorCode["BLUEFINX_TRANSACTION_NOT_APPROVED"] = 1201] = "BLUEFINX_TRANSACTION_NOT_APPROVED";
|
|
17
|
-
MetaAgErrorCode[MetaAgErrorCode["BLUEFINX_TRANSACTION_DIGEST_NOT_FOUND"] = 1202] = "BLUEFINX_TRANSACTION_DIGEST_NOT_FOUND";
|
|
18
14
|
})(MetaAgErrorCode || (MetaAgErrorCode = {}));
|
|
19
15
|
export class MetaAgError extends Error {
|
|
20
16
|
code;
|
|
@@ -5,10 +5,9 @@ import { SUI_ADDRESS_ZERO } from "../../constants/sui";
|
|
|
5
5
|
import { EProvider, isAggregatorProvider, isSwapAPIProvider, } from "../../types/metaAg";
|
|
6
6
|
import { isSystemAddress } from "../../utils/sui";
|
|
7
7
|
import { SuiClientUtils } from "../../utils/SuiClientUtils";
|
|
8
|
-
import { getExpectedReturn } from "
|
|
8
|
+
import { getExpectedReturn } from "../../utils/swap";
|
|
9
9
|
import { metaSettle, simulateAggregator, timeout } from "./common";
|
|
10
10
|
import { MetaAgError, MetaAgErrorCode } from "./error";
|
|
11
|
-
import { BluefinLegacyProvider } from "./providers/bluefin7kLegacy";
|
|
12
11
|
import { OkxProvider, simulateOKXSwap } from "./providers/okx";
|
|
13
12
|
const HERMES_API = "https://hermes.pyth.network";
|
|
14
13
|
const DEFAULT_PROVIDERS = {
|
|
@@ -43,9 +42,6 @@ export class MetaAg {
|
|
|
43
42
|
const providerOptions = this.options.providers[provider];
|
|
44
43
|
MetaAgError.assert(!!providerOptions, `Provider not found: ${provider}`, MetaAgErrorCode.PROVIDER_NOT_FOUND, { provider });
|
|
45
44
|
switch (provider) {
|
|
46
|
-
case EProvider.BLUEFIN7K_LEGACY:
|
|
47
|
-
this.providers[EProvider.BLUEFIN7K_LEGACY] = new BluefinLegacyProvider(providerOptions, this.options, this.client);
|
|
48
|
-
break;
|
|
49
45
|
case EProvider.BLUEFIN7K:
|
|
50
46
|
const { Bluefin7kProvider } = await import("./providers/bluefin7k").catch(catchImportError(EProvider.BLUEFIN7K));
|
|
51
47
|
this.providers[EProvider.BLUEFIN7K] = new Bluefin7kProvider(providerOptions, this.options, this.client);
|
|
@@ -156,7 +152,7 @@ export class MetaAg {
|
|
|
156
152
|
/**
|
|
157
153
|
* Build transaction from quote
|
|
158
154
|
* @info Use this function to build composable transaction (ie: add more commands after the swap, consume the coin out object)
|
|
159
|
-
* @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie:
|
|
155
|
+
* @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie: Okx, ...) are not supported, please use `fastSwap` instead
|
|
160
156
|
* @param options - build tx options
|
|
161
157
|
* @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
|
|
162
158
|
* @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
|
|
@@ -229,7 +225,6 @@ const catchImportError = (provider) => {
|
|
|
229
225
|
const map = {
|
|
230
226
|
[EProvider.CETUS]: "@cetusprotocol/aggregator-sdk",
|
|
231
227
|
[EProvider.FLOWX]: "@flowx-finance/sdk",
|
|
232
|
-
[EProvider.BLUEFIN7K_LEGACY]: "@7kprotocol/sdk-ts",
|
|
233
228
|
[EProvider.BLUEFIN7K]: "@bluefin-exchange/bluefin7k-aggregator-sdk",
|
|
234
229
|
[EProvider.OKX]: "",
|
|
235
230
|
};
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { fetchClient } from "../../config/fetchClient";
|
|
2
2
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
3
|
-
import {
|
|
3
|
+
import { SUI_FULL_TYPE } from "../../constants/tokens";
|
|
4
4
|
import { normalizeTokenType } from "../../utils/token";
|
|
5
|
-
export async function getTokenPrice(id, vsCoin = NATIVE_USDC_TOKEN_TYPE) {
|
|
6
|
-
try {
|
|
7
|
-
const response = await fetchClient(`${API_ENDPOINTS.PRICES}/price?ids=${normalizeTokenType(id)}&vsCoin=${vsCoin}`);
|
|
8
|
-
const pricesRes = (await response.json());
|
|
9
|
-
return Number(pricesRes?.[id]?.price || 0);
|
|
10
|
-
}
|
|
11
|
-
catch (_) {
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
5
|
const chunkArray = (array, chunkSize) => {
|
|
16
6
|
const chunks = [];
|
|
17
7
|
for (let i = 0; i < array.length; i += chunkSize) {
|
|
@@ -21,30 +11,66 @@ const chunkArray = (array, chunkSize) => {
|
|
|
21
11
|
};
|
|
22
12
|
const MAX_TOTAL_IDS = 500;
|
|
23
13
|
const MAX_IDS_PER_REQUEST = 100;
|
|
24
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Get the current Unix timestamp as a string
|
|
16
|
+
*/
|
|
17
|
+
function getCurrentTimestamp() {
|
|
18
|
+
return Math.floor(Date.now() / 1000).toString();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get price for a single token
|
|
22
|
+
* @param id - Token ID (coin type)
|
|
23
|
+
* @returns Token price, or 0 if not found or on error
|
|
24
|
+
*/
|
|
25
|
+
export async function getTokenPrice(id) {
|
|
26
|
+
try {
|
|
27
|
+
const normalizedId = normalizeTokenType(id);
|
|
28
|
+
const prices = await getTokenPrices([normalizedId]);
|
|
29
|
+
return prices[normalizedId] || 0;
|
|
30
|
+
}
|
|
31
|
+
catch (_) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get prices for multiple tokens
|
|
37
|
+
* @param ids - Array of token IDs (coin types)
|
|
38
|
+
* @returns Record mapping token IDs to their prices
|
|
39
|
+
*/
|
|
40
|
+
export async function getTokenPrices(ids) {
|
|
25
41
|
try {
|
|
42
|
+
if (ids.length === 0) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
26
45
|
const limitedIds = ids.slice(0, MAX_TOTAL_IDS).map(normalizeTokenType);
|
|
27
46
|
const idChunks = chunkArray(limitedIds, MAX_IDS_PER_REQUEST);
|
|
47
|
+
const timestamp = getCurrentTimestamp();
|
|
28
48
|
const responses = await Promise.all(idChunks.map(async (chunk) => {
|
|
29
|
-
const
|
|
49
|
+
const requestBody = {
|
|
50
|
+
timestamp,
|
|
51
|
+
token_ids: chunk,
|
|
52
|
+
};
|
|
53
|
+
const response = await fetchClient(`${API_ENDPOINTS.PRICES}/prices/batch`, {
|
|
30
54
|
method: "POST",
|
|
31
55
|
headers: {
|
|
32
56
|
"Content-Type": "application/json",
|
|
33
57
|
},
|
|
34
|
-
body: JSON.stringify(
|
|
35
|
-
ids: chunk,
|
|
36
|
-
vsCoin,
|
|
37
|
-
}),
|
|
58
|
+
body: JSON.stringify(requestBody),
|
|
38
59
|
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
throw new Error(`Price API returned status ${response.status}`);
|
|
62
|
+
}
|
|
39
63
|
const pricesRes = (await response.json());
|
|
40
64
|
return pricesRes;
|
|
41
65
|
}));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
// Combine all responses into a single record
|
|
67
|
+
const combinedPrices = responses.reduce((acc, priceResponses) => {
|
|
68
|
+
priceResponses.forEach((priceResponse) => {
|
|
69
|
+
acc[priceResponse.token_id] = priceResponse.price;
|
|
45
70
|
});
|
|
46
71
|
return acc;
|
|
47
72
|
}, {});
|
|
73
|
+
// Ensure all requested IDs are in the result (set to 0 if not found)
|
|
48
74
|
const finalPrices = limitedIds.reduce((acc, id) => {
|
|
49
75
|
acc[id] = combinedPrices[id] || 0;
|
|
50
76
|
return acc;
|
|
@@ -52,12 +78,17 @@ export async function getTokenPrices(ids, vsCoin = NATIVE_USDC_TOKEN_TYPE) {
|
|
|
52
78
|
return finalPrices;
|
|
53
79
|
}
|
|
54
80
|
catch (_) {
|
|
81
|
+
// On error, return 0 for all requested IDs
|
|
55
82
|
return ids.slice(0, MAX_TOTAL_IDS).reduce((acc, id) => {
|
|
56
|
-
acc[id] = 0;
|
|
83
|
+
acc[normalizeTokenType(id)] = 0;
|
|
57
84
|
return acc;
|
|
58
85
|
}, {});
|
|
59
86
|
}
|
|
60
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the current SUI token price
|
|
90
|
+
* @returns SUI price, or 0 if not found or on error
|
|
91
|
+
*/
|
|
61
92
|
export async function getSuiPrice() {
|
|
62
93
|
return await getTokenPrice(SUI_FULL_TYPE);
|
|
63
94
|
}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,47 +1,19 @@
|
|
|
1
|
-
export * from "./types/aggregator";
|
|
2
1
|
export * from "./types/metaAg";
|
|
3
|
-
import { Config } from "./config";
|
|
4
2
|
import { MetaAg } from "./features/metaAg";
|
|
5
3
|
import { getSuiPrice, getTokenPrice, getTokenPrices } from "./features/prices";
|
|
6
|
-
import { executeBluefinTx } from "./libs/protocols/bluefinx/client";
|
|
7
|
-
import { buildTx, buildTxV2, DEFAULT_SOURCES, estimateGasFee, executeTx, getQuote, getSwapHistory, multiSwap, } from "./features/swap";
|
|
8
4
|
import { cancelDcaOrder, cancelLimitOrder, claimExpiredLimitOrder, getClosedDcaOrders, getClosedLimitOrders, getDcaOrderExecutions, getOpenDcaOrders, getOpenLimitOrders, placeDcaOrder, placeLimitOrder, } from "./features/limitDca";
|
|
9
|
-
|
|
10
|
-
const getSuiClient = Config.getSuiClient;
|
|
11
|
-
const setSuiClient = Config.setSuiClient;
|
|
12
|
-
export { buildTx, buildTxV2, cancelDcaOrder, cancelLimitOrder, claimExpiredLimitOrder,
|
|
13
|
-
// config
|
|
14
|
-
Config, DEFAULT_SOURCES, estimateGasFee, executeBluefinTx, executeTx, getClosedDcaOrders, getClosedLimitOrders, getDcaOrderExecutions, getOpenDcaOrders, getOpenLimitOrders,
|
|
15
|
-
// swap
|
|
16
|
-
getQuote,
|
|
17
|
-
// sui client
|
|
18
|
-
getSuiClient, getSuiPrice, getSwapHistory,
|
|
5
|
+
export { MetaAg, cancelDcaOrder, cancelLimitOrder, claimExpiredLimitOrder, getClosedDcaOrders, getClosedLimitOrders, getDcaOrderExecutions, getOpenDcaOrders, getOpenLimitOrders,
|
|
19
6
|
// prices
|
|
20
|
-
getTokenPrice, getTokenPrices,
|
|
7
|
+
getSuiPrice, getTokenPrice, getTokenPrices,
|
|
21
8
|
// dca
|
|
22
9
|
placeDcaOrder,
|
|
23
10
|
// limit order
|
|
24
|
-
placeLimitOrder,
|
|
11
|
+
placeLimitOrder, };
|
|
25
12
|
export default {
|
|
26
|
-
// config
|
|
27
|
-
Config,
|
|
28
|
-
// sui client
|
|
29
|
-
getSuiClient,
|
|
30
|
-
setSuiClient,
|
|
31
13
|
// prices
|
|
32
14
|
getTokenPrice,
|
|
33
15
|
getTokenPrices,
|
|
34
16
|
getSuiPrice,
|
|
35
|
-
// swap
|
|
36
|
-
getQuote,
|
|
37
|
-
estimateGasFee,
|
|
38
|
-
buildTx,
|
|
39
|
-
buildTxV2,
|
|
40
|
-
multiSwap,
|
|
41
|
-
getSwapHistory,
|
|
42
|
-
executeTx,
|
|
43
|
-
executeBluefinTx,
|
|
44
|
-
DEFAULT_SOURCES,
|
|
45
17
|
// limit order
|
|
46
18
|
placeLimitOrder,
|
|
47
19
|
getOpenLimitOrders,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchClient.d.ts","sourceRoot":"","sources":["../../../../src/config/fetchClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchClient.d.ts","sourceRoot":"","sources":["../../../../src/config/fetchClient.ts"],"names":[],"mappings":"AAAA,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,QAAQ,CAAC,CAUnB"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export declare const _7K_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
|
|
2
|
-
export declare const _7K_CONFIG = "0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54";
|
|
3
|
-
export declare const _7K_VAULT = "0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6";
|
|
4
1
|
export declare const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
5
2
|
export declare const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
6
3
|
export declare const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC"}
|
|
@@ -9,7 +9,7 @@ export declare const simulateAggregator: (provider: AggregatorProvider, quote: M
|
|
|
9
9
|
simulatedAmountOut: string;
|
|
10
10
|
gasUsed: import("@mysten/sui/client").GasCostSummary;
|
|
11
11
|
id: string;
|
|
12
|
-
provider: import("../../types/metaAg").EProvider.
|
|
12
|
+
provider: import("../../types/metaAg").EProvider.BLUEFIN7K | import("../../types/metaAg").EProvider.CETUS | import("../../types/metaAg").EProvider.FLOWX;
|
|
13
13
|
}>;
|
|
14
14
|
/**
|
|
15
15
|
* this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
|
|
@@ -10,10 +10,7 @@ export declare enum MetaAgErrorCode {
|
|
|
10
10
|
INVALID_SIGNER_ADDRESS = 1006,
|
|
11
11
|
PROVIDER_NOT_SUPPORT_SWAP = 1007,
|
|
12
12
|
SIMULATION_FAILED = 1008,
|
|
13
|
-
OKX_FINALIZE_COMMAND_NOT_FOUND = 1100
|
|
14
|
-
BLUEFINX_TRANSACTION_NOT_FOUND = 1200,
|
|
15
|
-
BLUEFINX_TRANSACTION_NOT_APPROVED = 1201,
|
|
16
|
-
BLUEFINX_TRANSACTION_DIGEST_NOT_FOUND = 1202
|
|
13
|
+
OKX_FINALIZE_COMMAND_NOT_FOUND = 1100
|
|
17
14
|
}
|
|
18
15
|
export type MetaAgErrorDetailsMap = {
|
|
19
16
|
[MetaAgErrorCode.UNKNOWN]: any;
|
|
@@ -46,9 +43,6 @@ export type MetaAgErrorDetailsMap = {
|
|
|
46
43
|
[MetaAgErrorCode.OKX_FINALIZE_COMMAND_NOT_FOUND]: {
|
|
47
44
|
packageId: string;
|
|
48
45
|
};
|
|
49
|
-
[MetaAgErrorCode.BLUEFINX_TRANSACTION_NOT_FOUND]: Record<string, never>;
|
|
50
|
-
[MetaAgErrorCode.BLUEFINX_TRANSACTION_NOT_APPROVED]: Record<string, never>;
|
|
51
|
-
[MetaAgErrorCode.BLUEFINX_TRANSACTION_DIGEST_NOT_FOUND]: Record<string, never>;
|
|
52
46
|
};
|
|
53
47
|
export type MetaAgErrorDetails<T extends MetaAgErrorCode> = T extends keyof MetaAgErrorDetailsMap ? MetaAgErrorDetailsMap[T] : never;
|
|
54
48
|
export declare class MetaAgError<T extends MetaAgErrorCode> extends Error {
|