@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,223 +0,0 @@
|
|
|
1
|
-
import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
|
|
2
|
-
import { isValidSuiAddress, normalizeStructTag } from "@mysten/sui/utils";
|
|
3
|
-
import { groupSwapRoutes } from "../../libs/groupSwapRoutes";
|
|
4
|
-
import { swapWithRoute } from "../../libs/swapWithRoute";
|
|
5
|
-
import { isBluefinXRouting, } from "../../types/aggregator";
|
|
6
|
-
import { SuiUtils } from "../../utils/sui";
|
|
7
|
-
import { buildBluefinXTx, settle, updatePythPriceFeedsIfAny, validateRoutes, } from "./buildTx";
|
|
8
|
-
import { getConfig } from "./config";
|
|
9
|
-
/**
|
|
10
|
-
* Wave-based transaction builder that optimizes swap execution by:
|
|
11
|
-
* 1. Grouping swaps into execution waves based on readiness
|
|
12
|
-
* 2. Merging redundant swaps to the same pool within each wave
|
|
13
|
-
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
14
|
-
*/
|
|
15
|
-
export const buildTxV2 = async (params) => {
|
|
16
|
-
return buildTxV2Int(params);
|
|
17
|
-
};
|
|
18
|
-
export const buildTxV2Int = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }, beforeBuildBluefinXTx) => {
|
|
19
|
-
const isBluefinX = isBluefinXRouting(quoteResponse);
|
|
20
|
-
const _commission = {
|
|
21
|
-
...__commission,
|
|
22
|
-
commissionBps: isBluefinX ? 0 : __commission.commissionBps,
|
|
23
|
-
};
|
|
24
|
-
const { tx: _tx, coinIn: _coinIn } = extendTx || {};
|
|
25
|
-
let coinOut;
|
|
26
|
-
if (isBluefinX && devInspect) {
|
|
27
|
-
throw new Error("BluefinX tx is sponsored, skip devInspect");
|
|
28
|
-
}
|
|
29
|
-
if (!accountAddress) {
|
|
30
|
-
throw new Error("Sender address is required");
|
|
31
|
-
}
|
|
32
|
-
if (!quoteResponse.routes) {
|
|
33
|
-
throw new Error("Invalid quote response: 'routes' are required");
|
|
34
|
-
}
|
|
35
|
-
if (!isValidSuiAddress(_commission.partner)) {
|
|
36
|
-
throw new Error("Invalid commission partner address");
|
|
37
|
-
}
|
|
38
|
-
const tx = _tx || new Transaction();
|
|
39
|
-
const routes = groupSwapRoutes(quoteResponse);
|
|
40
|
-
validateRoutes(routes, isSponsored);
|
|
41
|
-
const splits = routes.map((group) => group[0]?.amount ?? "0");
|
|
42
|
-
const coinIn = _coinIn ||
|
|
43
|
-
tx.add(coinWithBalance({
|
|
44
|
-
type: quoteResponse.tokenIn,
|
|
45
|
-
balance: BigInt(quoteResponse.swapAmountWithDecimal),
|
|
46
|
-
useGasCoin: !isSponsored && !isBluefinX,
|
|
47
|
-
}));
|
|
48
|
-
const coinData = tx.splitCoins(coinIn, splits);
|
|
49
|
-
SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
|
|
50
|
-
const pythMap = await updatePythPriceFeedsIfAny(tx, [quoteResponse]);
|
|
51
|
-
const config = await getConfig();
|
|
52
|
-
const finalCoins = await optimize(pythMap, config, routes, coinData, tx, accountAddress);
|
|
53
|
-
// Merge all final coins
|
|
54
|
-
if (finalCoins.length > 0) {
|
|
55
|
-
const mergeCoin = tx.add(settle(finalCoins, quoteResponse, Math.floor(+slippage * 10000), _commission));
|
|
56
|
-
if (!extendTx) {
|
|
57
|
-
tx.transferObjects([mergeCoin], tx.pure.address(accountAddress));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
coinOut = mergeCoin;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (isBluefinX) {
|
|
64
|
-
beforeBuildBluefinXTx?.(tx, coinOut);
|
|
65
|
-
return {
|
|
66
|
-
tx: await buildBluefinXTx(tx, accountAddress, quoteResponse),
|
|
67
|
-
coinOut,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
tx.setSenderIfNotSet(accountAddress);
|
|
71
|
-
return { tx, coinOut };
|
|
72
|
-
};
|
|
73
|
-
const optimize = async (pythMap, config, routes, coinData, tx, accountAddress) => {
|
|
74
|
-
// Initialize route states with split coins
|
|
75
|
-
const routeStates = routes.map((route, index) => ({
|
|
76
|
-
routeIndex: index,
|
|
77
|
-
currentHopIndex: 0,
|
|
78
|
-
currentCoin: coinData[index],
|
|
79
|
-
swaps: route,
|
|
80
|
-
completed: false,
|
|
81
|
-
}));
|
|
82
|
-
const finalCoins = [];
|
|
83
|
-
const coinTypeOut = routes[0][routes[0].length - 1].assetOut;
|
|
84
|
-
// Execute swaps in waves
|
|
85
|
-
while (true) {
|
|
86
|
-
const readyHops = [];
|
|
87
|
-
routeStates.forEach((state) => {
|
|
88
|
-
if (state.completed)
|
|
89
|
-
return;
|
|
90
|
-
if (state.currentHopIndex >= state.swaps.length) {
|
|
91
|
-
state.completed = true;
|
|
92
|
-
finalCoins.push(state.currentCoin);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const swap = state.swaps[state.currentHopIndex];
|
|
96
|
-
readyHops.push({
|
|
97
|
-
routeIndex: state.routeIndex,
|
|
98
|
-
hopIndex: state.currentHopIndex,
|
|
99
|
-
swap,
|
|
100
|
-
inputCoin: state.currentCoin,
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
if (readyHops.length === 0)
|
|
104
|
-
break;
|
|
105
|
-
// Group hops by pool for merging opportunities
|
|
106
|
-
const poolGroups = new Map();
|
|
107
|
-
readyHops.forEach((hop) => {
|
|
108
|
-
const poolKey = `${hop.swap.poolId}|${hop.swap.assetIn}|${hop.swap.assetOut}`;
|
|
109
|
-
if (!poolGroups.has(poolKey)) {
|
|
110
|
-
poolGroups.set(poolKey, {
|
|
111
|
-
swap: hop.swap,
|
|
112
|
-
hops: [],
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
poolGroups.get(poolKey).hops.push(hop);
|
|
116
|
-
});
|
|
117
|
-
// Execute each pool group in this wave
|
|
118
|
-
const wavePromises = [];
|
|
119
|
-
for (const group of poolGroups.values()) {
|
|
120
|
-
const { swap, hops } = group;
|
|
121
|
-
// For merged swaps, we need to combine input coins first
|
|
122
|
-
const wavePromise = (async () => {
|
|
123
|
-
let combinedCoin;
|
|
124
|
-
if (hops.length > 1) {
|
|
125
|
-
// Merge all input coins for this pool
|
|
126
|
-
const inputCoins = hops.map((h) => h.inputCoin);
|
|
127
|
-
tx.mergeCoins(inputCoins[0], inputCoins.slice(1));
|
|
128
|
-
combinedCoin = inputCoins[0];
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
combinedCoin = hops[0].inputCoin;
|
|
132
|
-
}
|
|
133
|
-
// Execute the swap with the combined coin
|
|
134
|
-
const resultCoin = await swapWithRoute({
|
|
135
|
-
route: [swap],
|
|
136
|
-
inputCoinObject: combinedCoin,
|
|
137
|
-
currentAccount: accountAddress,
|
|
138
|
-
tx,
|
|
139
|
-
config,
|
|
140
|
-
pythMap,
|
|
141
|
-
});
|
|
142
|
-
if (!resultCoin) {
|
|
143
|
-
throw new Error(`Swap failed for pool ${swap.poolId}`);
|
|
144
|
-
}
|
|
145
|
-
if (hops[0].swap.assetOut === coinTypeOut) {
|
|
146
|
-
finalCoins.push(resultCoin);
|
|
147
|
-
hops.forEach((hop) => {
|
|
148
|
-
const state = routeStates[hop.routeIndex];
|
|
149
|
-
state.completed = true;
|
|
150
|
-
state.currentHopIndex++;
|
|
151
|
-
});
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
// For merged swaps, we need to split the output proportionally
|
|
155
|
-
if (hops.length > 1) {
|
|
156
|
-
// Split output proportionally (except the last one which gets the remainder)
|
|
157
|
-
const splitAmounts = hops
|
|
158
|
-
.slice(1)
|
|
159
|
-
.map((hop) => hop.swap.returnAmount);
|
|
160
|
-
const splitCoins = splitAmounts.length > 0
|
|
161
|
-
? [resultCoin, ...tx.splitCoins(resultCoin, splitAmounts)]
|
|
162
|
-
: [resultCoin];
|
|
163
|
-
// Assign split coins back to routes
|
|
164
|
-
hops.forEach((hop, index) => {
|
|
165
|
-
const state = routeStates[hop.routeIndex];
|
|
166
|
-
state.currentCoin = splitCoins[index];
|
|
167
|
-
state.currentHopIndex++;
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
// Single swap - simply update the route state
|
|
172
|
-
const state = routeStates[hops[0].routeIndex];
|
|
173
|
-
state.currentCoin = resultCoin;
|
|
174
|
-
state.currentHopIndex++;
|
|
175
|
-
}
|
|
176
|
-
})();
|
|
177
|
-
wavePromises.push(wavePromise);
|
|
178
|
-
}
|
|
179
|
-
// Wait for all swaps in this wave to complete
|
|
180
|
-
await Promise.all(wavePromises);
|
|
181
|
-
}
|
|
182
|
-
return finalCoins;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* execute multiple swap in single transaction
|
|
186
|
-
*
|
|
187
|
-
* User must handle the coins from return
|
|
188
|
-
* @param param - MultiSwapParams
|
|
189
|
-
* @returns a map of coinType to coinObject
|
|
190
|
-
*/
|
|
191
|
-
export const multiSwap = async ({ sender, slippageBps, swaps, tx, commission, }) => {
|
|
192
|
-
if (swaps.some((s) => isBluefinXRouting(s.quote))) {
|
|
193
|
-
throw Error("BluefinX routing not supported yet");
|
|
194
|
-
}
|
|
195
|
-
// update oracles price if any
|
|
196
|
-
const pythMap = await updatePythPriceFeedsIfAny(tx, swaps.map((s) => s.quote));
|
|
197
|
-
const map = {};
|
|
198
|
-
const config = await getConfig();
|
|
199
|
-
for (const { quote: sorResponse, coinIn } of swaps) {
|
|
200
|
-
const routes = groupSwapRoutes(sorResponse);
|
|
201
|
-
const splits = routes.map((group) => group[0]?.amount ?? "0");
|
|
202
|
-
const coinData = splits.length === 1
|
|
203
|
-
? [coinIn]
|
|
204
|
-
: [coinIn, ...tx.splitCoins(coinIn, splits.slice(1))];
|
|
205
|
-
const coinObjects = await optimize(pythMap, config, routes, coinData, tx, sender);
|
|
206
|
-
if (coinObjects.length > 0) {
|
|
207
|
-
const mergeCoin = tx.add(settle(coinObjects, sorResponse, slippageBps, commission));
|
|
208
|
-
if (!map[normalizeStructTag(sorResponse.tokenOut)]) {
|
|
209
|
-
map[normalizeStructTag(sorResponse.tokenOut)] = [];
|
|
210
|
-
}
|
|
211
|
-
map[normalizeStructTag(sorResponse.tokenOut)].push(mergeCoin);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const result = {};
|
|
215
|
-
for (const [tokenOut, coins] of Object.entries(map)) {
|
|
216
|
-
if (coins.length > 1) {
|
|
217
|
-
tx.mergeCoins(coins[0], coins.slice(1));
|
|
218
|
-
}
|
|
219
|
-
result[tokenOut] = coins[0];
|
|
220
|
-
}
|
|
221
|
-
tx.setSenderIfNotSet(sender);
|
|
222
|
-
return result;
|
|
223
|
-
};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { Config as _Config } from "../../config";
|
|
2
|
-
import { fetchClient } from "../../config/fetchClient";
|
|
3
|
-
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
4
|
-
export const DEFAULT_CONFIG = {
|
|
5
|
-
aftermath: {
|
|
6
|
-
name: "Aftermath",
|
|
7
|
-
package: "0xc4049b2d1cc0f6e017fda8260e4377cecd236bd7f56a54fee120816e72e2e0dd",
|
|
8
|
-
poolRegistry: "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae",
|
|
9
|
-
protocolFeeVault: "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4",
|
|
10
|
-
treasury: "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce",
|
|
11
|
-
insuranceFund: "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b",
|
|
12
|
-
referralVault: "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278",
|
|
13
|
-
},
|
|
14
|
-
bluefin: {
|
|
15
|
-
name: "Bluefin",
|
|
16
|
-
package: "0x67b34b728c4e28e704dcfecf7c5cf55c7fc593b6c65c20d1836d97c209c1928a",
|
|
17
|
-
globalConfig: "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352",
|
|
18
|
-
},
|
|
19
|
-
bluemove: {
|
|
20
|
-
name: "Bluemove",
|
|
21
|
-
package: "0x08cd33481587d4c4612865b164796d937df13747d8c763b8a178c87e3244498f",
|
|
22
|
-
dexInfo: "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92",
|
|
23
|
-
},
|
|
24
|
-
cetus: {
|
|
25
|
-
name: "Cetus",
|
|
26
|
-
package: "0xfbb32ac0fa89a3cb0c56c745b688c6d2a53ac8e43447119ad822763997ffb9c3",
|
|
27
|
-
globalConfig: "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",
|
|
28
|
-
},
|
|
29
|
-
deepbook_v3: {
|
|
30
|
-
name: "Deepbook V3",
|
|
31
|
-
package: "",
|
|
32
|
-
sponsor: "0x951a01360d85b06722edf896852bf8005b81cdb26375235c935138987f629502",
|
|
33
|
-
sponsorFund: "0xf245e7a4b83ed9a26622f5818a158c2ba7a03b91e62717b557a7df1d4dab38df",
|
|
34
|
-
},
|
|
35
|
-
flowx: {
|
|
36
|
-
name: "Flowx Finance",
|
|
37
|
-
package: "0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0",
|
|
38
|
-
container: "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511",
|
|
39
|
-
},
|
|
40
|
-
flowx_v3: {
|
|
41
|
-
name: "Flowx Finance V3",
|
|
42
|
-
package: "0xe882cd54551e73e64ff5b257146a0c5264546974cf00d78ecc871017cb22df67",
|
|
43
|
-
registry: "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc",
|
|
44
|
-
version: "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656",
|
|
45
|
-
},
|
|
46
|
-
kriya: {
|
|
47
|
-
name: "Kriya",
|
|
48
|
-
package: "0xa0eba10b173538c8fecca1dff298e488402cc9ff374f8a12ca7758eebe830b66",
|
|
49
|
-
},
|
|
50
|
-
kriya_v3: {
|
|
51
|
-
name: "Kriya V3",
|
|
52
|
-
package: "0x0d7305a7475ed54adc905365bd081939a81926636b4c438cf2f75f4924b8d960",
|
|
53
|
-
version: "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78",
|
|
54
|
-
},
|
|
55
|
-
obric: {
|
|
56
|
-
name: "Obric",
|
|
57
|
-
package: "0xb84e63d22ea4822a0a333c250e790f69bf5c2ef0c63f4e120e05a6415991368f",
|
|
58
|
-
pythState: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
59
|
-
},
|
|
60
|
-
springsui: {
|
|
61
|
-
name: "SpringSui",
|
|
62
|
-
package: "0x82e6f4f75441eae97d2d5850f41a09d28c7b64a05b067d37748d471f43aaf3f7",
|
|
63
|
-
},
|
|
64
|
-
stsui: {
|
|
65
|
-
name: "AlphaFi stSUI",
|
|
66
|
-
package: "0x059f94b85c07eb74d2847f8255d8cc0a67c9a8dcc039eabf9f8b9e23a0de2700",
|
|
67
|
-
},
|
|
68
|
-
suiswap: {
|
|
69
|
-
name: "SuiSwap",
|
|
70
|
-
package: "0xd075d51486df71e750872b4edf82ea3409fda397ceecc0b6aedf573d923c54a0",
|
|
71
|
-
},
|
|
72
|
-
turbos: {
|
|
73
|
-
name: "Turbos Finance",
|
|
74
|
-
package: "0xd02012c71c1a6a221e540c36c37c81e0224907fe1ee05bfe250025654ff17103",
|
|
75
|
-
version: "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f",
|
|
76
|
-
},
|
|
77
|
-
steamm: {
|
|
78
|
-
name: "Steamm",
|
|
79
|
-
package: "0x5ef2a1bca239764c8381ba26b758833060eadb8903682e4fb15e58c6406e2488",
|
|
80
|
-
script: "0x0755429cba577decc090009348987a89f4fb8397da27a3eaafc366794078af7d",
|
|
81
|
-
oracle: "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b",
|
|
82
|
-
},
|
|
83
|
-
magma: {
|
|
84
|
-
name: "Magma",
|
|
85
|
-
package: "0x49e9f06c58a36830fe0d83291f002012e72b00a4ec9b3a6304c40fc5712bb6e3",
|
|
86
|
-
globalConfig: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
87
|
-
},
|
|
88
|
-
haedal_pmm: {
|
|
89
|
-
name: "Haedal PMM",
|
|
90
|
-
package: "0x486622af8a7250a192e6ee97eed4f54e30343b764d9148bf1535b55f85155204",
|
|
91
|
-
},
|
|
92
|
-
momentum: {
|
|
93
|
-
name: "Momentum",
|
|
94
|
-
package: "0xcf60a40f45d46fc1e828871a647c1e25a0915dec860d2662eb10fdb382c3c1d1",
|
|
95
|
-
version: "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a",
|
|
96
|
-
},
|
|
97
|
-
bluefinx: {
|
|
98
|
-
name: "BluefinX",
|
|
99
|
-
package: "0x9633d611ea4b3a30751135cede2c7871980955473c1c7c883d43567e7e9b164e",
|
|
100
|
-
globalConfig: "0xc6b29a60c3924776bedc78df72c127ea52b86aeb655432979a38f13d742dedaa",
|
|
101
|
-
},
|
|
102
|
-
sevenk_v1: {
|
|
103
|
-
name: "7K DEX",
|
|
104
|
-
package: "0x4142285db093ba0cf0623b3cbc07372fb4f5ed00af1fb62be6d55f49a42c0b0e",
|
|
105
|
-
oracle: "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0",
|
|
106
|
-
},
|
|
107
|
-
fullsail: {
|
|
108
|
-
name: "Fullsail",
|
|
109
|
-
package: "0xb3b98d4fda36acc2c2e66dba61f9149b341c38e97a532af802ebbb0c037b9d1f",
|
|
110
|
-
globalConfig: "0xe93baa80cb570b3a494cbf0621b2ba96bc993926d34dc92508c9446f9a05d615",
|
|
111
|
-
rewarderGlobalVault: "0xfb971d3a2fb98bde74e1c30ba15a3d8bef60a02789e59ae0b91660aeed3e64e1",
|
|
112
|
-
priceProvider: "0x854b2d2c0381bb656ec962f8b443eb082654384cf97885359d1956c7d76e33c9",
|
|
113
|
-
stats: "0x6822a33d1d971e040c32f7cc74507010d1fe786f7d06ab89135083ddb07d2dc2",
|
|
114
|
-
},
|
|
115
|
-
cetus_dlmm: {
|
|
116
|
-
name: "Cetus DLMM",
|
|
117
|
-
package: "0xa4c6f46bd6b456e6477bcddf0652e0d2d8fb4767e306533e6e885302ee28cfab",
|
|
118
|
-
globalConfig: "0xf31b605d117f959b9730e8c07b08b856cb05143c5e81d5751c90d2979e82f599",
|
|
119
|
-
version: "0x05370b2d656612dd5759cbe80463de301e3b94a921dfc72dd9daa2ecdeb2d0a8",
|
|
120
|
-
},
|
|
121
|
-
ferra_dlmm: {
|
|
122
|
-
name: "Ferra DLMM",
|
|
123
|
-
package: "0x5a5c1d10e4782dbbdec3eb8327ede04bd078b294b97cfdba447b11b846b383ac",
|
|
124
|
-
globalConfig: "0x5c9dacf5a678ea15b8569d65960330307e23d429289ca380e665b1aa175ebeca",
|
|
125
|
-
},
|
|
126
|
-
ferra_clmm: {
|
|
127
|
-
name: "Ferra CLMM",
|
|
128
|
-
package: "0xc895342d87127c9c67b76c8ad7f9a22b8bfe1dcdc2c5af82bd85266783115e31",
|
|
129
|
-
integrate: "0x1dd5538aeb1066315969d87ae9a920ce2692824385342f49854b764ac730a64b",
|
|
130
|
-
globalConfig: "0x2cd8382c19e6994f16df204e9b8cddd04bdc486c251de75ac66ac4e48e3e7081",
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
let config = DEFAULT_CONFIG;
|
|
134
|
-
let configTs = 0;
|
|
135
|
-
export async function getConfig() {
|
|
136
|
-
const ttl = 60;
|
|
137
|
-
if (config && Date.now() - configTs < ttl * 1000) {
|
|
138
|
-
return config;
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
const response = await fetchClient(`${_Config.getApi() || API_ENDPOINTS.MAIN}/config`);
|
|
142
|
-
const quoteResponse = (await response.json());
|
|
143
|
-
config = { ...config, ...quoteResponse };
|
|
144
|
-
configTs = Date.now();
|
|
145
|
-
return config;
|
|
146
|
-
}
|
|
147
|
-
catch (_) {
|
|
148
|
-
return DEFAULT_CONFIG;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { SUI_DECIMALS } from "@mysten/sui/utils";
|
|
2
|
-
import { Config } from "../../config";
|
|
3
|
-
import { isBluefinXRouting } from "../../types/aggregator";
|
|
4
|
-
import { formatBalance } from "../../utils/number";
|
|
5
|
-
import { getSuiPrice } from "../prices";
|
|
6
|
-
import { buildTx } from "./buildTx";
|
|
7
|
-
import { BluefinXTx } from "../../libs/protocols/bluefinx/types";
|
|
8
|
-
export async function estimateGasFee({ quoteResponse, accountAddress, slippage, suiPrice: _suiPrice, extendTx, commission, }) {
|
|
9
|
-
if (!accountAddress)
|
|
10
|
-
return 0;
|
|
11
|
-
// BluefinX is sponsored, no need to estimate gas fee
|
|
12
|
-
if (!accountAddress || isBluefinXRouting(quoteResponse))
|
|
13
|
-
return 0;
|
|
14
|
-
const result = await buildTx({
|
|
15
|
-
extendTx,
|
|
16
|
-
quoteResponse,
|
|
17
|
-
accountAddress,
|
|
18
|
-
slippage,
|
|
19
|
-
commission,
|
|
20
|
-
devInspect: true,
|
|
21
|
-
}).catch((err) => {
|
|
22
|
-
console.log("build tx error: ", err);
|
|
23
|
-
return undefined;
|
|
24
|
-
});
|
|
25
|
-
const { tx } = result || {};
|
|
26
|
-
if (!tx || tx instanceof BluefinXTx)
|
|
27
|
-
return 0;
|
|
28
|
-
const suiPrice = _suiPrice || (await getSuiPrice());
|
|
29
|
-
const suiDecimals = SUI_DECIMALS;
|
|
30
|
-
const { effects: { gasUsed, status }, } = await Config.getSuiClient().devInspectTransactionBlock({
|
|
31
|
-
sender: accountAddress,
|
|
32
|
-
transactionBlock: tx,
|
|
33
|
-
});
|
|
34
|
-
if (status.status !== "success")
|
|
35
|
-
return 0;
|
|
36
|
-
const fee = BigInt(gasUsed.computationCost) +
|
|
37
|
-
BigInt(gasUsed.storageCost) -
|
|
38
|
-
BigInt(gasUsed.storageRebate);
|
|
39
|
-
const feeUsd = Number(suiPrice) * Number(formatBalance(fee, suiDecimals));
|
|
40
|
-
return feeUsd;
|
|
41
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Config } from "../../config";
|
|
2
|
-
import { executeBluefinTx } from "../../libs/protocols/bluefinx/client";
|
|
3
|
-
import { BluefinXTx } from "../../libs/protocols/bluefinx/types";
|
|
4
|
-
/**
|
|
5
|
-
* Execute a transaction after it is signed
|
|
6
|
-
*
|
|
7
|
-
* Automatically handle BluefinX transaction execution if needed
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const { mutateAsync: signTransaction } = useSignTransaction();
|
|
11
|
-
* const quoteResponse = await getQuote(...quoteParams);
|
|
12
|
-
* const { tx } = await buildTx(...buildTxParams);
|
|
13
|
-
* const {signature, bytes} = await signTransaction({
|
|
14
|
-
* transaction: tx instanceof BluefinXTx ? tx.txBytes : tx,
|
|
15
|
-
* });
|
|
16
|
-
* const res = await executeTx(tx, signature, bytes);
|
|
17
|
-
* ```
|
|
18
|
-
* @param tx - AggregatorTx - received from `buildTx`
|
|
19
|
-
* @param signature - User signature after signing the transaction
|
|
20
|
-
* @param signedTxBytes - Signed transaction bytes after signing the transaction
|
|
21
|
-
* @param options - Options for the transaction
|
|
22
|
-
* @returns `SuiTransactionBlockResponse`
|
|
23
|
-
*/
|
|
24
|
-
export const executeTx = async (tx, signature, signedTxBytes, options) => {
|
|
25
|
-
const isBluefinTx = tx instanceof BluefinXTx;
|
|
26
|
-
const client = Config.getSuiClient();
|
|
27
|
-
let res;
|
|
28
|
-
if (isBluefinTx) {
|
|
29
|
-
try {
|
|
30
|
-
const result = await executeBluefinTx(tx, signature);
|
|
31
|
-
res = await client.waitForTransaction({
|
|
32
|
-
digest: result.txDigest,
|
|
33
|
-
options,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
throw Error(`Could not retrieve BluefinX transaction with quoteId: ${tx.quoteId} ${e}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
res = await client.executeTransactionBlock({
|
|
42
|
-
transactionBlock: signedTxBytes,
|
|
43
|
-
signature,
|
|
44
|
-
options,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return res;
|
|
48
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
2
|
-
import { Config } from "../../config";
|
|
3
|
-
import { fetchClient } from "../../config/fetchClient";
|
|
4
|
-
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
5
|
-
import { isBluefinXRouting, } from "../../types/aggregator";
|
|
6
|
-
export const DEFAULT_SOURCES = [
|
|
7
|
-
"suiswap",
|
|
8
|
-
"turbos",
|
|
9
|
-
"cetus",
|
|
10
|
-
"bluemove",
|
|
11
|
-
"kriya",
|
|
12
|
-
"kriya_v3",
|
|
13
|
-
"aftermath",
|
|
14
|
-
"deepbook_v3",
|
|
15
|
-
"flowx",
|
|
16
|
-
"flowx_v3",
|
|
17
|
-
"bluefin",
|
|
18
|
-
"springsui",
|
|
19
|
-
"obric",
|
|
20
|
-
"stsui",
|
|
21
|
-
"steamm",
|
|
22
|
-
"steamm_oracle_quoter",
|
|
23
|
-
"steamm_oracle_quoter_v2",
|
|
24
|
-
"magma",
|
|
25
|
-
"haedal_pmm",
|
|
26
|
-
"momentum",
|
|
27
|
-
"sevenk_v1",
|
|
28
|
-
"fullsail",
|
|
29
|
-
"cetus_dlmm",
|
|
30
|
-
"ferra_dlmm",
|
|
31
|
-
"ferra_clmm",
|
|
32
|
-
];
|
|
33
|
-
export const ORACLE_BASED_SOURCES = new Set([
|
|
34
|
-
"obric",
|
|
35
|
-
"haedal_pmm",
|
|
36
|
-
"sevenk_v1",
|
|
37
|
-
"steamm_oracle_quoter",
|
|
38
|
-
"steamm_oracle_quoter_v2",
|
|
39
|
-
]);
|
|
40
|
-
export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
|
|
41
|
-
let sources = _sources;
|
|
42
|
-
if (isSponsored) {
|
|
43
|
-
sources = _sources.filter((s) => !ORACLE_BASED_SOURCES.has(s));
|
|
44
|
-
}
|
|
45
|
-
const params = new URLSearchParams({
|
|
46
|
-
amount: amountIn,
|
|
47
|
-
from: normalizeStructTag(tokenIn),
|
|
48
|
-
to: normalizeStructTag(tokenOut),
|
|
49
|
-
sources: sources.join(","),
|
|
50
|
-
});
|
|
51
|
-
if (targetPools?.length) {
|
|
52
|
-
params.append("target_pools", targetPools.map((v) => normalizeSuiObjectId(v)).join(","));
|
|
53
|
-
}
|
|
54
|
-
if (excludedPools?.length) {
|
|
55
|
-
params.append("excluded_pools", excludedPools.map((v) => normalizeSuiObjectId(v)).join(","));
|
|
56
|
-
}
|
|
57
|
-
if (taker) {
|
|
58
|
-
params.append("taker", taker);
|
|
59
|
-
}
|
|
60
|
-
if (maxPaths) {
|
|
61
|
-
params.append("max_paths", maxPaths.toString());
|
|
62
|
-
}
|
|
63
|
-
const response = await fetchClient(`${Config.getApi() || API_ENDPOINTS.MAIN}/quote?${params}`);
|
|
64
|
-
if (!response.ok) {
|
|
65
|
-
let responseText;
|
|
66
|
-
try {
|
|
67
|
-
responseText = await response.text();
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
responseText = "Failed to fetch aggregator quote";
|
|
71
|
-
}
|
|
72
|
-
throw new Error(responseText);
|
|
73
|
-
}
|
|
74
|
-
const quoteResponse = (await response.json());
|
|
75
|
-
computeReturnAmountAfterCommission(quoteResponse, commissionBps);
|
|
76
|
-
return quoteResponse;
|
|
77
|
-
}
|
|
78
|
-
const computeReturnAmountAfterCommission = (quoteResponse, commissionBps) => {
|
|
79
|
-
const _commissionBps = isBluefinXRouting(quoteResponse) ? 0 : commissionBps;
|
|
80
|
-
if (quoteResponse.returnAmount && +quoteResponse.returnAmount > 0) {
|
|
81
|
-
quoteResponse.returnAmountAfterCommissionWithDecimal = ((BigInt(quoteResponse.returnAmountWithDecimal || 0) *
|
|
82
|
-
BigInt(10_000 - (_commissionBps ?? 0))) /
|
|
83
|
-
BigInt(10_000)).toString(10);
|
|
84
|
-
const exp = Math.round(+quoteResponse.returnAmountWithDecimal / +quoteResponse.returnAmount);
|
|
85
|
-
quoteResponse.returnAmountAfterCommission = (+quoteResponse.returnAmountAfterCommissionWithDecimal / exp).toString(10);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
quoteResponse.returnAmountAfterCommission = "";
|
|
89
|
-
quoteResponse.returnAmountAfterCommissionWithDecimal = "";
|
|
90
|
-
}
|
|
91
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { fetchClient } from "../../config/fetchClient";
|
|
2
|
-
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
3
|
-
import { formatQueryParams } from "../../libs/url";
|
|
4
|
-
export async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
5
|
-
const queryParams = {
|
|
6
|
-
addr: owner,
|
|
7
|
-
offset,
|
|
8
|
-
limit,
|
|
9
|
-
token_pair: tokenPair,
|
|
10
|
-
};
|
|
11
|
-
const paramsStr = formatQueryParams(queryParams);
|
|
12
|
-
const response = await fetchClient(`${API_ENDPOINTS.STATISTIC}/trading-history?${paramsStr}`);
|
|
13
|
-
if (!response.ok) {
|
|
14
|
-
throw new Error("Failed to fetch open limit orders");
|
|
15
|
-
}
|
|
16
|
-
const orders = (await response.json());
|
|
17
|
-
return orders;
|
|
18
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { denormalizeTokenType } from "../utils/token";
|
|
2
|
-
export function groupSwapRoutes(quoteResponse) {
|
|
3
|
-
if (!quoteResponse.routes || !quoteResponse.swaps) {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
const poolDetails = mapPoolIdsToDetails(quoteResponse.routes);
|
|
7
|
-
const items = getTxSorSwaps(quoteResponse.swaps, poolDetails);
|
|
8
|
-
const groupedItems = [];
|
|
9
|
-
let currentGroup = [];
|
|
10
|
-
for (let i = 0; i < items.length; i++) {
|
|
11
|
-
const item = items[i];
|
|
12
|
-
currentGroup.push(item);
|
|
13
|
-
const nextItem = items[i + 1];
|
|
14
|
-
if (!nextItem || BigInt(nextItem.amount) > 0n) {
|
|
15
|
-
groupedItems.push(currentGroup);
|
|
16
|
-
currentGroup = [];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (currentGroup.length > 0) {
|
|
20
|
-
groupedItems.push(currentGroup);
|
|
21
|
-
}
|
|
22
|
-
return groupedItems;
|
|
23
|
-
}
|
|
24
|
-
function mapPoolIdsToDetails(routes) {
|
|
25
|
-
const poolTypes = {};
|
|
26
|
-
routes.forEach((route) => {
|
|
27
|
-
route.hops.forEach((hop) => {
|
|
28
|
-
poolTypes[hop.poolId] = hop.pool;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
return poolTypes;
|
|
32
|
-
}
|
|
33
|
-
function getTxSorSwaps(swaps, poolDetails) {
|
|
34
|
-
return swaps.map((swap) => {
|
|
35
|
-
const pool = poolDetails[swap.poolId];
|
|
36
|
-
const assetIn = denormalizeTokenType(swap.assetIn);
|
|
37
|
-
const assetOut = denormalizeTokenType(swap.assetOut);
|
|
38
|
-
const coinX = {
|
|
39
|
-
type: denormalizeTokenType(pool?.allTokens?.[0]?.address),
|
|
40
|
-
decimals: pool?.allTokens?.[0]?.decimal,
|
|
41
|
-
};
|
|
42
|
-
const coinY = {
|
|
43
|
-
type: denormalizeTokenType(pool?.allTokens?.[1]?.address),
|
|
44
|
-
decimals: pool?.allTokens?.[0]?.decimal,
|
|
45
|
-
};
|
|
46
|
-
const swapXtoY = assetIn === coinX.type;
|
|
47
|
-
return {
|
|
48
|
-
...swap,
|
|
49
|
-
pool,
|
|
50
|
-
assetIn,
|
|
51
|
-
assetOut,
|
|
52
|
-
coinX,
|
|
53
|
-
coinY,
|
|
54
|
-
swapXtoY,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BaseContract } from "../base";
|
|
2
|
-
import { normalizeTokenType } from "../../../utils/token";
|
|
3
|
-
export class AfterMathContract extends BaseContract {
|
|
4
|
-
async swap(tx) {
|
|
5
|
-
const poolId = this.swapInfo.poolId;
|
|
6
|
-
const returnAmount = this.swapInfo.returnAmount;
|
|
7
|
-
const coinInType = normalizeTokenType(this.swapInfo.assetIn);
|
|
8
|
-
const coinOutType = normalizeTokenType(this.swapInfo.assetOut);
|
|
9
|
-
const inputCoinObject = this.inputCoinObject;
|
|
10
|
-
const [lpCoinType] = this.getTypeParams();
|
|
11
|
-
if (!lpCoinType)
|
|
12
|
-
throw new Error("lpCoinType is not defined");
|
|
13
|
-
const config = this.config.aftermath;
|
|
14
|
-
const [tokenOut] = tx.moveCall({
|
|
15
|
-
target: `${config.package}::swap::swap_exact_in`,
|
|
16
|
-
typeArguments: [lpCoinType, coinInType, coinOutType],
|
|
17
|
-
arguments: [
|
|
18
|
-
tx.object(poolId),
|
|
19
|
-
tx.object(config.poolRegistry),
|
|
20
|
-
tx.object(config.protocolFeeVault),
|
|
21
|
-
tx.object(config.treasury),
|
|
22
|
-
tx.object(config.insuranceFund),
|
|
23
|
-
tx.object(config.referralVault),
|
|
24
|
-
inputCoinObject,
|
|
25
|
-
tx.pure.u64(returnAmount),
|
|
26
|
-
tx.pure.u64("1000000000000000000"), // slippage
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
return tokenOut;
|
|
30
|
-
}
|
|
31
|
-
}
|