@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,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
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeTx = void 0;
|
|
4
|
-
const config_1 = require("../../config");
|
|
5
|
-
const client_1 = require("../../libs/protocols/bluefinx/client");
|
|
6
|
-
const types_1 = require("../../libs/protocols/bluefinx/types");
|
|
7
|
-
/**
|
|
8
|
-
* Execute a transaction after it is signed
|
|
9
|
-
*
|
|
10
|
-
* Automatically handle BluefinX transaction execution if needed
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const { mutateAsync: signTransaction } = useSignTransaction();
|
|
14
|
-
* const quoteResponse = await getQuote(...quoteParams);
|
|
15
|
-
* const { tx } = await buildTx(...buildTxParams);
|
|
16
|
-
* const {signature, bytes} = await signTransaction({
|
|
17
|
-
* transaction: tx instanceof BluefinXTx ? tx.txBytes : tx,
|
|
18
|
-
* });
|
|
19
|
-
* const res = await executeTx(tx, signature, bytes);
|
|
20
|
-
* ```
|
|
21
|
-
* @param tx - AggregatorTx - received from `buildTx`
|
|
22
|
-
* @param signature - User signature after signing the transaction
|
|
23
|
-
* @param signedTxBytes - Signed transaction bytes after signing the transaction
|
|
24
|
-
* @param options - Options for the transaction
|
|
25
|
-
* @returns `SuiTransactionBlockResponse`
|
|
26
|
-
*/
|
|
27
|
-
const executeTx = async (tx, signature, signedTxBytes, options) => {
|
|
28
|
-
const isBluefinTx = tx instanceof types_1.BluefinXTx;
|
|
29
|
-
const client = config_1.Config.getSuiClient();
|
|
30
|
-
let res;
|
|
31
|
-
if (isBluefinTx) {
|
|
32
|
-
try {
|
|
33
|
-
const result = await (0, client_1.executeBluefinTx)(tx, signature);
|
|
34
|
-
res = await client.waitForTransaction({
|
|
35
|
-
digest: result.txDigest,
|
|
36
|
-
options,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
throw Error(`Could not retrieve BluefinX transaction with quoteId: ${tx.quoteId} ${e}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
res = await client.executeTransactionBlock({
|
|
45
|
-
transactionBlock: signedTxBytes,
|
|
46
|
-
signature,
|
|
47
|
-
options,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return res;
|
|
51
|
-
};
|
|
52
|
-
exports.executeTx = executeTx;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ORACLE_BASED_SOURCES = exports.DEFAULT_SOURCES = void 0;
|
|
4
|
-
exports.getQuote = getQuote;
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const config_1 = require("../../config");
|
|
7
|
-
const fetchClient_1 = require("../../config/fetchClient");
|
|
8
|
-
const apiEndpoints_1 = require("../../constants/apiEndpoints");
|
|
9
|
-
const aggregator_1 = require("../../types/aggregator");
|
|
10
|
-
exports.DEFAULT_SOURCES = [
|
|
11
|
-
"suiswap",
|
|
12
|
-
"turbos",
|
|
13
|
-
"cetus",
|
|
14
|
-
"bluemove",
|
|
15
|
-
"kriya",
|
|
16
|
-
"kriya_v3",
|
|
17
|
-
"aftermath",
|
|
18
|
-
"deepbook_v3",
|
|
19
|
-
"flowx",
|
|
20
|
-
"flowx_v3",
|
|
21
|
-
"bluefin",
|
|
22
|
-
"springsui",
|
|
23
|
-
"obric",
|
|
24
|
-
"stsui",
|
|
25
|
-
"steamm",
|
|
26
|
-
"steamm_oracle_quoter",
|
|
27
|
-
"steamm_oracle_quoter_v2",
|
|
28
|
-
"magma",
|
|
29
|
-
"haedal_pmm",
|
|
30
|
-
"momentum",
|
|
31
|
-
"sevenk_v1",
|
|
32
|
-
"fullsail",
|
|
33
|
-
"cetus_dlmm",
|
|
34
|
-
"ferra_dlmm",
|
|
35
|
-
"ferra_clmm",
|
|
36
|
-
];
|
|
37
|
-
exports.ORACLE_BASED_SOURCES = new Set([
|
|
38
|
-
"obric",
|
|
39
|
-
"haedal_pmm",
|
|
40
|
-
"sevenk_v1",
|
|
41
|
-
"steamm_oracle_quoter",
|
|
42
|
-
"steamm_oracle_quoter_v2",
|
|
43
|
-
]);
|
|
44
|
-
async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = exports.DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
|
|
45
|
-
let sources = _sources;
|
|
46
|
-
if (isSponsored) {
|
|
47
|
-
sources = _sources.filter((s) => !exports.ORACLE_BASED_SOURCES.has(s));
|
|
48
|
-
}
|
|
49
|
-
const params = new URLSearchParams({
|
|
50
|
-
amount: amountIn,
|
|
51
|
-
from: (0, utils_1.normalizeStructTag)(tokenIn),
|
|
52
|
-
to: (0, utils_1.normalizeStructTag)(tokenOut),
|
|
53
|
-
sources: sources.join(","),
|
|
54
|
-
});
|
|
55
|
-
if (targetPools?.length) {
|
|
56
|
-
params.append("target_pools", targetPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
|
|
57
|
-
}
|
|
58
|
-
if (excludedPools?.length) {
|
|
59
|
-
params.append("excluded_pools", excludedPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
|
|
60
|
-
}
|
|
61
|
-
if (taker) {
|
|
62
|
-
params.append("taker", taker);
|
|
63
|
-
}
|
|
64
|
-
if (maxPaths) {
|
|
65
|
-
params.append("max_paths", maxPaths.toString());
|
|
66
|
-
}
|
|
67
|
-
const response = await (0, fetchClient_1.fetchClient)(`${config_1.Config.getApi() || apiEndpoints_1.API_ENDPOINTS.MAIN}/quote?${params}`);
|
|
68
|
-
if (!response.ok) {
|
|
69
|
-
let responseText;
|
|
70
|
-
try {
|
|
71
|
-
responseText = await response.text();
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
responseText = "Failed to fetch aggregator quote";
|
|
75
|
-
}
|
|
76
|
-
throw new Error(responseText);
|
|
77
|
-
}
|
|
78
|
-
const quoteResponse = (await response.json());
|
|
79
|
-
computeReturnAmountAfterCommission(quoteResponse, commissionBps);
|
|
80
|
-
return quoteResponse;
|
|
81
|
-
}
|
|
82
|
-
const computeReturnAmountAfterCommission = (quoteResponse, commissionBps) => {
|
|
83
|
-
const _commissionBps = (0, aggregator_1.isBluefinXRouting)(quoteResponse) ? 0 : commissionBps;
|
|
84
|
-
if (quoteResponse.returnAmount && +quoteResponse.returnAmount > 0) {
|
|
85
|
-
quoteResponse.returnAmountAfterCommissionWithDecimal = ((BigInt(quoteResponse.returnAmountWithDecimal || 0) *
|
|
86
|
-
BigInt(10000 - (_commissionBps ?? 0))) /
|
|
87
|
-
BigInt(10000)).toString(10);
|
|
88
|
-
const exp = Math.round(+quoteResponse.returnAmountWithDecimal / +quoteResponse.returnAmount);
|
|
89
|
-
quoteResponse.returnAmountAfterCommission = (+quoteResponse.returnAmountAfterCommissionWithDecimal / exp).toString(10);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
quoteResponse.returnAmountAfterCommission = "";
|
|
93
|
-
quoteResponse.returnAmountAfterCommissionWithDecimal = "";
|
|
94
|
-
}
|
|
95
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSwapHistory = getSwapHistory;
|
|
4
|
-
const fetchClient_1 = require("../../config/fetchClient");
|
|
5
|
-
const apiEndpoints_1 = require("../../constants/apiEndpoints");
|
|
6
|
-
const url_1 = require("../../libs/url");
|
|
7
|
-
async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair, }) {
|
|
8
|
-
const queryParams = {
|
|
9
|
-
addr: owner,
|
|
10
|
-
offset,
|
|
11
|
-
limit,
|
|
12
|
-
token_pair: tokenPair,
|
|
13
|
-
};
|
|
14
|
-
const paramsStr = (0, url_1.formatQueryParams)(queryParams);
|
|
15
|
-
const response = await (0, fetchClient_1.fetchClient)(`${apiEndpoints_1.API_ENDPOINTS.STATISTIC}/trading-history?${paramsStr}`);
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
throw new Error("Failed to fetch open limit orders");
|
|
18
|
-
}
|
|
19
|
-
const orders = (await response.json());
|
|
20
|
-
return orders;
|
|
21
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./buildTx"), exports);
|
|
18
|
-
__exportStar(require("./buildTxV2"), exports);
|
|
19
|
-
__exportStar(require("./estimateGasFee"), exports);
|
|
20
|
-
__exportStar(require("./executeTx"), exports);
|
|
21
|
-
__exportStar(require("./getQuote"), exports);
|
|
22
|
-
__exportStar(require("./getSwapHistory"), exports);
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupSwapRoutes = groupSwapRoutes;
|
|
4
|
-
const token_1 = require("../utils/token");
|
|
5
|
-
function groupSwapRoutes(quoteResponse) {
|
|
6
|
-
if (!quoteResponse.routes || !quoteResponse.swaps) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
const poolDetails = mapPoolIdsToDetails(quoteResponse.routes);
|
|
10
|
-
const items = getTxSorSwaps(quoteResponse.swaps, poolDetails);
|
|
11
|
-
const groupedItems = [];
|
|
12
|
-
let currentGroup = [];
|
|
13
|
-
for (let i = 0; i < items.length; i++) {
|
|
14
|
-
const item = items[i];
|
|
15
|
-
currentGroup.push(item);
|
|
16
|
-
const nextItem = items[i + 1];
|
|
17
|
-
if (!nextItem || BigInt(nextItem.amount) > 0n) {
|
|
18
|
-
groupedItems.push(currentGroup);
|
|
19
|
-
currentGroup = [];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (currentGroup.length > 0) {
|
|
23
|
-
groupedItems.push(currentGroup);
|
|
24
|
-
}
|
|
25
|
-
return groupedItems;
|
|
26
|
-
}
|
|
27
|
-
function mapPoolIdsToDetails(routes) {
|
|
28
|
-
const poolTypes = {};
|
|
29
|
-
routes.forEach((route) => {
|
|
30
|
-
route.hops.forEach((hop) => {
|
|
31
|
-
poolTypes[hop.poolId] = hop.pool;
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
return poolTypes;
|
|
35
|
-
}
|
|
36
|
-
function getTxSorSwaps(swaps, poolDetails) {
|
|
37
|
-
return swaps.map((swap) => {
|
|
38
|
-
const pool = poolDetails[swap.poolId];
|
|
39
|
-
const assetIn = (0, token_1.denormalizeTokenType)(swap.assetIn);
|
|
40
|
-
const assetOut = (0, token_1.denormalizeTokenType)(swap.assetOut);
|
|
41
|
-
const coinX = {
|
|
42
|
-
type: (0, token_1.denormalizeTokenType)(pool?.allTokens?.[0]?.address),
|
|
43
|
-
decimals: pool?.allTokens?.[0]?.decimal,
|
|
44
|
-
};
|
|
45
|
-
const coinY = {
|
|
46
|
-
type: (0, token_1.denormalizeTokenType)(pool?.allTokens?.[1]?.address),
|
|
47
|
-
decimals: pool?.allTokens?.[0]?.decimal,
|
|
48
|
-
};
|
|
49
|
-
const swapXtoY = assetIn === coinX.type;
|
|
50
|
-
return {
|
|
51
|
-
...swap,
|
|
52
|
-
pool,
|
|
53
|
-
assetIn,
|
|
54
|
-
assetOut,
|
|
55
|
-
coinX,
|
|
56
|
-
coinY,
|
|
57
|
-
swapXtoY,
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AfterMathContract = void 0;
|
|
4
|
-
const base_1 = require("../base");
|
|
5
|
-
const token_1 = require("../../../utils/token");
|
|
6
|
-
class AfterMathContract extends base_1.BaseContract {
|
|
7
|
-
async swap(tx) {
|
|
8
|
-
const poolId = this.swapInfo.poolId;
|
|
9
|
-
const returnAmount = this.swapInfo.returnAmount;
|
|
10
|
-
const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
|
|
11
|
-
const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
|
|
12
|
-
const inputCoinObject = this.inputCoinObject;
|
|
13
|
-
const [lpCoinType] = this.getTypeParams();
|
|
14
|
-
if (!lpCoinType)
|
|
15
|
-
throw new Error("lpCoinType is not defined");
|
|
16
|
-
const config = this.config.aftermath;
|
|
17
|
-
const [tokenOut] = tx.moveCall({
|
|
18
|
-
target: `${config.package}::swap::swap_exact_in`,
|
|
19
|
-
typeArguments: [lpCoinType, coinInType, coinOutType],
|
|
20
|
-
arguments: [
|
|
21
|
-
tx.object(poolId),
|
|
22
|
-
tx.object(config.poolRegistry),
|
|
23
|
-
tx.object(config.protocolFeeVault),
|
|
24
|
-
tx.object(config.treasury),
|
|
25
|
-
tx.object(config.insuranceFund),
|
|
26
|
-
tx.object(config.referralVault),
|
|
27
|
-
inputCoinObject,
|
|
28
|
-
tx.pure.u64(returnAmount),
|
|
29
|
-
tx.pure.u64("1000000000000000000"), // slippage
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
return tokenOut;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.AfterMathContract = AfterMathContract;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseContract = void 0;
|
|
4
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
5
|
-
const sui_1 = require("../../utils/sui");
|
|
6
|
-
class BaseContract {
|
|
7
|
-
constructor({ swapInfo, inputCoinObject, currentAccount, config, pythMap, }) {
|
|
8
|
-
this.swapInfo = swapInfo;
|
|
9
|
-
this.inputCoinObject = inputCoinObject;
|
|
10
|
-
this.currentAccount = currentAccount;
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.pythMap = pythMap;
|
|
13
|
-
}
|
|
14
|
-
getInputCoinValue(tx) {
|
|
15
|
-
return sui_1.SuiUtils.getCoinValue(this.swapInfo.assetIn, this.inputCoinObject, tx);
|
|
16
|
-
}
|
|
17
|
-
getTypeParams() {
|
|
18
|
-
return (0, utils_1.parseStructTag)(this.swapInfo.extra?.poolStructTag || "").typeParams.map(utils_1.normalizeStructTag);
|
|
19
|
-
}
|
|
20
|
-
get extra() {
|
|
21
|
-
const extra = this.swapInfo.extra;
|
|
22
|
-
if (!extra) {
|
|
23
|
-
throw new Error(`Invalid extra info for getExtra`);
|
|
24
|
-
}
|
|
25
|
-
return extra;
|
|
26
|
-
}
|
|
27
|
-
getPythPriceInfoId(oracle) {
|
|
28
|
-
// FIXME: deprecation price_identifier in the next version
|
|
29
|
-
const bytes = oracle?.Pyth?.bytes || oracle?.Pyth?.price_identifier?.bytes;
|
|
30
|
-
if (!bytes) {
|
|
31
|
-
throw new Error(`Invalid oracle info for getPythPriceInfoId`);
|
|
32
|
-
}
|
|
33
|
-
const feedId = "0x" + (0, utils_1.toHex)(Uint8Array.from(bytes));
|
|
34
|
-
const id = this.pythMap[feedId];
|
|
35
|
-
if (!id) {
|
|
36
|
-
throw new Error(`Missing price info for oracle ${feedId}`);
|
|
37
|
-
}
|
|
38
|
-
return id;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.BaseContract = BaseContract;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BluefinContract = void 0;
|
|
4
|
-
const base_1 = require("../base");
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const utils_2 = require("../utils");
|
|
7
|
-
const sui_1 = require("../../../utils/sui");
|
|
8
|
-
class BluefinContract extends base_1.BaseContract {
|
|
9
|
-
async swap(tx) {
|
|
10
|
-
const [coinX, coinY] = this.swapInfo.pool.allTokens;
|
|
11
|
-
const swapXtoY = this.swapInfo.swapXtoY;
|
|
12
|
-
const amountIn = this.getInputCoinValue(tx);
|
|
13
|
-
const coinInBalance = sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject);
|
|
14
|
-
const coinOutBalance = sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.assetOut);
|
|
15
|
-
const config = this.config.bluefin;
|
|
16
|
-
const [balanceOutX, balanceOutY] = tx.moveCall({
|
|
17
|
-
target: `${config.package}::pool::swap`,
|
|
18
|
-
typeArguments: [coinX.address, coinY.address],
|
|
19
|
-
arguments: [
|
|
20
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
21
|
-
tx.object(config.globalConfig),
|
|
22
|
-
tx.object(this.swapInfo.poolId),
|
|
23
|
-
swapXtoY ? coinInBalance : coinOutBalance,
|
|
24
|
-
swapXtoY ? coinOutBalance : coinInBalance,
|
|
25
|
-
tx.pure.bool(swapXtoY),
|
|
26
|
-
tx.pure.bool(true),
|
|
27
|
-
amountIn,
|
|
28
|
-
tx.pure.u64(0),
|
|
29
|
-
tx.pure.u128((0, utils_2.getDefaultSqrtPriceLimit)(swapXtoY) + (swapXtoY ? 1n : -1n)),
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
const coinOutX = sui_1.SuiUtils.coinFromBalance(tx, coinX.address, balanceOutX);
|
|
33
|
-
const coinOutY = sui_1.SuiUtils.coinFromBalance(tx, coinY.address, balanceOutY);
|
|
34
|
-
sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, swapXtoY ? coinOutX : coinOutY);
|
|
35
|
-
return swapXtoY ? coinOutY : coinOutX;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.BluefinContract = BluefinContract;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeBluefinTx = exports.sponsorBluefinX = void 0;
|
|
4
|
-
const config_1 = require("../../../config");
|
|
5
|
-
const apiEndpoints_1 = require("../../../constants/apiEndpoints");
|
|
6
|
-
const request = async (path, body) => {
|
|
7
|
-
const headers = new Headers({
|
|
8
|
-
"Content-Type": "application/json",
|
|
9
|
-
});
|
|
10
|
-
const bluefinXApiKey = (config_1.Config.getBluefinXApiKey() || "").trim();
|
|
11
|
-
if (bluefinXApiKey) {
|
|
12
|
-
headers.set("Bluefin-X-API-Key", bluefinXApiKey);
|
|
13
|
-
}
|
|
14
|
-
const res = await fetch(`${config_1.Config.getApi() || apiEndpoints_1.API_ENDPOINTS.MAIN}/${path}`, {
|
|
15
|
-
method: "POST",
|
|
16
|
-
body: JSON.stringify(body),
|
|
17
|
-
headers,
|
|
18
|
-
});
|
|
19
|
-
return res.json();
|
|
20
|
-
};
|
|
21
|
-
const sponsorBluefinX = async (body) => {
|
|
22
|
-
return await request("bluefinx/sponsor", body);
|
|
23
|
-
};
|
|
24
|
-
exports.sponsorBluefinX = sponsorBluefinX;
|
|
25
|
-
/**
|
|
26
|
-
* Request BluefinX for signing sponsored tx and execute it
|
|
27
|
-
*
|
|
28
|
-
* @Warning
|
|
29
|
-
* User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract
|
|
30
|
-
* @param tx - BluefinX tx which is generated by `buildTx`
|
|
31
|
-
* @param signature - user signature after signing the transaction
|
|
32
|
-
* @returns `SwapResponse`
|
|
33
|
-
*/
|
|
34
|
-
const executeBluefinTx = async (tx, signature) => {
|
|
35
|
-
return await request("bluefinx/swap", {
|
|
36
|
-
quoteId: tx.quoteId,
|
|
37
|
-
txBytes: tx.txBytes,
|
|
38
|
-
signature,
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.executeBluefinTx = executeBluefinTx;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BluefinXContract = void 0;
|
|
4
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const sui_1 = require("../../../utils/sui");
|
|
7
|
-
const base_1 = require("../base");
|
|
8
|
-
const BcsQuote = bcs_1.bcs.struct("Quote", {
|
|
9
|
-
vault: bcs_1.bcs.Address,
|
|
10
|
-
id: bcs_1.bcs.string(),
|
|
11
|
-
taker: bcs_1.bcs.Address,
|
|
12
|
-
token_in_amount: bcs_1.bcs.u64(),
|
|
13
|
-
token_out_amount: bcs_1.bcs.u64(),
|
|
14
|
-
token_in_type: bcs_1.bcs.string(),
|
|
15
|
-
token_out_type: bcs_1.bcs.string(),
|
|
16
|
-
expires_at: bcs_1.bcs.u64(),
|
|
17
|
-
created_at: bcs_1.bcs.u64(),
|
|
18
|
-
});
|
|
19
|
-
class BluefinXContract extends base_1.BaseContract {
|
|
20
|
-
async swap(tx) {
|
|
21
|
-
const extra = this.extra;
|
|
22
|
-
const quoteBytes = BcsQuote.serialize({
|
|
23
|
-
vault: extra.vault,
|
|
24
|
-
id: extra.quoteId,
|
|
25
|
-
taker: extra.taker,
|
|
26
|
-
token_in_amount: this.swapInfo.amount,
|
|
27
|
-
token_out_amount: this.swapInfo.returnAmount,
|
|
28
|
-
token_in_type: (0, utils_1.normalizeStructTag)(this.swapInfo.assetIn).slice(2),
|
|
29
|
-
token_out_type: (0, utils_1.normalizeStructTag)(this.swapInfo.assetOut).slice(2),
|
|
30
|
-
expires_at: extra.quoteExpiresAtUtcMillis,
|
|
31
|
-
created_at: extra.createdAtUtcMillis,
|
|
32
|
-
}).toBytes();
|
|
33
|
-
const [out] = tx.moveCall({
|
|
34
|
-
arguments: [
|
|
35
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
36
|
-
tx.object(extra.vault),
|
|
37
|
-
tx.object(this.config.bluefinx.globalConfig),
|
|
38
|
-
tx.pure.vector("u8", Array.from(quoteBytes)),
|
|
39
|
-
tx.pure.vector("u8", Array.from((0, utils_1.fromBase64)(extra.signature))),
|
|
40
|
-
sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject),
|
|
41
|
-
],
|
|
42
|
-
target: `${this.config.bluefinx.package}::vault::swap`,
|
|
43
|
-
typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
|
|
44
|
-
});
|
|
45
|
-
return sui_1.SuiUtils.coinFromBalance(tx, this.swapInfo.assetOut, out);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.BluefinXContract = BluefinXContract;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BluemoveContract = void 0;
|
|
4
|
-
const base_1 = require("../base");
|
|
5
|
-
const sui_1 = require("../../../utils/sui");
|
|
6
|
-
class BluemoveContract extends base_1.BaseContract {
|
|
7
|
-
async swap(tx) {
|
|
8
|
-
const config = this.config.bluemove;
|
|
9
|
-
const [coinOut] = tx.moveCall({
|
|
10
|
-
target: `${config.package}::router::swap_exact_input_`,
|
|
11
|
-
typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
|
|
12
|
-
arguments: [
|
|
13
|
-
sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
|
|
14
|
-
? this.swapInfo.coinX.type
|
|
15
|
-
: this.swapInfo.coinY.type, this.inputCoinObject, tx), // input amount
|
|
16
|
-
this.inputCoinObject, // input coin
|
|
17
|
-
tx.pure.u64(0), // min output amount
|
|
18
|
-
tx.object(config.dexInfo),
|
|
19
|
-
],
|
|
20
|
-
});
|
|
21
|
-
return coinOut;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.BluemoveContract = BluemoveContract;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CetusContract = void 0;
|
|
4
|
-
const base_1 = require("../base");
|
|
5
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
6
|
-
const utils_2 = require("../utils");
|
|
7
|
-
const sui_1 = require("../../../utils/sui");
|
|
8
|
-
class CetusContract extends base_1.BaseContract {
|
|
9
|
-
async swap(tx) {
|
|
10
|
-
const sqrtPriceLimit = (0, utils_2.getDefaultSqrtPriceLimit)(this.swapInfo.swapXtoY);
|
|
11
|
-
const typeArguments = [this.swapInfo.coinX.type, this.swapInfo.coinY.type];
|
|
12
|
-
const [zeroOut] = tx.moveCall({
|
|
13
|
-
target: "0x2::coin::zero",
|
|
14
|
-
typeArguments: [
|
|
15
|
-
this.swapInfo.swapXtoY
|
|
16
|
-
? this.swapInfo.coinY.type
|
|
17
|
-
: this.swapInfo.coinX.type,
|
|
18
|
-
],
|
|
19
|
-
});
|
|
20
|
-
const amountIn = sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
|
|
21
|
-
? this.swapInfo.coinX.type
|
|
22
|
-
: this.swapInfo.coinY.type, this.inputCoinObject, tx);
|
|
23
|
-
const config = this.config.cetus;
|
|
24
|
-
const [receiveA, receiveB] = tx.moveCall({
|
|
25
|
-
target: `${config.package}::router::swap`,
|
|
26
|
-
typeArguments,
|
|
27
|
-
arguments: [
|
|
28
|
-
tx.object(config.globalConfig),
|
|
29
|
-
tx.object(this.swapInfo.poolId),
|
|
30
|
-
this.swapInfo.swapXtoY ? this.inputCoinObject : zeroOut, // coin A
|
|
31
|
-
this.swapInfo.swapXtoY ? zeroOut : this.inputCoinObject, // coin B
|
|
32
|
-
tx.pure.bool(this.swapInfo.swapXtoY), // a to b or b to a
|
|
33
|
-
tx.pure.bool(true), // exact in or out
|
|
34
|
-
amountIn, // swap amount
|
|
35
|
-
tx.pure.u128(sqrtPriceLimit.toString()), // sqrt price limit
|
|
36
|
-
tx.pure.bool(false),
|
|
37
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB);
|
|
41
|
-
return this.swapInfo.swapXtoY ? receiveB : receiveA;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.CetusContract = CetusContract;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CetusDLMMContract = void 0;
|
|
4
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
5
|
-
const sui_1 = require("../../utils/sui");
|
|
6
|
-
const base_1 = require("./base");
|
|
7
|
-
class CetusDLMMContract extends base_1.BaseContract {
|
|
8
|
-
async swap(tx) {
|
|
9
|
-
const config = this.config.cetus_dlmm;
|
|
10
|
-
const [x, y, receipt] = tx.moveCall({
|
|
11
|
-
target: `${config.package}::pool::flash_swap`,
|
|
12
|
-
typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
|
|
13
|
-
arguments: [
|
|
14
|
-
tx.object(this.swapInfo.poolId),
|
|
15
|
-
tx.pure.bool(this.swapInfo.swapXtoY),
|
|
16
|
-
tx.pure.bool(true), // exact in
|
|
17
|
-
this.getInputCoinValue(tx),
|
|
18
|
-
tx.object(config.globalConfig),
|
|
19
|
-
tx.object(config.version),
|
|
20
|
-
tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
const debtX = this.swapInfo.swapXtoY
|
|
24
|
-
? sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.coinX.type, this.inputCoinObject)
|
|
25
|
-
: sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.coinX.type);
|
|
26
|
-
const debtY = this.swapInfo.swapXtoY
|
|
27
|
-
? sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.coinY.type)
|
|
28
|
-
: sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.coinY.type, this.inputCoinObject);
|
|
29
|
-
tx.moveCall({
|
|
30
|
-
target: `${config.package}::pool::repay_flash_swap`,
|
|
31
|
-
typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
|
|
32
|
-
arguments: [
|
|
33
|
-
tx.object(this.swapInfo.poolId),
|
|
34
|
-
debtX,
|
|
35
|
-
debtY,
|
|
36
|
-
receipt,
|
|
37
|
-
tx.object(config.version),
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
const [destroyType, destroyCoin, outType, outBalance] = this.swapInfo
|
|
41
|
-
.swapXtoY
|
|
42
|
-
? [this.swapInfo.coinX.type, x, this.swapInfo.coinY.type, y]
|
|
43
|
-
: [this.swapInfo.coinY.type, y, this.swapInfo.coinX.type, x];
|
|
44
|
-
sui_1.SuiUtils.balanceDestroyZero(tx, destroyType, destroyCoin);
|
|
45
|
-
return sui_1.SuiUtils.coinFromBalance(tx, outType, outBalance);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.CetusDLMMContract = CetusDLMMContract;
|