@7kprotocol/sdk-ts 3.5.4 → 3.6.1-beta.0
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 +103 -0
- package/lib/cjs/features/metaAg/error.js +31 -0
- package/lib/cjs/features/metaAg/index.js +96 -117
- package/lib/cjs/features/metaAg/providers/bluefin7k.js +57 -0
- package/lib/cjs/features/metaAg/providers/cetus.js +7 -7
- package/lib/cjs/features/metaAg/providers/flowx.js +6 -6
- package/lib/cjs/features/metaAg/providers/okx.js +182 -0
- 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 +24 -0
- package/lib/cjs/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/error.d.ts +54 -0
- package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/index.d.ts +11 -2
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +1 -0
- 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 -30
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/metaAg.js +8 -4
- package/lib/cjs/types/okx.js +6 -0
- package/lib/cjs/types/types/metaAg.d.ts +50 -12
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/cjs/types/types/okx.d.ts +206 -0
- package/lib/cjs/types/types/okx.d.ts.map +1 -0
- package/lib/cjs/types/utils/sui.d.ts +1 -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 +19 -146
- 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 +96 -0
- package/lib/esm/features/metaAg/error.js +29 -0
- package/lib/esm/features/metaAg/index.js +96 -117
- package/lib/esm/features/metaAg/providers/{bluefin.js → bluefin7k.js} +12 -23
- package/lib/esm/features/metaAg/providers/cetus.js +7 -7
- package/lib/esm/features/metaAg/providers/flowx.js +6 -6
- package/lib/esm/features/metaAg/providers/okx.js +147 -0
- 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 +24 -0
- package/lib/esm/types/features/metaAg/common.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/error.d.ts +54 -0
- package/lib/esm/types/features/metaAg/error.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/index.d.ts +11 -2
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +4 -5
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/okx.d.ts +21 -0
- package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +1 -0
- 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 -30
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/metaAg.js +5 -2
- package/lib/esm/types/okx.js +5 -0
- package/lib/esm/types/types/metaAg.d.ts +50 -12
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/types/types/okx.d.ts +206 -0
- package/lib/esm/types/types/okx.d.ts.map +1 -0
- package/lib/esm/types/utils/sui.d.ts +1 -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 +19 -147
- package/lib/esm/utils/swap.js +33 -0
- package/package.json +3 -1
- package/lib/cjs/config/index.js +0 -58
- package/lib/cjs/features/metaAg/providers/bluefin.js +0 -68
- package/lib/cjs/features/swap/buildTx.js +0 -195
- package/lib/cjs/features/swap/buildTxV2.js +0 -225
- package/lib/cjs/features/swap/config.js +0 -153
- 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 -94
- 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 -26
- package/lib/cjs/types/config/index.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +0 -11
- package/lib/cjs/types/features/metaAg/providers/bluefin.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 -29
- 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/condition.d.ts +0 -2
- package/lib/cjs/types/utils/condition.d.ts.map +0 -1
- 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/condition.js +0 -8
- package/lib/cjs/utils/number.js +0 -9
- package/lib/esm/config/index.js +0 -55
- package/lib/esm/features/swap/buildTx.js +0 -185
- package/lib/esm/features/swap/buildTxV2.js +0 -219
- package/lib/esm/features/swap/config.js +0 -149
- 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 -90
- 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 -26
- package/lib/esm/types/config/index.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +0 -11
- package/lib/esm/types/features/metaAg/providers/bluefin.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 -29
- 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/condition.d.ts +0 -2
- package/lib/esm/types/utils/condition.d.ts.map +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/condition.js +0 -5
- package/lib/esm/utils/number.js +0 -6
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BluefinProvider = void 0;
|
|
4
|
-
const pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
const config_1 = require("../../../config");
|
|
7
|
-
const _7k_1 = require("../../../constants/_7k");
|
|
8
|
-
const apiEndpoints_1 = require("../../../constants/apiEndpoints");
|
|
9
|
-
const metaAg_1 = require("../../../types/metaAg");
|
|
10
|
-
const condition_1 = require("../../../utils/condition");
|
|
11
|
-
const buildTxV2_1 = require("../../swap/buildTxV2");
|
|
12
|
-
const getQuote_1 = require("../../swap/getQuote");
|
|
13
|
-
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
14
|
-
const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
|
|
15
|
-
class BluefinProvider {
|
|
16
|
-
constructor(options, metaOptions, client) {
|
|
17
|
-
this.options = options;
|
|
18
|
-
this.metaOptions = metaOptions;
|
|
19
|
-
this.kind = metaAg_1.EProvider.BLUEFIN7K;
|
|
20
|
-
const pythClient = new pyth_sui_js_1.SuiPythClient(client, PYTH_STATE_ID, WORMHOLE_STATE_ID);
|
|
21
|
-
const pythConnection = new pyth_sui_js_1.SuiPriceServiceConnection(this.metaOptions.hermesApi);
|
|
22
|
-
if (options.apiKey)
|
|
23
|
-
config_1.Config.setApiKey(options.apiKey);
|
|
24
|
-
config_1.Config.setSuiClient(client);
|
|
25
|
-
config_1.Config.setPythClient(pythClient);
|
|
26
|
-
config_1.Config.setPythConnection(pythConnection);
|
|
27
|
-
}
|
|
28
|
-
async quote(options) {
|
|
29
|
-
const quote = await (0, getQuote_1.getQuote)({
|
|
30
|
-
amountIn: options.amountIn,
|
|
31
|
-
tokenIn: options.coinInType,
|
|
32
|
-
tokenOut: options.coinOutType,
|
|
33
|
-
api: this.options.api || apiEndpoints_1.API_ENDPOINTS.MAIN,
|
|
34
|
-
sources: this.options.sources,
|
|
35
|
-
maxPaths: this.options.maxPaths,
|
|
36
|
-
excludedPools: this.options.excludedPools,
|
|
37
|
-
targetPools: this.options.targetPools,
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
id: (0, uuid_1.v4)(),
|
|
41
|
-
provider: metaAg_1.EProvider.BLUEFIN7K,
|
|
42
|
-
quote,
|
|
43
|
-
amountIn: quote.swapAmountWithDecimal,
|
|
44
|
-
rawAmountOut: quote.returnAmountWithDecimal,
|
|
45
|
-
amountOut: quote.returnAmountWithDecimal,
|
|
46
|
-
coinTypeIn: options.coinInType,
|
|
47
|
-
coinTypeOut: options.coinOutType,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
async swap({ quote, signer, tx, coinIn }) {
|
|
51
|
-
(0, condition_1.assert)(quote.provider === metaAg_1.EProvider.BLUEFIN7K, "Invalid quote");
|
|
52
|
-
const { coinOut } = await (0, buildTxV2_1.buildTxV2)({
|
|
53
|
-
quoteResponse: quote.quote,
|
|
54
|
-
accountAddress: signer,
|
|
55
|
-
commission: {
|
|
56
|
-
commissionBps: 0,
|
|
57
|
-
partner: _7k_1._7K_PARTNER_ADDRESS,
|
|
58
|
-
},
|
|
59
|
-
slippage: 1,
|
|
60
|
-
extendTx: {
|
|
61
|
-
tx,
|
|
62
|
-
coinIn,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
return coinOut;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.BluefinProvider = BluefinProvider;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildBluefinXTx = exports.settle = exports.getExpectedReturn = exports.validateRoutes = exports.updatePythPriceFeedsIfAny = exports.getPythPriceFeeds = exports.buildTx = void 0;
|
|
4
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const config_1 = require("../../config");
|
|
7
|
-
const _7k_1 = require("../../constants/_7k");
|
|
8
|
-
const groupSwapRoutes_1 = require("../../libs/groupSwapRoutes");
|
|
9
|
-
const client_1 = require("../../libs/protocols/bluefinx/client");
|
|
10
|
-
const types_1 = require("../../libs/protocols/bluefinx/types");
|
|
11
|
-
const swapWithRoute_1 = require("../../libs/swapWithRoute");
|
|
12
|
-
const aggregator_1 = require("../../types/aggregator");
|
|
13
|
-
const sui_1 = require("../../utils/sui");
|
|
14
|
-
const config_2 = require("./config");
|
|
15
|
-
const getQuote_1 = require("./getQuote");
|
|
16
|
-
const buildTx = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }) => {
|
|
17
|
-
const isBluefinX = (0, aggregator_1.isBluefinXRouting)(quoteResponse);
|
|
18
|
-
const _commission = {
|
|
19
|
-
...__commission,
|
|
20
|
-
// commission is ignored for bluefinx
|
|
21
|
-
commissionBps: isBluefinX ? 0 : __commission.commissionBps,
|
|
22
|
-
};
|
|
23
|
-
const { tx: _tx, coinIn: _coinIn } = extendTx || {};
|
|
24
|
-
let coinOut;
|
|
25
|
-
if (isBluefinX && devInspect) {
|
|
26
|
-
throw new Error("BluefinX tx is sponsored, skip devInspect");
|
|
27
|
-
}
|
|
28
|
-
if (!accountAddress) {
|
|
29
|
-
throw new Error("Sender address is required");
|
|
30
|
-
}
|
|
31
|
-
if (!quoteResponse.routes) {
|
|
32
|
-
throw new Error("Invalid quote response: 'routes' are required");
|
|
33
|
-
}
|
|
34
|
-
if (!(0, utils_1.isValidSuiAddress)(_commission.partner)) {
|
|
35
|
-
throw new Error("Invalid commission partner address");
|
|
36
|
-
}
|
|
37
|
-
const tx = _tx || new transactions_1.Transaction();
|
|
38
|
-
const routes = (0, groupSwapRoutes_1.groupSwapRoutes)(quoteResponse);
|
|
39
|
-
(0, exports.validateRoutes)(routes, isSponsored);
|
|
40
|
-
const splits = routes.map((group) => group[0]?.amount ?? "0");
|
|
41
|
-
const coinIn = _coinIn ||
|
|
42
|
-
tx.add((0, transactions_1.coinWithBalance)({
|
|
43
|
-
type: quoteResponse.tokenIn,
|
|
44
|
-
balance: BigInt(quoteResponse.swapAmountWithDecimal),
|
|
45
|
-
useGasCoin: !isSponsored && !isBluefinX,
|
|
46
|
-
}));
|
|
47
|
-
const coinData = tx.splitCoins(coinIn, splits);
|
|
48
|
-
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
|
|
49
|
-
const pythMap = await (0, exports.updatePythPriceFeedsIfAny)(tx, [quoteResponse]);
|
|
50
|
-
const coinObjects = [];
|
|
51
|
-
const config = await (0, config_2.getConfig)();
|
|
52
|
-
await Promise.all(routes.map(async (route, index) => {
|
|
53
|
-
const inputCoinObject = coinData[index];
|
|
54
|
-
const coinRes = await (0, swapWithRoute_1.swapWithRoute)({
|
|
55
|
-
route,
|
|
56
|
-
inputCoinObject,
|
|
57
|
-
currentAccount: accountAddress,
|
|
58
|
-
tx,
|
|
59
|
-
config,
|
|
60
|
-
pythMap,
|
|
61
|
-
});
|
|
62
|
-
if (coinRes) {
|
|
63
|
-
coinObjects.push(coinRes);
|
|
64
|
-
}
|
|
65
|
-
}));
|
|
66
|
-
if (coinObjects.length > 0) {
|
|
67
|
-
const mergedCoin = tx.add((0, exports.settle)(coinObjects, quoteResponse, Math.floor(+slippage * 10000), _commission));
|
|
68
|
-
if (!extendTx) {
|
|
69
|
-
tx.transferObjects([mergedCoin], tx.pure.address(accountAddress));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
coinOut = mergedCoin;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (isBluefinX) {
|
|
76
|
-
return {
|
|
77
|
-
tx: await (0, exports.buildBluefinXTx)(tx, accountAddress, quoteResponse),
|
|
78
|
-
coinOut,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
tx.setSenderIfNotSet(accountAddress);
|
|
82
|
-
return { tx, coinOut };
|
|
83
|
-
};
|
|
84
|
-
exports.buildTx = buildTx;
|
|
85
|
-
const getPythPriceFeeds = (responses) => {
|
|
86
|
-
const ids = new Set();
|
|
87
|
-
for (const res of responses) {
|
|
88
|
-
for (const s of res.swaps) {
|
|
89
|
-
for (const o of s.extra?.oracles || []) {
|
|
90
|
-
const bytes = o.Pyth?.price_identifier?.bytes || o.Pyth?.bytes;
|
|
91
|
-
if (bytes) {
|
|
92
|
-
ids.add("0x" + (0, utils_1.toHex)(Uint8Array.from(bytes)));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return Array.from(ids);
|
|
98
|
-
};
|
|
99
|
-
exports.getPythPriceFeeds = getPythPriceFeeds;
|
|
100
|
-
const updatePythPriceFeedsIfAny = async (tx, quoteResponse) => {
|
|
101
|
-
// update oracles price if any
|
|
102
|
-
const pythMap = {};
|
|
103
|
-
const pythIds = (0, exports.getPythPriceFeeds)(quoteResponse);
|
|
104
|
-
if (pythIds.length > 0) {
|
|
105
|
-
const prices = await config_1.Config.getPythConnection().getPriceFeedsUpdateData(pythIds);
|
|
106
|
-
const ids = await config_1.Config.getPythClient().updatePriceFeeds(tx, prices, pythIds);
|
|
107
|
-
pythIds.map((id, index) => {
|
|
108
|
-
pythMap[id] = ids[index];
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return pythMap;
|
|
112
|
-
};
|
|
113
|
-
exports.updatePythPriceFeedsIfAny = updatePythPriceFeedsIfAny;
|
|
114
|
-
const validateRoutes = (routes, isSponsored) => {
|
|
115
|
-
if (!isSponsored) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const hasOracleBasedSource = routes.some((g) => g.some((s) => getQuote_1.ORACLE_BASED_SOURCES.has(s.pool.type)));
|
|
119
|
-
if (hasOracleBasedSource) {
|
|
120
|
-
throw new Error("Oracle based sources are not supported for sponsored tx");
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
exports.validateRoutes = validateRoutes;
|
|
124
|
-
const getExpectedReturn = (returnAmount, slippageBps, commissionBps, tipBps = 0) => {
|
|
125
|
-
if (slippageBps > 10000) {
|
|
126
|
-
throw new Error("Slippage must be less than 100%");
|
|
127
|
-
}
|
|
128
|
-
if (commissionBps > 10000) {
|
|
129
|
-
throw new Error("Commission must be less than 100%");
|
|
130
|
-
}
|
|
131
|
-
if (tipBps > 10000) {
|
|
132
|
-
throw new Error("Tip must be less than 100%");
|
|
133
|
-
}
|
|
134
|
-
const returnAmountWithDecimal = BigInt(returnAmount);
|
|
135
|
-
const tipAmountWithDecimal = (returnAmountWithDecimal * BigInt(tipBps || 0)) / 10000n;
|
|
136
|
-
const commissionAmountWithDecimal = ((returnAmountWithDecimal - tipAmountWithDecimal) * BigInt(commissionBps)) /
|
|
137
|
-
10000n;
|
|
138
|
-
const expectedReturnWithDecimal = returnAmountWithDecimal -
|
|
139
|
-
tipAmountWithDecimal -
|
|
140
|
-
commissionAmountWithDecimal;
|
|
141
|
-
const minAmountWithDecimal = (expectedReturnWithDecimal * BigInt(1e4 - slippageBps)) / 10000n;
|
|
142
|
-
return {
|
|
143
|
-
tipAmount: tipAmountWithDecimal,
|
|
144
|
-
minAmount: minAmountWithDecimal,
|
|
145
|
-
commissionAmount: commissionAmountWithDecimal,
|
|
146
|
-
expectedAmount: expectedReturnWithDecimal.toString(10),
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
exports.getExpectedReturn = getExpectedReturn;
|
|
150
|
-
const settle = (coinObjects, quoteResponse, slippageBps, _commission) => {
|
|
151
|
-
return (tx) => {
|
|
152
|
-
const mergeCoin = coinObjects.length > 1
|
|
153
|
-
? (tx.mergeCoins(coinObjects[0], coinObjects.slice(1)), coinObjects[0])
|
|
154
|
-
: coinObjects[0];
|
|
155
|
-
const { minAmount, expectedAmount } = (0, exports.getExpectedReturn)(quoteResponse.returnAmountWithDecimal, slippageBps, _commission.commissionBps);
|
|
156
|
-
tx.moveCall({
|
|
157
|
-
target: `${_7k_1._7K_PACKAGE_ID}::settle::settle`,
|
|
158
|
-
typeArguments: [quoteResponse.tokenIn, quoteResponse.tokenOut],
|
|
159
|
-
arguments: [
|
|
160
|
-
tx.object(_7k_1._7K_CONFIG),
|
|
161
|
-
tx.object(_7k_1._7K_VAULT),
|
|
162
|
-
tx.pure.u64(quoteResponse.swapAmountWithDecimal),
|
|
163
|
-
mergeCoin,
|
|
164
|
-
tx.pure.u64(minAmount), // minimum received
|
|
165
|
-
tx.pure.u64(expectedAmount), // expected amount out
|
|
166
|
-
tx.pure.option("address", (0, utils_1.isValidSuiAddress)(_commission.partner) ? _commission.partner : null),
|
|
167
|
-
tx.pure.u64(_commission.commissionBps),
|
|
168
|
-
tx.pure.u64(0),
|
|
169
|
-
],
|
|
170
|
-
});
|
|
171
|
-
return mergeCoin;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
exports.settle = settle;
|
|
175
|
-
const buildBluefinXTx = async (tx, accountAddress, quoteResponse) => {
|
|
176
|
-
const extra = quoteResponse.swaps[0].extra;
|
|
177
|
-
if (extra.quoteExpiresAtUtcMillis < Date.now()) {
|
|
178
|
-
throw new Error("Quote expired");
|
|
179
|
-
}
|
|
180
|
-
tx.setSenderIfNotSet(accountAddress);
|
|
181
|
-
const bytes = await tx.build({
|
|
182
|
-
client: config_1.Config.getSuiClient(),
|
|
183
|
-
onlyTransactionKind: true,
|
|
184
|
-
});
|
|
185
|
-
const res = await (0, client_1.sponsorBluefinX)({
|
|
186
|
-
quoteId: extra.quoteId,
|
|
187
|
-
txBytes: (0, utils_1.toBase64)(bytes),
|
|
188
|
-
sender: accountAddress,
|
|
189
|
-
});
|
|
190
|
-
if (!res.success) {
|
|
191
|
-
throw new Error("Sponsor failed");
|
|
192
|
-
}
|
|
193
|
-
return new types_1.BluefinXTx(res.quoteId, res.data.txBytes);
|
|
194
|
-
};
|
|
195
|
-
exports.buildBluefinXTx = buildBluefinXTx;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.multiSwap = exports.optimize = exports.buildTxV2 = void 0;
|
|
4
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const groupSwapRoutes_1 = require("../../libs/groupSwapRoutes");
|
|
7
|
-
const swapWithRoute_1 = require("../../libs/swapWithRoute");
|
|
8
|
-
const aggregator_1 = require("../../types/aggregator");
|
|
9
|
-
const sui_1 = require("../../utils/sui");
|
|
10
|
-
const buildTx_1 = require("./buildTx");
|
|
11
|
-
const config_1 = require("./config");
|
|
12
|
-
/**
|
|
13
|
-
* Wave-based transaction builder that optimizes swap execution by:
|
|
14
|
-
* 1. Grouping swaps into execution waves based on readiness
|
|
15
|
-
* 2. Merging redundant swaps to the same pool within each wave
|
|
16
|
-
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
17
|
-
*/
|
|
18
|
-
const buildTxV2 = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }) => {
|
|
19
|
-
const isBluefinX = (0, aggregator_1.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 (!(0, utils_1.isValidSuiAddress)(_commission.partner)) {
|
|
36
|
-
throw new Error("Invalid commission partner address");
|
|
37
|
-
}
|
|
38
|
-
const tx = _tx || new transactions_1.Transaction();
|
|
39
|
-
const routes = (0, groupSwapRoutes_1.groupSwapRoutes)(quoteResponse);
|
|
40
|
-
(0, buildTx_1.validateRoutes)(routes, isSponsored);
|
|
41
|
-
const splits = routes.map((group) => group[0]?.amount ?? "0");
|
|
42
|
-
const coinIn = _coinIn ||
|
|
43
|
-
tx.add((0, transactions_1.coinWithBalance)({
|
|
44
|
-
type: quoteResponse.tokenIn,
|
|
45
|
-
balance: BigInt(quoteResponse.swapAmountWithDecimal),
|
|
46
|
-
useGasCoin: !isSponsored && !isBluefinX,
|
|
47
|
-
}));
|
|
48
|
-
const coinData = tx.splitCoins(coinIn, splits);
|
|
49
|
-
sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, quoteResponse.tokenIn, coinIn, accountAddress);
|
|
50
|
-
const pythMap = await (0, buildTx_1.updatePythPriceFeedsIfAny)(tx, [quoteResponse]);
|
|
51
|
-
const config = await (0, config_1.getConfig)();
|
|
52
|
-
const finalCoins = await (0, exports.optimize)(pythMap, config, routes, coinData, tx, accountAddress);
|
|
53
|
-
// Merge all final coins
|
|
54
|
-
if (finalCoins.length > 0) {
|
|
55
|
-
const mergeCoin = tx.add((0, buildTx_1.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
|
-
return {
|
|
65
|
-
tx: await (0, buildTx_1.buildBluefinXTx)(tx, accountAddress, quoteResponse),
|
|
66
|
-
coinOut,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
tx.setSenderIfNotSet(accountAddress);
|
|
70
|
-
return { tx, coinOut };
|
|
71
|
-
};
|
|
72
|
-
exports.buildTxV2 = buildTxV2;
|
|
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 (0, swapWithRoute_1.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
|
-
exports.optimize = optimize;
|
|
185
|
-
/**
|
|
186
|
-
* execute multiple swap in single transaction
|
|
187
|
-
*
|
|
188
|
-
* User must handle the coins from return
|
|
189
|
-
* @param param - MultiSwapParams
|
|
190
|
-
* @returns a map of coinType to coinObject
|
|
191
|
-
*/
|
|
192
|
-
const multiSwap = async ({ sender, slippageBps, swaps, tx, commission, }) => {
|
|
193
|
-
if (swaps.some((s) => (0, aggregator_1.isBluefinXRouting)(s.quote))) {
|
|
194
|
-
throw Error("BluefinX routing not supported yet");
|
|
195
|
-
}
|
|
196
|
-
// update oracles price if any
|
|
197
|
-
const pythMap = await (0, buildTx_1.updatePythPriceFeedsIfAny)(tx, swaps.map((s) => s.quote));
|
|
198
|
-
const map = {};
|
|
199
|
-
const config = await (0, config_1.getConfig)();
|
|
200
|
-
for (const { quote: sorResponse, coinIn } of swaps) {
|
|
201
|
-
const routes = (0, groupSwapRoutes_1.groupSwapRoutes)(sorResponse);
|
|
202
|
-
const splits = routes.map((group) => group[0]?.amount ?? "0");
|
|
203
|
-
const coinData = splits.length === 1
|
|
204
|
-
? [coinIn]
|
|
205
|
-
: [coinIn, ...tx.splitCoins(coinIn, splits.slice(1))];
|
|
206
|
-
const coinObjects = await (0, exports.optimize)(pythMap, config, routes, coinData, tx, sender);
|
|
207
|
-
if (coinObjects.length > 0) {
|
|
208
|
-
const mergeCoin = tx.add((0, buildTx_1.settle)(coinObjects, sorResponse, slippageBps, commission));
|
|
209
|
-
if (!map[(0, utils_1.normalizeStructTag)(sorResponse.tokenOut)]) {
|
|
210
|
-
map[(0, utils_1.normalizeStructTag)(sorResponse.tokenOut)] = [];
|
|
211
|
-
}
|
|
212
|
-
map[(0, utils_1.normalizeStructTag)(sorResponse.tokenOut)].push(mergeCoin);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const result = {};
|
|
216
|
-
for (const [tokenOut, coins] of Object.entries(map)) {
|
|
217
|
-
if (coins.length > 1) {
|
|
218
|
-
tx.mergeCoins(coins[0], coins.slice(1));
|
|
219
|
-
}
|
|
220
|
-
result[tokenOut] = coins[0];
|
|
221
|
-
}
|
|
222
|
-
tx.setSenderIfNotSet(sender);
|
|
223
|
-
return result;
|
|
224
|
-
};
|
|
225
|
-
exports.multiSwap = multiSwap;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_CONFIG = void 0;
|
|
4
|
-
exports.getConfig = getConfig;
|
|
5
|
-
const fetchClient_1 = require("../../config/fetchClient");
|
|
6
|
-
const apiEndpoints_1 = require("../../constants/apiEndpoints");
|
|
7
|
-
exports.DEFAULT_CONFIG = {
|
|
8
|
-
aftermath: {
|
|
9
|
-
name: "Aftermath",
|
|
10
|
-
package: "0xc4049b2d1cc0f6e017fda8260e4377cecd236bd7f56a54fee120816e72e2e0dd",
|
|
11
|
-
poolRegistry: "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae",
|
|
12
|
-
protocolFeeVault: "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4",
|
|
13
|
-
treasury: "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce",
|
|
14
|
-
insuranceFund: "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b",
|
|
15
|
-
referralVault: "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278",
|
|
16
|
-
},
|
|
17
|
-
bluefin: {
|
|
18
|
-
name: "Bluefin",
|
|
19
|
-
package: "0x67b34b728c4e28e704dcfecf7c5cf55c7fc593b6c65c20d1836d97c209c1928a",
|
|
20
|
-
globalConfig: "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352",
|
|
21
|
-
},
|
|
22
|
-
bluemove: {
|
|
23
|
-
name: "Bluemove",
|
|
24
|
-
package: "0x08cd33481587d4c4612865b164796d937df13747d8c763b8a178c87e3244498f",
|
|
25
|
-
dexInfo: "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92",
|
|
26
|
-
},
|
|
27
|
-
cetus: {
|
|
28
|
-
name: "Cetus",
|
|
29
|
-
package: "0xfbb32ac0fa89a3cb0c56c745b688c6d2a53ac8e43447119ad822763997ffb9c3",
|
|
30
|
-
globalConfig: "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",
|
|
31
|
-
},
|
|
32
|
-
deepbook_v3: {
|
|
33
|
-
name: "Deepbook V3",
|
|
34
|
-
package: "",
|
|
35
|
-
sponsor: "0x951a01360d85b06722edf896852bf8005b81cdb26375235c935138987f629502",
|
|
36
|
-
sponsorFund: "0xf245e7a4b83ed9a26622f5818a158c2ba7a03b91e62717b557a7df1d4dab38df",
|
|
37
|
-
},
|
|
38
|
-
flowx: {
|
|
39
|
-
name: "Flowx Finance",
|
|
40
|
-
package: "0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0",
|
|
41
|
-
container: "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511",
|
|
42
|
-
},
|
|
43
|
-
flowx_v3: {
|
|
44
|
-
name: "Flowx Finance V3",
|
|
45
|
-
package: "0xe882cd54551e73e64ff5b257146a0c5264546974cf00d78ecc871017cb22df67",
|
|
46
|
-
registry: "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc",
|
|
47
|
-
version: "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656",
|
|
48
|
-
},
|
|
49
|
-
kriya: {
|
|
50
|
-
name: "Kriya",
|
|
51
|
-
package: "0xa0eba10b173538c8fecca1dff298e488402cc9ff374f8a12ca7758eebe830b66",
|
|
52
|
-
},
|
|
53
|
-
kriya_v3: {
|
|
54
|
-
name: "Kriya V3",
|
|
55
|
-
package: "0x0d7305a7475ed54adc905365bd081939a81926636b4c438cf2f75f4924b8d960",
|
|
56
|
-
version: "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78",
|
|
57
|
-
},
|
|
58
|
-
obric: {
|
|
59
|
-
name: "Obric",
|
|
60
|
-
package: "0xb84e63d22ea4822a0a333c250e790f69bf5c2ef0c63f4e120e05a6415991368f",
|
|
61
|
-
pythState: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
62
|
-
},
|
|
63
|
-
springsui: {
|
|
64
|
-
name: "SpringSui",
|
|
65
|
-
package: "0x82e6f4f75441eae97d2d5850f41a09d28c7b64a05b067d37748d471f43aaf3f7",
|
|
66
|
-
},
|
|
67
|
-
stsui: {
|
|
68
|
-
name: "AlphaFi stSUI",
|
|
69
|
-
package: "0x059f94b85c07eb74d2847f8255d8cc0a67c9a8dcc039eabf9f8b9e23a0de2700",
|
|
70
|
-
},
|
|
71
|
-
suiswap: {
|
|
72
|
-
name: "SuiSwap",
|
|
73
|
-
package: "0xd075d51486df71e750872b4edf82ea3409fda397ceecc0b6aedf573d923c54a0",
|
|
74
|
-
},
|
|
75
|
-
turbos: {
|
|
76
|
-
name: "Turbos Finance",
|
|
77
|
-
package: "0xd02012c71c1a6a221e540c36c37c81e0224907fe1ee05bfe250025654ff17103",
|
|
78
|
-
version: "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f",
|
|
79
|
-
},
|
|
80
|
-
steamm: {
|
|
81
|
-
name: "Steamm",
|
|
82
|
-
package: "0x5ef2a1bca239764c8381ba26b758833060eadb8903682e4fb15e58c6406e2488",
|
|
83
|
-
script: "0x0755429cba577decc090009348987a89f4fb8397da27a3eaafc366794078af7d",
|
|
84
|
-
oracle: "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b",
|
|
85
|
-
},
|
|
86
|
-
magma: {
|
|
87
|
-
name: "Magma",
|
|
88
|
-
package: "0x49e9f06c58a36830fe0d83291f002012e72b00a4ec9b3a6304c40fc5712bb6e3",
|
|
89
|
-
globalConfig: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
90
|
-
},
|
|
91
|
-
haedal_pmm: {
|
|
92
|
-
name: "Haedal PMM",
|
|
93
|
-
package: "0x486622af8a7250a192e6ee97eed4f54e30343b764d9148bf1535b55f85155204",
|
|
94
|
-
},
|
|
95
|
-
momentum: {
|
|
96
|
-
name: "Momentum",
|
|
97
|
-
package: "0xcf60a40f45d46fc1e828871a647c1e25a0915dec860d2662eb10fdb382c3c1d1",
|
|
98
|
-
version: "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a",
|
|
99
|
-
},
|
|
100
|
-
bluefinx: {
|
|
101
|
-
name: "BluefinX",
|
|
102
|
-
package: "0x9633d611ea4b3a30751135cede2c7871980955473c1c7c883d43567e7e9b164e",
|
|
103
|
-
globalConfig: "0xc6b29a60c3924776bedc78df72c127ea52b86aeb655432979a38f13d742dedaa",
|
|
104
|
-
},
|
|
105
|
-
sevenk_v1: {
|
|
106
|
-
name: "7K DEX",
|
|
107
|
-
package: "0x4142285db093ba0cf0623b3cbc07372fb4f5ed00af1fb62be6d55f49a42c0b0e",
|
|
108
|
-
oracle: "0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0",
|
|
109
|
-
},
|
|
110
|
-
fullsail: {
|
|
111
|
-
name: "Fullsail",
|
|
112
|
-
package: "0xb3b98d4fda36acc2c2e66dba61f9149b341c38e97a532af802ebbb0c037b9d1f",
|
|
113
|
-
globalConfig: "0xe93baa80cb570b3a494cbf0621b2ba96bc993926d34dc92508c9446f9a05d615",
|
|
114
|
-
rewarderGlobalVault: "0xfb971d3a2fb98bde74e1c30ba15a3d8bef60a02789e59ae0b91660aeed3e64e1",
|
|
115
|
-
priceProvider: "0x854b2d2c0381bb656ec962f8b443eb082654384cf97885359d1956c7d76e33c9",
|
|
116
|
-
stats: "0x6822a33d1d971e040c32f7cc74507010d1fe786f7d06ab89135083ddb07d2dc2",
|
|
117
|
-
},
|
|
118
|
-
cetus_dlmm: {
|
|
119
|
-
name: "Cetus DLMM",
|
|
120
|
-
package: "0xa4c6f46bd6b456e6477bcddf0652e0d2d8fb4767e306533e6e885302ee28cfab",
|
|
121
|
-
globalConfig: "0xf31b605d117f959b9730e8c07b08b856cb05143c5e81d5751c90d2979e82f599",
|
|
122
|
-
version: "0x05370b2d656612dd5759cbe80463de301e3b94a921dfc72dd9daa2ecdeb2d0a8",
|
|
123
|
-
},
|
|
124
|
-
ferra_dlmm: {
|
|
125
|
-
name: "Ferra DLMM",
|
|
126
|
-
package: "0x5a5c1d10e4782dbbdec3eb8327ede04bd078b294b97cfdba447b11b846b383ac",
|
|
127
|
-
globalConfig: "0x5c9dacf5a678ea15b8569d65960330307e23d429289ca380e665b1aa175ebeca",
|
|
128
|
-
},
|
|
129
|
-
ferra_clmm: {
|
|
130
|
-
name: "Ferra CLMM",
|
|
131
|
-
package: "0xc895342d87127c9c67b76c8ad7f9a22b8bfe1dcdc2c5af82bd85266783115e31",
|
|
132
|
-
integrate: "0x1dd5538aeb1066315969d87ae9a920ce2692824385342f49854b764ac730a64b",
|
|
133
|
-
globalConfig: "0x2cd8382c19e6994f16df204e9b8cddd04bdc486c251de75ac66ac4e48e3e7081",
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
let config = exports.DEFAULT_CONFIG;
|
|
137
|
-
let configTs = 0;
|
|
138
|
-
async function getConfig() {
|
|
139
|
-
const ttl = 60;
|
|
140
|
-
if (config && Date.now() - configTs < ttl * 1000) {
|
|
141
|
-
return config;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
const response = await (0, fetchClient_1.fetchClient)(`${apiEndpoints_1.API_ENDPOINTS.MAIN}/config`);
|
|
145
|
-
const quoteResponse = (await response.json());
|
|
146
|
-
config = { ...config, ...quoteResponse };
|
|
147
|
-
configTs = Date.now();
|
|
148
|
-
return config;
|
|
149
|
-
}
|
|
150
|
-
catch (_) {
|
|
151
|
-
return exports.DEFAULT_CONFIG;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.estimateGasFee = estimateGasFee;
|
|
4
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
5
|
-
const config_1 = require("../../config");
|
|
6
|
-
const aggregator_1 = require("../../types/aggregator");
|
|
7
|
-
const number_1 = require("../../utils/number");
|
|
8
|
-
const prices_1 = require("../prices");
|
|
9
|
-
const buildTx_1 = require("./buildTx");
|
|
10
|
-
const types_1 = require("../../libs/protocols/bluefinx/types");
|
|
11
|
-
async function estimateGasFee({ quoteResponse, accountAddress, slippage, suiPrice: _suiPrice, extendTx, commission, }) {
|
|
12
|
-
if (!accountAddress)
|
|
13
|
-
return 0;
|
|
14
|
-
// BluefinX is sponsored, no need to estimate gas fee
|
|
15
|
-
if (!accountAddress || (0, aggregator_1.isBluefinXRouting)(quoteResponse))
|
|
16
|
-
return 0;
|
|
17
|
-
const result = await (0, buildTx_1.buildTx)({
|
|
18
|
-
extendTx,
|
|
19
|
-
quoteResponse,
|
|
20
|
-
accountAddress,
|
|
21
|
-
slippage,
|
|
22
|
-
commission,
|
|
23
|
-
devInspect: true,
|
|
24
|
-
}).catch((err) => {
|
|
25
|
-
console.log("build tx error: ", err);
|
|
26
|
-
return undefined;
|
|
27
|
-
});
|
|
28
|
-
const { tx } = result || {};
|
|
29
|
-
if (!tx || tx instanceof types_1.BluefinXTx)
|
|
30
|
-
return 0;
|
|
31
|
-
const suiPrice = _suiPrice || (await (0, prices_1.getSuiPrice)());
|
|
32
|
-
const suiDecimals = utils_1.SUI_DECIMALS;
|
|
33
|
-
const { effects: { gasUsed, status }, } = await config_1.Config.getSuiClient().devInspectTransactionBlock({
|
|
34
|
-
sender: accountAddress,
|
|
35
|
-
transactionBlock: tx,
|
|
36
|
-
});
|
|
37
|
-
if (status.status !== "success")
|
|
38
|
-
return 0;
|
|
39
|
-
const fee = BigInt(gasUsed.computationCost) +
|
|
40
|
-
BigInt(gasUsed.storageCost) -
|
|
41
|
-
BigInt(gasUsed.storageRebate);
|
|
42
|
-
const feeUsd = Number(suiPrice) * Number((0, number_1.formatBalance)(fee, suiDecimals));
|
|
43
|
-
return feeUsd;
|
|
44
|
-
}
|