@7kprotocol/sdk-ts 3.6.1-beta.1 → 3.6.1-beta.2
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 +13 -10
- package/dist/bluefin7k-I6ZCDWDN.js +2 -0
- package/dist/bluefin7k-I6ZCDWDN.js.map +1 -0
- package/dist/bluefin7k-TERLUCNL.mjs +2 -0
- package/dist/bluefin7k-TERLUCNL.mjs.map +1 -0
- package/dist/cetus-AU3OMWOY.mjs +2 -0
- package/dist/cetus-AU3OMWOY.mjs.map +1 -0
- package/dist/cetus-SIPX6FYL.js +2 -0
- package/dist/cetus-SIPX6FYL.js.map +1 -0
- package/dist/chunk-ETQEI4QC.mjs +2 -0
- package/dist/chunk-ETQEI4QC.mjs.map +1 -0
- package/dist/chunk-KVGSSW22.js +2 -0
- package/dist/chunk-KVGSSW22.js.map +1 -0
- package/dist/flowx-6M54WFWO.js +2 -0
- package/dist/flowx-6M54WFWO.js.map +1 -0
- package/dist/flowx-OXZZX5FD.mjs +2 -0
- package/dist/flowx-OXZZX5FD.mjs.map +1 -0
- package/dist/index.d.mts +536 -0
- package/dist/index.d.ts +536 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +12 -20
- package/lib/cjs/config/fetchClient.js +0 -12
- package/lib/cjs/constants/_7k.js +0 -20
- package/lib/cjs/constants/apiEndpoints.js +0 -9
- package/lib/cjs/constants/sui.js +0 -4
- package/lib/cjs/constants/tokens.js +0 -7
- package/lib/cjs/features/limitDca/cancelDcaOrder.js +0 -14
- package/lib/cjs/features/limitDca/cancelLimitOrder.js +0 -14
- package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +0 -14
- package/lib/cjs/features/limitDca/constants.js +0 -13
- package/lib/cjs/features/limitDca/getClosedDcaOrders.js +0 -23
- package/lib/cjs/features/limitDca/getClosedLimitOrders.js +0 -22
- package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +0 -23
- package/lib/cjs/features/limitDca/getOpenDcaOrders.js +0 -22
- package/lib/cjs/features/limitDca/getOpenLimitOrders.js +0 -22
- package/lib/cjs/features/limitDca/index.js +0 -26
- package/lib/cjs/features/limitDca/placeDcaOrder.js +0 -33
- package/lib/cjs/features/limitDca/placeLimitOrder.js +0 -27
- package/lib/cjs/features/limitDca/types.js +0 -16
- package/lib/cjs/features/metaAg/common.js +0 -103
- package/lib/cjs/features/metaAg/error.js +0 -31
- package/lib/cjs/features/metaAg/index.js +0 -268
- package/lib/cjs/features/metaAg/providers/bluefin7k.js +0 -57
- package/lib/cjs/features/metaAg/providers/cetus.js +0 -59
- package/lib/cjs/features/metaAg/providers/flowx.js +0 -52
- package/lib/cjs/features/metaAg/providers/okx.js +0 -182
- package/lib/cjs/features/prices/index.js +0 -99
- package/lib/cjs/index.js +0 -55
- package/lib/cjs/libs/url.js +0 -17
- package/lib/cjs/types/config/fetchClient.d.ts +0 -2
- package/lib/cjs/types/config/fetchClient.d.ts.map +0 -1
- package/lib/cjs/types/constants/_7k.d.ts +0 -6
- package/lib/cjs/types/constants/_7k.d.ts.map +0 -1
- package/lib/cjs/types/constants/apiEndpoints.d.ts +0 -7
- package/lib/cjs/types/constants/apiEndpoints.d.ts.map +0 -1
- package/lib/cjs/types/constants/sui.d.ts +0 -2
- package/lib/cjs/types/constants/sui.d.ts.map +0 -1
- package/lib/cjs/types/constants/tokens.d.ts +0 -5
- package/lib/cjs/types/constants/tokens.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/cancelDcaOrder.d.ts +0 -9
- package/lib/cjs/types/features/limitDca/cancelDcaOrder.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/cancelLimitOrder.d.ts +0 -9
- package/lib/cjs/types/features/limitDca/cancelLimitOrder.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/claimExpiredLimitOrder.d.ts +0 -9
- package/lib/cjs/types/features/limitDca/claimExpiredLimitOrder.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/constants.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/constants.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/getClosedDcaOrders.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/getClosedDcaOrders.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/getClosedLimitOrders.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/getClosedLimitOrders.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/getDcaOrderExecutions.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/getDcaOrderExecutions.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/getOpenDcaOrders.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/getOpenDcaOrders.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/getOpenLimitOrders.d.ts +0 -10
- package/lib/cjs/types/features/limitDca/getOpenLimitOrders.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/index.d.ts +0 -11
- package/lib/cjs/types/features/limitDca/index.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/placeDcaOrder.d.ts +0 -14
- package/lib/cjs/types/features/limitDca/placeDcaOrder.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/placeLimitOrder.d.ts +0 -13
- package/lib/cjs/types/features/limitDca/placeLimitOrder.d.ts.map +0 -1
- package/lib/cjs/types/features/limitDca/types.d.ts +0 -98
- package/lib/cjs/types/features/limitDca/types.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/common.d.ts +0 -24
- package/lib/cjs/types/features/metaAg/common.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/error.d.ts +0 -54
- package/lib/cjs/types/features/metaAg/error.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/index.d.ts +0 -42
- package/lib/cjs/types/features/metaAg/index.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +0 -11
- package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +0 -11
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +0 -13
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts +0 -21
- package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +0 -1
- package/lib/cjs/types/features/prices/index.d.ts +0 -18
- package/lib/cjs/types/features/prices/index.d.ts.map +0 -1
- package/lib/cjs/types/index.d.ts +0 -23
- package/lib/cjs/types/index.d.ts.map +0 -1
- package/lib/cjs/types/libs/url.d.ts +0 -2
- package/lib/cjs/types/libs/url.d.ts.map +0 -1
- package/lib/cjs/types/metaAg.js +0 -16
- package/lib/cjs/types/okx.js +0 -6
- package/lib/cjs/types/types/metaAg.d.ts +0 -165
- package/lib/cjs/types/types/metaAg.d.ts.map +0 -1
- package/lib/cjs/types/types/okx.d.ts +0 -206
- package/lib/cjs/types/types/okx.d.ts.map +0 -1
- package/lib/cjs/types/utils/ObjectCache.d.ts +0 -87
- package/lib/cjs/types/utils/ObjectCache.d.ts.map +0 -1
- package/lib/cjs/types/utils/SuiClientUtils.d.ts +0 -15
- package/lib/cjs/types/utils/SuiClientUtils.d.ts.map +0 -1
- package/lib/cjs/types/utils/sui.d.ts +0 -27
- package/lib/cjs/types/utils/sui.d.ts.map +0 -1
- package/lib/cjs/types/utils/swap.d.ts +0 -15
- package/lib/cjs/types/utils/swap.d.ts.map +0 -1
- package/lib/cjs/types/utils/token.d.ts +0 -4
- package/lib/cjs/types/utils/token.d.ts.map +0 -1
- package/lib/cjs/utils/ObjectCache.js +0 -273
- package/lib/cjs/utils/SuiClientUtils.js +0 -50
- package/lib/cjs/utils/sui.js +0 -96
- package/lib/cjs/utils/swap.js +0 -37
- package/lib/cjs/utils/token.js +0 -15
- package/lib/esm/config/fetchClient.js +0 -9
- package/lib/esm/constants/_7k.js +0 -17
- package/lib/esm/constants/apiEndpoints.js +0 -6
- package/lib/esm/constants/sui.js +0 -1
- package/lib/esm/constants/tokens.js +0 -4
- package/lib/esm/features/limitDca/cancelDcaOrder.js +0 -11
- package/lib/esm/features/limitDca/cancelLimitOrder.js +0 -11
- package/lib/esm/features/limitDca/claimExpiredLimitOrder.js +0 -11
- package/lib/esm/features/limitDca/constants.js +0 -10
- package/lib/esm/features/limitDca/getClosedDcaOrders.js +0 -20
- package/lib/esm/features/limitDca/getClosedLimitOrders.js +0 -19
- package/lib/esm/features/limitDca/getDcaOrderExecutions.js +0 -20
- package/lib/esm/features/limitDca/getOpenDcaOrders.js +0 -19
- package/lib/esm/features/limitDca/getOpenLimitOrders.js +0 -19
- package/lib/esm/features/limitDca/index.js +0 -10
- package/lib/esm/features/limitDca/placeDcaOrder.js +0 -30
- package/lib/esm/features/limitDca/placeLimitOrder.js +0 -24
- package/lib/esm/features/limitDca/types.js +0 -13
- package/lib/esm/features/metaAg/common.js +0 -96
- package/lib/esm/features/metaAg/error.js +0 -29
- package/lib/esm/features/metaAg/index.js +0 -234
- package/lib/esm/features/metaAg/providers/bluefin7k.js +0 -55
- package/lib/esm/features/metaAg/providers/cetus.js +0 -57
- package/lib/esm/features/metaAg/providers/flowx.js +0 -51
- package/lib/esm/features/metaAg/providers/okx.js +0 -147
- package/lib/esm/features/prices/index.js +0 -94
- package/lib/esm/index.mjs +0 -31
- package/lib/esm/libs/url.js +0 -14
- package/lib/esm/types/config/fetchClient.d.ts +0 -2
- package/lib/esm/types/config/fetchClient.d.ts.map +0 -1
- package/lib/esm/types/constants/_7k.d.ts +0 -6
- package/lib/esm/types/constants/_7k.d.ts.map +0 -1
- package/lib/esm/types/constants/apiEndpoints.d.ts +0 -7
- package/lib/esm/types/constants/apiEndpoints.d.ts.map +0 -1
- package/lib/esm/types/constants/sui.d.ts +0 -2
- package/lib/esm/types/constants/sui.d.ts.map +0 -1
- package/lib/esm/types/constants/tokens.d.ts +0 -5
- package/lib/esm/types/constants/tokens.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/cancelDcaOrder.d.ts +0 -9
- package/lib/esm/types/features/limitDca/cancelDcaOrder.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/cancelLimitOrder.d.ts +0 -9
- package/lib/esm/types/features/limitDca/cancelLimitOrder.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/claimExpiredLimitOrder.d.ts +0 -9
- package/lib/esm/types/features/limitDca/claimExpiredLimitOrder.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/constants.d.ts +0 -10
- package/lib/esm/types/features/limitDca/constants.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/getClosedDcaOrders.d.ts +0 -10
- package/lib/esm/types/features/limitDca/getClosedDcaOrders.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/getClosedLimitOrders.d.ts +0 -10
- package/lib/esm/types/features/limitDca/getClosedLimitOrders.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/getDcaOrderExecutions.d.ts +0 -10
- package/lib/esm/types/features/limitDca/getDcaOrderExecutions.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/getOpenDcaOrders.d.ts +0 -10
- package/lib/esm/types/features/limitDca/getOpenDcaOrders.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/getOpenLimitOrders.d.ts +0 -10
- package/lib/esm/types/features/limitDca/getOpenLimitOrders.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/index.d.ts +0 -11
- package/lib/esm/types/features/limitDca/index.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/placeDcaOrder.d.ts +0 -14
- package/lib/esm/types/features/limitDca/placeDcaOrder.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/placeLimitOrder.d.ts +0 -13
- package/lib/esm/types/features/limitDca/placeLimitOrder.d.ts.map +0 -1
- package/lib/esm/types/features/limitDca/types.d.ts +0 -98
- package/lib/esm/types/features/limitDca/types.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/common.d.ts +0 -24
- package/lib/esm/types/features/metaAg/common.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/error.d.ts +0 -54
- package/lib/esm/types/features/metaAg/error.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/index.d.ts +0 -42
- package/lib/esm/types/features/metaAg/index.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +0 -11
- package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +0 -11
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +0 -13
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/okx.d.ts +0 -21
- package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +0 -1
- package/lib/esm/types/features/prices/index.d.ts +0 -18
- package/lib/esm/types/features/prices/index.d.ts.map +0 -1
- package/lib/esm/types/index.d.ts +0 -23
- package/lib/esm/types/index.d.ts.map +0 -1
- package/lib/esm/types/libs/url.d.ts +0 -2
- package/lib/esm/types/libs/url.d.ts.map +0 -1
- package/lib/esm/types/metaAg.js +0 -11
- package/lib/esm/types/okx.js +0 -5
- package/lib/esm/types/types/metaAg.d.ts +0 -165
- package/lib/esm/types/types/metaAg.d.ts.map +0 -1
- package/lib/esm/types/types/okx.d.ts +0 -206
- package/lib/esm/types/types/okx.d.ts.map +0 -1
- package/lib/esm/types/utils/ObjectCache.d.ts +0 -87
- package/lib/esm/types/utils/ObjectCache.d.ts.map +0 -1
- package/lib/esm/types/utils/SuiClientUtils.d.ts +0 -15
- package/lib/esm/types/utils/SuiClientUtils.d.ts.map +0 -1
- package/lib/esm/types/utils/sui.d.ts +0 -27
- package/lib/esm/types/utils/sui.d.ts.map +0 -1
- package/lib/esm/types/utils/swap.d.ts +0 -15
- package/lib/esm/types/utils/swap.d.ts.map +0 -1
- package/lib/esm/types/utils/token.d.ts +0 -4
- package/lib/esm/types/utils/token.d.ts.map +0 -1
- package/lib/esm/utils/ObjectCache.js +0 -250
- package/lib/esm/utils/SuiClientUtils.js +0 -34
- package/lib/esm/utils/sui.js +0 -92
- package/lib/esm/utils/swap.js +0 -33
- package/lib/esm/utils/token.js +0 -10
package/README.md
CHANGED
|
@@ -64,13 +64,13 @@ npm i @mysten/sui@^1.39.0 @pythnetwork/pyth-sui-js@^2.2.0
|
|
|
64
64
|
The following dependencies are **optional** and only needed for specific MetaAg
|
|
65
65
|
providers:
|
|
66
66
|
|
|
67
|
-
| Package
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
| Package | Version | Provider |
|
|
68
|
+
| -------------------------------------------- | --------- | ------------------------- |
|
|
69
|
+
| Package | Version | Provider |
|
|
70
|
+
| -------------------------------------------- | --------- | ----------------------- |
|
|
71
|
+
| `@flowx-finance/sdk` | `^1.13.8` | Flowx MetaAg provider |
|
|
72
|
+
| `@cetusprotocol/aggregator-sdk` | `^1.4.1` | Cetus MetaAg provider |
|
|
73
|
+
| `@bluefin-exchange/bluefin7k-aggregator-sdk` | `^5.1.4` | Bluefin7k MetaAg provider |
|
|
74
74
|
|
|
75
75
|
To use Flowx or Cetus providers, install their respective dependencies:
|
|
76
76
|
|
|
@@ -80,6 +80,9 @@ npm i @flowx-finance/sdk@^1.13.8
|
|
|
80
80
|
|
|
81
81
|
# For Cetus MetaAg provider
|
|
82
82
|
npm i @cetusprotocol/aggregator-sdk@^1.4.1
|
|
83
|
+
|
|
84
|
+
# For Bluefin7k MetaAg provider
|
|
85
|
+
npm i @bluefin-exchange/bluefin7k-aggregator-sdk@^5.1.4
|
|
83
86
|
```
|
|
84
87
|
|
|
85
88
|
### Graceful Degradation
|
|
@@ -91,14 +94,14 @@ missing:
|
|
|
91
94
|
and a helpful warning with installation instructions will be shown
|
|
92
95
|
- **Missing `@cetusprotocol/aggregator-sdk`**: Cetus MetaAg provider will not be
|
|
93
96
|
available, and a helpful warning with installation instructions will be shown
|
|
97
|
+
- **Missing `@bluefin-exchange/bluefin7k-aggregator-sdk`**: Bluefin7k MetaAg
|
|
98
|
+
provider will not be available, and a helpful warning with installation
|
|
99
|
+
instructions will be shown
|
|
94
100
|
- **Missing `@mysten/sui`**: Core functionality will fail (this is required)
|
|
95
101
|
|
|
96
102
|
The SDK will provide clear error messages and installation instructions when
|
|
97
103
|
optional dependencies are missing.
|
|
98
104
|
|
|
99
|
-
**Note**: The Bluefin7K provider works out-of-the-box with no additional
|
|
100
|
-
dependencies.
|
|
101
|
-
|
|
102
105
|
## Usage
|
|
103
106
|
|
|
104
107
|
You can import the entire SDK as a module:
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKVGSSW22js = require('./chunk-KVGSSW22.js');var _bluefin7kaggregatorsdk = require('@bluefin-exchange/bluefin7k-aggregator-sdk');var _uuid = require('uuid');var a=class{constructor(o,e,t){this.options=o;this.metaOptions=e;this.kind="bluefin7k";o.apiKey&&_bluefin7kaggregatorsdk.Config.setApiKey(o.apiKey),_bluefin7kaggregatorsdk.Config.setSuiClient(t)}async quote(o){let e=await _bluefin7kaggregatorsdk.getQuote.call(void 0, {tokenIn:o.coinTypeIn,tokenOut:o.coinTypeOut,amountIn:o.amountIn,sources:this.options.sources,excludedPools:this.options.excludedPools,targetPools:this.options.targetPools});return _chunkKVGSSW22js.l.assert(!!e,"No quote found",1005,{provider:this.kind}),{id:_uuid.v4.call(void 0, ),provider:"bluefin7k",quote:e,amountIn:e.swapAmountWithDecimal,rawAmountOut:e.returnAmountWithDecimal,amountOut:e.returnAmountWithDecimal,coinTypeIn:o.coinTypeIn,coinTypeOut:o.coinTypeOut}}async swap({quote:o,signer:e,tx:t,coinIn:s}){_chunkKVGSSW22js.l.assert(o.provider==="bluefin7k","Invalid quote",1004,{quote:o,expectedProvider:"bluefin7k"});let{coinOut:p}=await _bluefin7kaggregatorsdk.buildTx.call(void 0, {quoteResponse:o.quote,accountAddress:e,commission:{commissionBps:0,partner:_chunkKVGSSW22js.k},slippage:1,extendTx:{tx:t,coinIn:s}});return p}};exports.Bluefin7kProvider = a;
|
|
2
|
+
//# sourceMappingURL=bluefin7k-I6ZCDWDN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/otis/Documents/7k-ts-sdk/dist/bluefin7k-I6ZCDWDN.js","../src/features/metaAg/providers/bluefin7k.ts"],"names":["Bluefin7kProvider","options","metaOptions","client","Config","quoteOptions","quote","getQuote","MetaAgError","v4","signer","tx","coinIn","coinOut","buildTx","_7K_PARTNER_ADDRESS"],"mappings":"AAAA,+HAA8C,oFCIvC,4BAEY,IAcNA,CAAAA,CAAN,KAAqE,CAE1E,WAAA,CACmBC,CAAAA,CACAC,CAAAA,CACjBC,CAAAA,CACA,CAHiB,IAAA,CAAA,OAAA,CAAAF,CAAAA,CACA,IAAA,CAAA,WAAA,CAAAC,CAAAA,CAHnB,IAAA,CAAS,IAAA,CAAO,WAAA,CAMVD,CAAAA,CAAQ,MAAA,EAAQG,8BAAAA,CAAO,SAAA,CAAUH,CAAAA,CAAQ,MAAM,CAAA,CACnDG,8BAAAA,CAAO,YAAA,CAAaD,CAAM,CAC5B,CAEA,MAAM,KAAA,CAAME,CAAAA,CAAoD,CAC9D,IAAMC,CAAAA,CAAQ,MAAMC,8CAAAA,CAClB,OAAA,CAASF,CAAAA,CAAa,UAAA,CACtB,QAAA,CAAUA,CAAAA,CAAa,WAAA,CACvB,QAAA,CAAUA,CAAAA,CAAa,QAAA,CACvB,OAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,OAAA,CACtB,aAAA,CAAe,IAAA,CAAK,OAAA,CAAQ,aAAA,CAC5B,WAAA,CAAa,IAAA,CAAK,OAAA,CAAQ,WAC5B,CAAC,CAAA,CACD,OAAAG,kBAAAA,CAAY,MAAA,CACV,CAAC,CAACF,CAAAA,CACF,gBAAA,CAAA,IAAA,CAEA,CAAE,QAAA,CAAU,IAAA,CAAK,IAAK,CACxB,CAAA,CACO,CACL,EAAA,CAAIG,sBAAAA,CAAG,CACP,QAAA,CAAA,WAAA,CACA,KAAA,CAAAH,CAAAA,CACA,QAAA,CAAUA,CAAAA,CAAM,qBAAA,CAChB,YAAA,CAAcA,CAAAA,CAAM,uBAAA,CACpB,SAAA,CAAWA,CAAAA,CAAM,uBAAA,CACjB,UAAA,CAAYD,CAAAA,CAAa,UAAA,CACzB,WAAA,CAAaA,CAAAA,CAAa,WAC5B,CACF,CAEA,MAAM,IAAA,CAAK,CAAE,KAAA,CAAAC,CAAAA,CAAO,MAAA,CAAAI,CAAAA,CAAQ,EAAA,CAAAC,CAAAA,CAAI,MAAA,CAAAC,CAAO,CAAA,CAAoB,CACzDJ,kBAAAA,CAAY,MAAA,CACVF,CAAAA,CAAM,QAAA,GAAa,WAAA,CACnB,eAAA,CAAA,IAAA,CAEA,CAAE,KAAA,CAAAA,CAAAA,CAAO,gBAAA,CAAA,WAAsC,CACjD,CAAA,CACA,GAAM,CAAE,OAAA,CAAAO,CAAQ,CAAA,CAAI,MAAMC,6CAAAA,CACxB,aAAA,CAAeR,CAAAA,CAAM,KAAA,CACrB,cAAA,CAAgBI,CAAAA,CAChB,UAAA,CAAY,CACV,aAAA,CAAe,CAAA,CACf,OAAA,CAASK,kBACX,CAAA,CACA,QAAA,CAAU,CAAA,CACV,QAAA,CAAU,CACR,EAAA,CAAAJ,CAAAA,CACA,MAAA,CAAAC,CACF,CACF,CAAC,CAAA,CACD,OAAOC,CACT,CACF,CAAA,CAAA,8BAAA","file":"/Users/otis/Documents/7k-ts-sdk/dist/bluefin7k-I6ZCDWDN.js","sourcesContent":[null,"import {\n buildTx,\n Config,\n getQuote,\n} from \"@bluefin-exchange/bluefin7k-aggregator-sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n Bluefin7kProviderOptions,\n EProvider,\n MetaAgOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class Bluefin7kProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.BLUEFIN7K;\n constructor(\n private readonly options: Bluefin7kProviderOptions,\n private readonly metaOptions: Required<MetaAgOptions>,\n client: SuiClient,\n ) {\n if (options.apiKey) Config.setApiKey(options.apiKey);\n Config.setSuiClient(client);\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await getQuote({\n tokenIn: quoteOptions.coinTypeIn,\n tokenOut: quoteOptions.coinTypeOut,\n amountIn: quoteOptions.amountIn,\n sources: this.options.sources,\n excludedPools: this.options.excludedPools,\n targetPools: this.options.targetPools,\n });\n MetaAgError.assert(\n !!quote,\n \"No quote found\",\n MetaAgErrorCode.QUOTE_NOT_FOUND,\n { provider: this.kind },\n );\n return {\n id: v4(),\n provider: EProvider.BLUEFIN7K,\n quote,\n amountIn: quote.swapAmountWithDecimal,\n rawAmountOut: quote.returnAmountWithDecimal,\n amountOut: quote.returnAmountWithDecimal,\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap({ quote, signer, tx, coinIn }: MetaSwapOptions) {\n MetaAgError.assert(\n quote.provider === EProvider.BLUEFIN7K,\n \"Invalid quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote, expectedProvider: EProvider.BLUEFIN7K },\n );\n const { coinOut } = await buildTx({\n quoteResponse: quote.quote,\n accountAddress: signer,\n commission: {\n commissionBps: 0,\n partner: _7K_PARTNER_ADDRESS,\n },\n slippage: 1,\n extendTx: {\n tx,\n coinIn,\n },\n });\n return coinOut!;\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{k as i,l as r}from"./chunk-ETQEI4QC.mjs";import{buildTx as u,Config as n,getQuote as m}from"@bluefin-exchange/bluefin7k-aggregator-sdk";import{v4 as d}from"uuid";var a=class{constructor(o,e,t){this.options=o;this.metaOptions=e;this.kind="bluefin7k";o.apiKey&&n.setApiKey(o.apiKey),n.setSuiClient(t)}async quote(o){let e=await m({tokenIn:o.coinTypeIn,tokenOut:o.coinTypeOut,amountIn:o.amountIn,sources:this.options.sources,excludedPools:this.options.excludedPools,targetPools:this.options.targetPools});return r.assert(!!e,"No quote found",1005,{provider:this.kind}),{id:d(),provider:"bluefin7k",quote:e,amountIn:e.swapAmountWithDecimal,rawAmountOut:e.returnAmountWithDecimal,amountOut:e.returnAmountWithDecimal,coinTypeIn:o.coinTypeIn,coinTypeOut:o.coinTypeOut}}async swap({quote:o,signer:e,tx:t,coinIn:s}){r.assert(o.provider==="bluefin7k","Invalid quote",1004,{quote:o,expectedProvider:"bluefin7k"});let{coinOut:p}=await u({quoteResponse:o.quote,accountAddress:e,commission:{commissionBps:0,partner:i},slippage:1,extendTx:{tx:t,coinIn:s}});return p}};export{a as Bluefin7kProvider};
|
|
2
|
+
//# sourceMappingURL=bluefin7k-TERLUCNL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/metaAg/providers/bluefin7k.ts"],"sourcesContent":["import {\n buildTx,\n Config,\n getQuote,\n} from \"@bluefin-exchange/bluefin7k-aggregator-sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n Bluefin7kProviderOptions,\n EProvider,\n MetaAgOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class Bluefin7kProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.BLUEFIN7K;\n constructor(\n private readonly options: Bluefin7kProviderOptions,\n private readonly metaOptions: Required<MetaAgOptions>,\n client: SuiClient,\n ) {\n if (options.apiKey) Config.setApiKey(options.apiKey);\n Config.setSuiClient(client);\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await getQuote({\n tokenIn: quoteOptions.coinTypeIn,\n tokenOut: quoteOptions.coinTypeOut,\n amountIn: quoteOptions.amountIn,\n sources: this.options.sources,\n excludedPools: this.options.excludedPools,\n targetPools: this.options.targetPools,\n });\n MetaAgError.assert(\n !!quote,\n \"No quote found\",\n MetaAgErrorCode.QUOTE_NOT_FOUND,\n { provider: this.kind },\n );\n return {\n id: v4(),\n provider: EProvider.BLUEFIN7K,\n quote,\n amountIn: quote.swapAmountWithDecimal,\n rawAmountOut: quote.returnAmountWithDecimal,\n amountOut: quote.returnAmountWithDecimal,\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap({ quote, signer, tx, coinIn }: MetaSwapOptions) {\n MetaAgError.assert(\n quote.provider === EProvider.BLUEFIN7K,\n \"Invalid quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote, expectedProvider: EProvider.BLUEFIN7K },\n );\n const { coinOut } = await buildTx({\n quoteResponse: quote.quote,\n accountAddress: signer,\n commission: {\n commissionBps: 0,\n partner: _7K_PARTNER_ADDRESS,\n },\n slippage: 1,\n extendTx: {\n tx,\n coinIn,\n },\n });\n return coinOut!;\n }\n}\n"],"mappings":"gDAAA,OACE,WAAAA,EACA,UAAAC,EACA,YAAAC,MACK,6CAEP,OAAS,MAAAC,MAAU,OAcZ,IAAMC,EAAN,KAAqE,CAE1E,YACmBC,EACAC,EACjBC,EACA,CAHiB,aAAAF,EACA,iBAAAC,EAHnB,KAAS,KAAO,YAMVD,EAAQ,QAAQG,EAAO,UAAUH,EAAQ,MAAM,EACnDG,EAAO,aAAaD,CAAM,CAC5B,CAEA,MAAM,MAAME,EAAoD,CAC9D,IAAMC,EAAQ,MAAMC,EAAS,CAC3B,QAASF,EAAa,WACtB,SAAUA,EAAa,YACvB,SAAUA,EAAa,SACvB,QAAS,KAAK,QAAQ,QACtB,cAAe,KAAK,QAAQ,cAC5B,YAAa,KAAK,QAAQ,WAC5B,CAAC,EACD,OAAAG,EAAY,OACV,CAAC,CAACF,EACF,sBAEA,CAAE,SAAU,KAAK,IAAK,CACxB,EACO,CACL,GAAIG,EAAG,EACP,qBACA,MAAAH,EACA,SAAUA,EAAM,sBAChB,aAAcA,EAAM,wBACpB,UAAWA,EAAM,wBACjB,WAAYD,EAAa,WACzB,YAAaA,EAAa,WAC5B,CACF,CAEA,MAAM,KAAK,CAAE,MAAAC,EAAO,OAAAI,EAAQ,GAAAC,EAAI,OAAAC,CAAO,EAAoB,CACzDJ,EAAY,OACVF,EAAM,WAAa,YACnB,qBAEA,CAAE,MAAAA,EAAO,4BAAsC,CACjD,EACA,GAAM,CAAE,QAAAO,CAAQ,EAAI,MAAMC,EAAQ,CAChC,cAAeR,EAAM,MACrB,eAAgBI,EAChB,WAAY,CACV,cAAe,EACf,QAASK,CACX,EACA,SAAU,EACV,SAAU,CACR,GAAAJ,EACA,OAAAC,CACF,CACF,CAAC,EACD,OAAOC,CACT,CACF","names":["buildTx","Config","getQuote","v4","Bluefin7kProvider","options","metaOptions","client","Config","quoteOptions","quote","getQuote","MetaAgError","v4","signer","tx","coinIn","coinOut","buildTx","_7K_PARTNER_ADDRESS"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{k as i,l as o}from"./chunk-ETQEI4QC.mjs";import{AggregatorClient as a,Env as u}from"@cetusprotocol/aggregator-sdk";import{v4 as s}from"uuid";var r=class{constructor(t,e,n){this.options=t;this.kind="cetus";this.cetusClient=new a({apiKey:t.apiKey,client:n,endpoint:t.api,env:u.Mainnet,pythUrls:e.hermesApi?[e.hermesApi]:[],overlayFeeRate:0,overlayFeeReceiver:i})}async quote(t){let e=await this.cetusClient.findRouters({amount:t.amountIn,byAmountIn:!0,from:t.coinTypeIn,target:t.coinTypeOut,providers:this.options.sources,splitCount:this.options.splitCount,splitAlgorithm:this.options.splitAlgorithm,splitFactor:this.options.splitFactor,depth:this.options.depth,liquidityChanges:this.options.liquidityChanges});return o.assert(!!e,"No quote found",1005,{provider:this.kind}),{id:s(),provider:"cetus",quote:e,amountIn:e.amountIn.toString()||"0",rawAmountOut:e.amountOut.toString()||"0",amountOut:e.amountOut.toString()||"0",coinTypeIn:t.coinTypeIn,coinTypeOut:t.coinTypeOut}}async swap(t){return o.assert(t.quote.provider==="cetus","Expect Cetus quote",1004,{quote:t.quote,expectedProvider:"cetus"}),await this.cetusClient.routerSwap({inputCoin:t.coinIn,router:t.quote.quote,slippage:1,txb:t.tx})}};export{r as CetusProvider};
|
|
2
|
+
//# sourceMappingURL=cetus-AU3OMWOY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/metaAg/providers/cetus.ts"],"sourcesContent":["import { AggregatorClient, Env } from \"@cetusprotocol/aggregator-sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n CetusProviderOptions,\n EProvider,\n MetaAgOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class CetusProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.CETUS;\n private readonly cetusClient: AggregatorClient;\n constructor(\n private readonly options: CetusProviderOptions,\n metaOptions: MetaAgOptions,\n client: SuiClient,\n ) {\n this.cetusClient = new AggregatorClient({\n apiKey: options.apiKey,\n client,\n endpoint: options.api,\n env: Env.Mainnet,\n pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],\n overlayFeeRate: 0,\n overlayFeeReceiver: _7K_PARTNER_ADDRESS,\n });\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await this.cetusClient.findRouters({\n amount: quoteOptions.amountIn,\n byAmountIn: true,\n from: quoteOptions.coinTypeIn,\n target: quoteOptions.coinTypeOut,\n providers: this.options.sources,\n splitCount: this.options.splitCount,\n splitAlgorithm: this.options.splitAlgorithm,\n splitFactor: this.options.splitFactor,\n depth: this.options.depth,\n liquidityChanges: this.options.liquidityChanges,\n });\n MetaAgError.assert(\n !!quote,\n \"No quote found\",\n MetaAgErrorCode.QUOTE_NOT_FOUND,\n { provider: this.kind },\n );\n return {\n id: v4(),\n provider: EProvider.CETUS,\n quote,\n amountIn: quote.amountIn.toString() || \"0\",\n rawAmountOut: quote.amountOut.toString() || \"0\",\n amountOut: quote.amountOut.toString() || \"0\",\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap(options: MetaSwapOptions) {\n MetaAgError.assert(\n options.quote.provider === EProvider.CETUS,\n \"Expect Cetus quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote: options.quote, expectedProvider: EProvider.CETUS },\n );\n const coinOut = await this.cetusClient.routerSwap({\n inputCoin: options.coinIn,\n router: options.quote.quote,\n slippage: 1,\n txb: options.tx,\n });\n return coinOut;\n }\n}\n"],"mappings":"gDAAA,OAAS,oBAAAA,EAAkB,OAAAC,MAAW,gCAEtC,OAAS,MAAAC,MAAU,OAcZ,IAAMC,EAAN,KAAiE,CAGtE,YACmBC,EACjBC,EACAC,EACA,CAHiB,aAAAF,EAHnB,KAAS,KAAO,QAOd,KAAK,YAAc,IAAIG,EAAiB,CACtC,OAAQH,EAAQ,OAChB,OAAAE,EACA,SAAUF,EAAQ,IAClB,IAAKI,EAAI,QACT,SAAUH,EAAY,UAAY,CAACA,EAAY,SAAS,EAAI,CAAC,EAC7D,eAAgB,EAChB,mBAAoBI,CACtB,CAAC,CACH,CAEA,MAAM,MAAMC,EAAoD,CAC9D,IAAMC,EAAQ,MAAM,KAAK,YAAY,YAAY,CAC/C,OAAQD,EAAa,SACrB,WAAY,GACZ,KAAMA,EAAa,WACnB,OAAQA,EAAa,YACrB,UAAW,KAAK,QAAQ,QACxB,WAAY,KAAK,QAAQ,WACzB,eAAgB,KAAK,QAAQ,eAC7B,YAAa,KAAK,QAAQ,YAC1B,MAAO,KAAK,QAAQ,MACpB,iBAAkB,KAAK,QAAQ,gBACjC,CAAC,EACD,OAAAE,EAAY,OACV,CAAC,CAACD,EACF,sBAEA,CAAE,SAAU,KAAK,IAAK,CACxB,EACO,CACL,GAAIE,EAAG,EACP,iBACA,MAAAF,EACA,SAAUA,EAAM,SAAS,SAAS,GAAK,IACvC,aAAcA,EAAM,UAAU,SAAS,GAAK,IAC5C,UAAWA,EAAM,UAAU,SAAS,GAAK,IACzC,WAAYD,EAAa,WACzB,YAAaA,EAAa,WAC5B,CACF,CAEA,MAAM,KAAKN,EAA0B,CACnC,OAAAQ,EAAY,OACVR,EAAQ,MAAM,WAAa,QAC3B,0BAEA,CAAE,MAAOA,EAAQ,MAAO,wBAAkC,CAC5D,EACgB,MAAM,KAAK,YAAY,WAAW,CAChD,UAAWA,EAAQ,OACnB,OAAQA,EAAQ,MAAM,MACtB,SAAU,EACV,IAAKA,EAAQ,EACf,CAAC,CAEH,CACF","names":["AggregatorClient","Env","v4","CetusProvider","options","metaOptions","client","AggregatorClient","Env","_7K_PARTNER_ADDRESS","quoteOptions","quote","MetaAgError","v4"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKVGSSW22js = require('./chunk-KVGSSW22.js');var _aggregatorsdk = require('@cetusprotocol/aggregator-sdk');var _uuid = require('uuid');var r=class{constructor(t,e,n){this.options=t;this.kind="cetus";this.cetusClient=new (0, _aggregatorsdk.AggregatorClient)({apiKey:t.apiKey,client:n,endpoint:t.api,env:_aggregatorsdk.Env.Mainnet,pythUrls:e.hermesApi?[e.hermesApi]:[],overlayFeeRate:0,overlayFeeReceiver:_chunkKVGSSW22js.k})}async quote(t){let e=await this.cetusClient.findRouters({amount:t.amountIn,byAmountIn:!0,from:t.coinTypeIn,target:t.coinTypeOut,providers:this.options.sources,splitCount:this.options.splitCount,splitAlgorithm:this.options.splitAlgorithm,splitFactor:this.options.splitFactor,depth:this.options.depth,liquidityChanges:this.options.liquidityChanges});return _chunkKVGSSW22js.l.assert(!!e,"No quote found",1005,{provider:this.kind}),{id:_uuid.v4.call(void 0, ),provider:"cetus",quote:e,amountIn:e.amountIn.toString()||"0",rawAmountOut:e.amountOut.toString()||"0",amountOut:e.amountOut.toString()||"0",coinTypeIn:t.coinTypeIn,coinTypeOut:t.coinTypeOut}}async swap(t){return _chunkKVGSSW22js.l.assert(t.quote.provider==="cetus","Expect Cetus quote",1004,{quote:t.quote,expectedProvider:"cetus"}),await this.cetusClient.routerSwap({inputCoin:t.coinIn,router:t.quote.quote,slippage:1,txb:t.tx})}};exports.CetusProvider = r;
|
|
2
|
+
//# sourceMappingURL=cetus-SIPX6FYL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/otis/Documents/7k-ts-sdk/dist/cetus-SIPX6FYL.js","../src/features/metaAg/providers/cetus.ts"],"names":["CetusProvider","options","metaOptions","client","AggregatorClient","Env","_7K_PARTNER_ADDRESS","quoteOptions","quote","MetaAgError","v4"],"mappings":"AAAA,+HAA8C,8DCAR,4BAEnB,IAcNA,CAAAA,CAAN,KAAiE,CAGtE,WAAA,CACmBC,CAAAA,CACjBC,CAAAA,CACAC,CAAAA,CACA,CAHiB,IAAA,CAAA,OAAA,CAAAF,CAAAA,CAHnB,IAAA,CAAS,IAAA,CAAO,OAAA,CAOd,IAAA,CAAK,WAAA,CAAc,IAAIG,oCAAAA,CAAiB,CACtC,MAAA,CAAQH,CAAAA,CAAQ,MAAA,CAChB,MAAA,CAAAE,CAAAA,CACA,QAAA,CAAUF,CAAAA,CAAQ,GAAA,CAClB,GAAA,CAAKI,kBAAAA,CAAI,OAAA,CACT,QAAA,CAAUH,CAAAA,CAAY,SAAA,CAAY,CAACA,CAAAA,CAAY,SAAS,CAAA,CAAI,CAAC,CAAA,CAC7D,cAAA,CAAgB,CAAA,CAChB,kBAAA,CAAoBI,kBACtB,CAAC,CACH,CAEA,MAAM,KAAA,CAAMC,CAAAA,CAAoD,CAC9D,IAAMC,CAAAA,CAAQ,MAAM,IAAA,CAAK,WAAA,CAAY,WAAA,CAAY,CAC/C,MAAA,CAAQD,CAAAA,CAAa,QAAA,CACrB,UAAA,CAAY,CAAA,CAAA,CACZ,IAAA,CAAMA,CAAAA,CAAa,UAAA,CACnB,MAAA,CAAQA,CAAAA,CAAa,WAAA,CACrB,SAAA,CAAW,IAAA,CAAK,OAAA,CAAQ,OAAA,CACxB,UAAA,CAAY,IAAA,CAAK,OAAA,CAAQ,UAAA,CACzB,cAAA,CAAgB,IAAA,CAAK,OAAA,CAAQ,cAAA,CAC7B,WAAA,CAAa,IAAA,CAAK,OAAA,CAAQ,WAAA,CAC1B,KAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,CACpB,gBAAA,CAAkB,IAAA,CAAK,OAAA,CAAQ,gBACjC,CAAC,CAAA,CACD,OAAAE,kBAAAA,CAAY,MAAA,CACV,CAAC,CAACD,CAAAA,CACF,gBAAA,CAAA,IAAA,CAEA,CAAE,QAAA,CAAU,IAAA,CAAK,IAAK,CACxB,CAAA,CACO,CACL,EAAA,CAAIE,sBAAAA,CAAG,CACP,QAAA,CAAA,OAAA,CACA,KAAA,CAAAF,CAAAA,CACA,QAAA,CAAUA,CAAAA,CAAM,QAAA,CAAS,QAAA,CAAS,CAAA,EAAK,GAAA,CACvC,YAAA,CAAcA,CAAAA,CAAM,SAAA,CAAU,QAAA,CAAS,CAAA,EAAK,GAAA,CAC5C,SAAA,CAAWA,CAAAA,CAAM,SAAA,CAAU,QAAA,CAAS,CAAA,EAAK,GAAA,CACzC,UAAA,CAAYD,CAAAA,CAAa,UAAA,CACzB,WAAA,CAAaA,CAAAA,CAAa,WAC5B,CACF,CAEA,MAAM,IAAA,CAAKN,CAAAA,CAA0B,CACnC,OAAAQ,kBAAAA,CAAY,MAAA,CACVR,CAAAA,CAAQ,KAAA,CAAM,QAAA,GAAa,OAAA,CAC3B,oBAAA,CAAA,IAAA,CAEA,CAAE,KAAA,CAAOA,CAAAA,CAAQ,KAAA,CAAO,gBAAA,CAAA,OAAkC,CAC5D,CAAA,CACgB,MAAM,IAAA,CAAK,WAAA,CAAY,UAAA,CAAW,CAChD,SAAA,CAAWA,CAAAA,CAAQ,MAAA,CACnB,MAAA,CAAQA,CAAAA,CAAQ,KAAA,CAAM,KAAA,CACtB,QAAA,CAAU,CAAA,CACV,GAAA,CAAKA,CAAAA,CAAQ,EACf,CAAC,CAEH,CACF,CAAA,CAAA,0BAAA","file":"/Users/otis/Documents/7k-ts-sdk/dist/cetus-SIPX6FYL.js","sourcesContent":[null,"import { AggregatorClient, Env } from \"@cetusprotocol/aggregator-sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n CetusProviderOptions,\n EProvider,\n MetaAgOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class CetusProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.CETUS;\n private readonly cetusClient: AggregatorClient;\n constructor(\n private readonly options: CetusProviderOptions,\n metaOptions: MetaAgOptions,\n client: SuiClient,\n ) {\n this.cetusClient = new AggregatorClient({\n apiKey: options.apiKey,\n client,\n endpoint: options.api,\n env: Env.Mainnet,\n pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],\n overlayFeeRate: 0,\n overlayFeeReceiver: _7K_PARTNER_ADDRESS,\n });\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await this.cetusClient.findRouters({\n amount: quoteOptions.amountIn,\n byAmountIn: true,\n from: quoteOptions.coinTypeIn,\n target: quoteOptions.coinTypeOut,\n providers: this.options.sources,\n splitCount: this.options.splitCount,\n splitAlgorithm: this.options.splitAlgorithm,\n splitFactor: this.options.splitFactor,\n depth: this.options.depth,\n liquidityChanges: this.options.liquidityChanges,\n });\n MetaAgError.assert(\n !!quote,\n \"No quote found\",\n MetaAgErrorCode.QUOTE_NOT_FOUND,\n { provider: this.kind },\n );\n return {\n id: v4(),\n provider: EProvider.CETUS,\n quote,\n amountIn: quote.amountIn.toString() || \"0\",\n rawAmountOut: quote.amountOut.toString() || \"0\",\n amountOut: quote.amountOut.toString() || \"0\",\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap(options: MetaSwapOptions) {\n MetaAgError.assert(\n options.quote.provider === EProvider.CETUS,\n \"Expect Cetus quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote: options.quote, expectedProvider: EProvider.CETUS },\n );\n const coinOut = await this.cetusClient.routerSwap({\n inputCoin: options.coinIn,\n router: options.quote.quote,\n slippage: 1,\n txb: options.tx,\n });\n return coinOut;\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=e=>{throw TypeError(e)};var n=(e,t,r)=>t.has(e)||s("Cannot "+r);var d=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e)),u=(e,t,r)=>t.has(e)?s("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),O=(e,t,r,o)=>(n(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var p=(i=>(i.BLUEFIN7K="bluefin7k",i.CETUS="cetus",i.FLOWX="flowx",i.OKX="okx",i))(p||{}),P=e=>e.kind==="bluefin7k"||e.kind==="cetus"||e.kind==="flowx",g=e=>e.kind==="okx";var E="0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302",l="0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302",x="0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c",T="0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56",v="0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";var a=class e extends Error{constructor(t,r,o){super(t),this.name="MetaAgError",this.code=r??1e3,this.details=o}static assert(t,r,o,i){if(!t)throw new e(r??"Assertion failed",o,i)}};export{d as a,u as b,O as c,p as d,P as e,g as f,E as g,l as h,x as i,T as j,v as k,a as l};
|
|
2
|
+
//# sourceMappingURL=chunk-ETQEI4QC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/metaAg.ts","../src/constants/_7k.ts","../src/features/metaAg/error.ts"],"sourcesContent":["import type {\n QuoteResponse,\n SourceDex,\n} from \"@bluefin-exchange/bluefin7k-aggregator-sdk\";\nimport type {\n PreSwapLpChangeParams,\n RouterDataV3,\n} from \"@cetusprotocol/aggregator-sdk\";\nimport type { AggregatorQuoter, Protocol } from \"@flowx-finance/sdk\";\nimport type { GasCostSummary } from \"@mysten/sui/client\";\nimport { SignatureWithBytes } from \"@mysten/sui/cryptography\";\nimport type {\n Transaction,\n TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { OkxSwapResponseData } from \"./okx\";\n\nexport enum EProvider {\n BLUEFIN7K = \"bluefin7k\",\n CETUS = \"cetus\",\n FLOWX = \"flowx\",\n OKX = \"okx\",\n}\ntype ProviderBaseOptions = {\n api?: string;\n apiKey?: string;\n disabled?: boolean;\n};\nexport type Bluefin7kProviderOptions = ProviderBaseOptions & {\n sources?: SourceDex[];\n excludedPools?: string[];\n targetPools?: string[];\n};\nexport type FlowxProviderOptions = ProviderBaseOptions & {\n sources?: Protocol[];\n excludePools?: string[];\n excludeSources?: Protocol[];\n maxHops?: number;\n splitDistributionPercent?: number;\n};\nexport type CetusProviderOptions = ProviderBaseOptions & {\n sources?: string[];\n splitCount?: number;\n splitAlgorithm?: string;\n splitFactor?: number;\n depth?: number;\n liquidityChanges?: PreSwapLpChangeParams[];\n};\nexport type OkxProviderOptions = Required<Omit<ProviderBaseOptions, \"api\">> & {\n api?: string;\n secretKey: string;\n apiPassphrase: string;\n projectId: string;\n};\nexport interface MetaAgOptions {\n /**If not specified, all providers will be used */\n providers?: {\n [EProvider.BLUEFIN7K]?: Bluefin7kProviderOptions;\n [EProvider.FLOWX]?: FlowxProviderOptions;\n [EProvider.CETUS]?: CetusProviderOptions;\n [EProvider.OKX]?: OkxProviderOptions;\n };\n /**Mainnet Json Rpc url, if not specified, the default mainnet url will be used */\n fullnodeUrl?: string;\n /**Hermes Api url, if not specified, the default hermes api url will be used */\n hermesApi?: string;\n /**Address to receive commission, if not specified, the commission will not be used */\n partner?: string;\n /**@default 0 */\n partnerCommissionBps?: number;\n /**@default 100 */\n slippageBps?: number;\n /**\n * Tip to support 7k\n * @default 0 */\n tipBps?: number;\n}\nexport interface MetaQuoteOptions {\n coinTypeIn: string;\n coinTypeOut: string;\n amountIn: string;\n /** Required for api-tx providers (ie: Okx) */\n signer?: string;\n /**\n * Timeout for quote operation in milliseconds\n * @default 2000ms\n */\n timeout?: number;\n}\nexport interface MetaSimulationOptions {\n sender: string;\n /**\n * Timeout for simulation operation in milliseconds\n * @default 2000ms\n */\n timeout?: number;\n /** If specify, defer the simulation that could reduce the time to display quote result, you must update the quote via the id on callback\n * else await all quote and simulation before return\n */\n onSimulated?: (payload: MetaQuote) => void;\n}\nexport interface MetaFastSwapOptions {\n /** Quote object from the quote operation */\n quote: MetaQuote;\n /** Signer address (owner of `coinIn`) */\n signer: string;\n /** If true, use the gas coin for the swap\n * @default true */\n useGasCoin?: boolean;\n /**\n * Sign the transaction bytes\n * @param txBytes - base64 transaction bytes\n * @returns - signature with bytes\n */\n signTransaction: (txBytes: string) => Promise<SignatureWithBytes>;\n}\nexport interface MetaSwapOptions {\n /** Quote object from the quote operation */\n quote: MetaQuote;\n /** Signer address (owner of `coinIn`) */\n signer: string;\n /** Transaction object to add the swap operation */\n tx: Transaction;\n /**\n * Coin object used for the swap, must be consumed completely, no `coinIn` left, user must pass the coinIn object with the balance required for the swap - ie in quote `amountIn`\n * @warning `coinIn` value must match the quote `amountIn` */\n coinIn: TransactionObjectArgument;\n}\n\nexport type FlowxQuoteResponse = Awaited<\n ReturnType<AggregatorQuoter[\"getRoutes\"]>\n>;\nexport type MetaQuote = (\n | {\n provider: EProvider.BLUEFIN7K;\n quote: QuoteResponse;\n }\n | {\n provider: EProvider.CETUS;\n quote: RouterDataV3;\n }\n | {\n provider: EProvider.FLOWX;\n quote: FlowxQuoteResponse;\n }\n | {\n provider: EProvider.OKX;\n quote: OkxSwapResponseData;\n }\n) & {\n /** uuid to keep track the quote result, used to apply simulation result on quote on callback `onSimulated`*/\n id: string;\n /** coin type: ie 0x2::sui::SUI */\n coinTypeIn: string;\n /** coin type: ie 0x2::sui::SUI */\n coinTypeOut: string;\n /** Amount in as u64 */\n amountIn: string;\n /** Amount out as u64 if there're no commission be applied to the amount out */\n rawAmountOut: string;\n /** Amount as u64 after minus any commission kind */\n amountOut: string;\n /** Simulated amount out if the transaction is executed */\n simulatedAmountOut?: string;\n /** Estimate gas consumption if the transaction is executed */\n gasUsed?: GasCostSummary;\n};\nexport interface QuoteProvider {\n readonly kind: EProvider;\n quote(_quoteOptions: MetaQuoteOptions): Promise<MetaQuote | null>;\n}\n\nexport interface SwapAPIProvider extends QuoteProvider {\n readonly kind: EProvider.OKX;\n fastSwap(options: MetaFastSwapOptions): Promise<string>;\n}\n\nexport interface AggregatorProvider extends QuoteProvider {\n readonly kind: EProvider.BLUEFIN7K | EProvider.CETUS | EProvider.FLOWX;\n swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;\n}\n\nexport const isAggregatorProvider = (\n provider: QuoteProvider,\n): provider is AggregatorProvider =>\n provider.kind === EProvider.BLUEFIN7K ||\n provider.kind === EProvider.CETUS ||\n provider.kind === EProvider.FLOWX;\n\nexport const isSwapAPIProvider = (\n provider: QuoteProvider,\n): provider is SwapAPIProvider => provider.kind === EProvider.OKX;\n","// export const _7K_PACKAGE_ID =\n// \"0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04\";\n// //legacy V4: \"0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2\";\n// //legacy V3: \"0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519\";\n// //legacy V2: \"0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f\";\n// //legacy V1: \"0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc\";\n// export const _7K_CONFIG =\n// \"0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54\";\n// //legacy v3: \"0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee\";\n\n// export const _7K_VAULT =\n// \"0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6\";\n// //legacy v3: \"0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514\";\nexport const _7K_META_PUBLISHED_AT =\n \"0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302\";\nexport const _7K_META_PACKAGE_ID =\n \"0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302\";\nexport const _7K_META_VAULT =\n \"0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c\";\nexport const _7K_META_CONFIG =\n \"0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56\";\nexport const _7K_PARTNER_ADDRESS =\n \"0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5\";\n","import { DevInspectResults } from \"@mysten/sui/client\";\nimport { EProvider, MetaQuote, MetaQuoteOptions } from \"../../types/metaAg\";\n\nexport enum MetaAgErrorCode {\n UNKNOWN = 1000,\n TIMEOUT = 1001,\n PROVIDER_NOT_FOUND = 1002,\n PROVIDER_NOT_SUPPORTED = 1003,\n INVALID_QUOTE = 1004,\n QUOTE_NOT_FOUND = 1005,\n INVALID_SIGNER_ADDRESS = 1006,\n PROVIDER_NOT_SUPPORT_SWAP = 1007,\n SIMULATION_FAILED = 1008,\n // OKX error\n OKX_FINALIZE_COMMAND_NOT_FOUND = 1100,\n}\n\nexport type MetaAgErrorDetailsMap = {\n [MetaAgErrorCode.UNKNOWN]: any;\n [MetaAgErrorCode.TIMEOUT]: { timeout: number };\n [MetaAgErrorCode.PROVIDER_NOT_FOUND]: { provider: EProvider };\n [MetaAgErrorCode.PROVIDER_NOT_SUPPORTED]: { provider: EProvider };\n [MetaAgErrorCode.INVALID_QUOTE]: {\n quote: MetaQuote;\n expectedProvider: EProvider;\n };\n [MetaAgErrorCode.QUOTE_NOT_FOUND]: {\n provider: EProvider;\n quoteOptions?: MetaQuoteOptions;\n };\n [MetaAgErrorCode.INVALID_SIGNER_ADDRESS]: { signer: string };\n [MetaAgErrorCode.PROVIDER_NOT_SUPPORT_SWAP]: { provider: EProvider };\n [MetaAgErrorCode.SIMULATION_FAILED]: { error: DevInspectResults[\"error\"] };\n // OKX error\n [MetaAgErrorCode.OKX_FINALIZE_COMMAND_NOT_FOUND]: { packageId: string };\n};\n\nexport type MetaAgErrorDetails<T extends MetaAgErrorCode> =\n T extends keyof MetaAgErrorDetailsMap ? MetaAgErrorDetailsMap[T] : never;\n\nexport class MetaAgError<T extends MetaAgErrorCode> extends Error {\n code: T;\n details?: MetaAgErrorDetails<T>;\n constructor(message: string, code?: T, details?: MetaAgErrorDetails<T>) {\n super(message);\n this.name = \"MetaAgError\";\n this.code = code ?? (MetaAgErrorCode.UNKNOWN as T);\n this.details = details;\n }\n\n static assert<T extends MetaAgErrorCode>(\n condition: any,\n message?: string | null,\n code?: T,\n details?: MetaAgErrorDetails<T>,\n ): asserts condition {\n if (!condition) {\n throw new MetaAgError(message ?? \"Assertion failed\", code, details);\n }\n }\n}\n"],"mappings":"2UAiBO,IAAKA,OACVA,EAAA,UAAY,YACZA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QACRA,EAAA,IAAM,MAJIA,OAAA,IAqKCC,EACXC,GAEAA,EAAS,OAAS,aAClBA,EAAS,OAAS,SAClBA,EAAS,OAAS,QAEPC,EACXD,GACgCA,EAAS,OAAS,MClL7C,IAAME,EACX,qEACWC,EACX,qEACWC,EACX,qEACWC,EACX,qEACWC,EACX,qECkBK,IAAMC,EAAN,MAAMC,UAA+C,KAAM,CAGhE,YAAYC,EAAiBC,EAAUC,EAAiC,CACtE,MAAMF,CAAO,EACb,KAAK,KAAO,cACZ,KAAK,KAAOC,GAAS,IACrB,KAAK,QAAUC,CACjB,CAEA,OAAO,OACLC,EACAH,EACAC,EACAC,EACmB,CACnB,GAAI,CAACC,EACH,MAAM,IAAIJ,EAAYC,GAAW,mBAAoBC,EAAMC,CAAO,CAEtE,CACF","names":["EProvider","isAggregatorProvider","provider","isSwapAPIProvider","_7K_META_PUBLISHED_AT","_7K_META_PACKAGE_ID","_7K_META_VAULT","_7K_META_CONFIG","_7K_PARTNER_ADDRESS","MetaAgError","_MetaAgError","message","code","details","condition"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var s=e=>{throw TypeError(e)};var n=(e,t,r)=>t.has(e)||s("Cannot "+r);var d=(e,t,r)=>(n(e,t,"read from private field"),r?r.call(e):t.get(e)),u= exports.b =(e,t,r)=>t.has(e)?s("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),O= exports.c =(e,t,r,o)=>(n(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var p=(i=>(i.BLUEFIN7K="bluefin7k",i.CETUS="cetus",i.FLOWX="flowx",i.OKX="okx",i))(p||{}),P= exports.e =e=>e.kind==="bluefin7k"||e.kind==="cetus"||e.kind==="flowx",g= exports.f =e=>e.kind==="okx";var E="0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302",l= exports.h ="0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302",x= exports.i ="0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c",T= exports.j ="0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56",v= exports.k ="0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";var a=class e extends Error{constructor(t,r,o){super(t),this.name="MetaAgError",this.code=_nullishCoalesce(r, () => (1e3)),this.details=o}static assert(t,r,o,i){if(!t)throw new e(_nullishCoalesce(r, () => ("Assertion failed")),o,i)}};exports.a = d; exports.b = u; exports.c = O; exports.d = p; exports.e = P; exports.f = g; exports.g = E; exports.h = l; exports.i = x; exports.j = T; exports.k = v; exports.l = a;
|
|
2
|
+
//# sourceMappingURL=chunk-KVGSSW22.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/otis/Documents/7k-ts-sdk/dist/chunk-KVGSSW22.js","../src/types/metaAg.ts","../src/constants/_7k.ts","../src/features/metaAg/error.ts"],"names":["EProvider","isAggregatorProvider","provider","isSwapAPIProvider","_7K_META_PUBLISHED_AT","_7K_META_PACKAGE_ID","_7K_META_VAULT","_7K_META_CONFIG","_7K_PARTNER_ADDRESS","MetaAgError","_MetaAgError","message","code","details","condition"],"mappings":"AAAA,iLAAI,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mDAAmD,CAAC,CAAC,EAAE,WAAW,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCiBnU,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CACRA,CAAAA,CAAA,KAAA,CAAQ,OAAA,CACRA,CAAAA,CAAA,GAAA,CAAM,KAAA,CAJIA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAqKCC,CAAAA,aACXC,CAAAA,EAEAA,CAAAA,CAAS,IAAA,GAAS,WAAA,EAClBA,CAAAA,CAAS,IAAA,GAAS,OAAA,EAClBA,CAAAA,CAAS,IAAA,GAAS,OAAA,CAEPC,CAAAA,aACXD,CAAAA,EACgCA,CAAAA,CAAS,IAAA,GAAS,KAAA,CClL7C,IAAME,CAAAA,CACX,oEAAA,CACWC,CAAAA,aACX,oEAAA,CACWC,CAAAA,aACX,oEAAA,CACWC,CAAAA,aACX,oEAAA,CACWC,CAAAA,aACX,oEAAA,CCkBK,IAAMC,CAAAA,CAAN,MAAMC,EAAAA,QAA+C,KAAM,CAGhE,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAUC,CAAAA,CAAiC,CACtE,KAAA,CAAMF,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,aAAA,CACZ,IAAA,CAAK,IAAA,kBAAOC,CAAAA,SAAS,KAAA,CACrB,IAAA,CAAK,OAAA,CAAUC,CACjB,CAEA,OAAO,MAAA,CACLC,CAAAA,CACAH,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACmB,CACnB,EAAA,CAAI,CAACC,CAAAA,CACH,MAAM,IAAIJ,CAAAA,kBAAYC,CAAAA,SAAW,oBAAA,CAAoBC,CAAAA,CAAMC,CAAO,CAEtE,CACF,CAAA,CAAA,mLAAA","file":"/Users/otis/Documents/7k-ts-sdk/dist/chunk-KVGSSW22.js","sourcesContent":[null,"import type {\n QuoteResponse,\n SourceDex,\n} from \"@bluefin-exchange/bluefin7k-aggregator-sdk\";\nimport type {\n PreSwapLpChangeParams,\n RouterDataV3,\n} from \"@cetusprotocol/aggregator-sdk\";\nimport type { AggregatorQuoter, Protocol } from \"@flowx-finance/sdk\";\nimport type { GasCostSummary } from \"@mysten/sui/client\";\nimport { SignatureWithBytes } from \"@mysten/sui/cryptography\";\nimport type {\n Transaction,\n TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { OkxSwapResponseData } from \"./okx\";\n\nexport enum EProvider {\n BLUEFIN7K = \"bluefin7k\",\n CETUS = \"cetus\",\n FLOWX = \"flowx\",\n OKX = \"okx\",\n}\ntype ProviderBaseOptions = {\n api?: string;\n apiKey?: string;\n disabled?: boolean;\n};\nexport type Bluefin7kProviderOptions = ProviderBaseOptions & {\n sources?: SourceDex[];\n excludedPools?: string[];\n targetPools?: string[];\n};\nexport type FlowxProviderOptions = ProviderBaseOptions & {\n sources?: Protocol[];\n excludePools?: string[];\n excludeSources?: Protocol[];\n maxHops?: number;\n splitDistributionPercent?: number;\n};\nexport type CetusProviderOptions = ProviderBaseOptions & {\n sources?: string[];\n splitCount?: number;\n splitAlgorithm?: string;\n splitFactor?: number;\n depth?: number;\n liquidityChanges?: PreSwapLpChangeParams[];\n};\nexport type OkxProviderOptions = Required<Omit<ProviderBaseOptions, \"api\">> & {\n api?: string;\n secretKey: string;\n apiPassphrase: string;\n projectId: string;\n};\nexport interface MetaAgOptions {\n /**If not specified, all providers will be used */\n providers?: {\n [EProvider.BLUEFIN7K]?: Bluefin7kProviderOptions;\n [EProvider.FLOWX]?: FlowxProviderOptions;\n [EProvider.CETUS]?: CetusProviderOptions;\n [EProvider.OKX]?: OkxProviderOptions;\n };\n /**Mainnet Json Rpc url, if not specified, the default mainnet url will be used */\n fullnodeUrl?: string;\n /**Hermes Api url, if not specified, the default hermes api url will be used */\n hermesApi?: string;\n /**Address to receive commission, if not specified, the commission will not be used */\n partner?: string;\n /**@default 0 */\n partnerCommissionBps?: number;\n /**@default 100 */\n slippageBps?: number;\n /**\n * Tip to support 7k\n * @default 0 */\n tipBps?: number;\n}\nexport interface MetaQuoteOptions {\n coinTypeIn: string;\n coinTypeOut: string;\n amountIn: string;\n /** Required for api-tx providers (ie: Okx) */\n signer?: string;\n /**\n * Timeout for quote operation in milliseconds\n * @default 2000ms\n */\n timeout?: number;\n}\nexport interface MetaSimulationOptions {\n sender: string;\n /**\n * Timeout for simulation operation in milliseconds\n * @default 2000ms\n */\n timeout?: number;\n /** If specify, defer the simulation that could reduce the time to display quote result, you must update the quote via the id on callback\n * else await all quote and simulation before return\n */\n onSimulated?: (payload: MetaQuote) => void;\n}\nexport interface MetaFastSwapOptions {\n /** Quote object from the quote operation */\n quote: MetaQuote;\n /** Signer address (owner of `coinIn`) */\n signer: string;\n /** If true, use the gas coin for the swap\n * @default true */\n useGasCoin?: boolean;\n /**\n * Sign the transaction bytes\n * @param txBytes - base64 transaction bytes\n * @returns - signature with bytes\n */\n signTransaction: (txBytes: string) => Promise<SignatureWithBytes>;\n}\nexport interface MetaSwapOptions {\n /** Quote object from the quote operation */\n quote: MetaQuote;\n /** Signer address (owner of `coinIn`) */\n signer: string;\n /** Transaction object to add the swap operation */\n tx: Transaction;\n /**\n * Coin object used for the swap, must be consumed completely, no `coinIn` left, user must pass the coinIn object with the balance required for the swap - ie in quote `amountIn`\n * @warning `coinIn` value must match the quote `amountIn` */\n coinIn: TransactionObjectArgument;\n}\n\nexport type FlowxQuoteResponse = Awaited<\n ReturnType<AggregatorQuoter[\"getRoutes\"]>\n>;\nexport type MetaQuote = (\n | {\n provider: EProvider.BLUEFIN7K;\n quote: QuoteResponse;\n }\n | {\n provider: EProvider.CETUS;\n quote: RouterDataV3;\n }\n | {\n provider: EProvider.FLOWX;\n quote: FlowxQuoteResponse;\n }\n | {\n provider: EProvider.OKX;\n quote: OkxSwapResponseData;\n }\n) & {\n /** uuid to keep track the quote result, used to apply simulation result on quote on callback `onSimulated`*/\n id: string;\n /** coin type: ie 0x2::sui::SUI */\n coinTypeIn: string;\n /** coin type: ie 0x2::sui::SUI */\n coinTypeOut: string;\n /** Amount in as u64 */\n amountIn: string;\n /** Amount out as u64 if there're no commission be applied to the amount out */\n rawAmountOut: string;\n /** Amount as u64 after minus any commission kind */\n amountOut: string;\n /** Simulated amount out if the transaction is executed */\n simulatedAmountOut?: string;\n /** Estimate gas consumption if the transaction is executed */\n gasUsed?: GasCostSummary;\n};\nexport interface QuoteProvider {\n readonly kind: EProvider;\n quote(_quoteOptions: MetaQuoteOptions): Promise<MetaQuote | null>;\n}\n\nexport interface SwapAPIProvider extends QuoteProvider {\n readonly kind: EProvider.OKX;\n fastSwap(options: MetaFastSwapOptions): Promise<string>;\n}\n\nexport interface AggregatorProvider extends QuoteProvider {\n readonly kind: EProvider.BLUEFIN7K | EProvider.CETUS | EProvider.FLOWX;\n swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;\n}\n\nexport const isAggregatorProvider = (\n provider: QuoteProvider,\n): provider is AggregatorProvider =>\n provider.kind === EProvider.BLUEFIN7K ||\n provider.kind === EProvider.CETUS ||\n provider.kind === EProvider.FLOWX;\n\nexport const isSwapAPIProvider = (\n provider: QuoteProvider,\n): provider is SwapAPIProvider => provider.kind === EProvider.OKX;\n","// export const _7K_PACKAGE_ID =\n// \"0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04\";\n// //legacy V4: \"0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2\";\n// //legacy V3: \"0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519\";\n// //legacy V2: \"0xa13447019cd982d6bef91cf7b46ad384a52583b1dfc2bdecf31ef0c4bd787a0f\";\n// //legacy V1: \"0xd48e7cdc9e92bec69ce3baa75578010458a0c5b2733d661a84971e8cef6806bc\";\n// export const _7K_CONFIG =\n// \"0x47442a93f7727d188ba7cb71031170d1786af70013cb7ad5115f3fe877ff0c54\";\n// //legacy v3: \"0x0f8fc23dbcc9362b72c7a4c5aa53fcefa02ebfbb83a812c8c262ccd2c076d9ee\";\n\n// export const _7K_VAULT =\n// \"0x442ad50389ed5cda6f7a6f5a7ae6361a4c05ef1d9fb2e54fbba5a268d690bfe6\";\n// //legacy v3: \"0x39a3c55742c0e011b6f65548e73cf589e1ae5e82dbfab449ca57f24c3bcd9514\";\nexport const _7K_META_PUBLISHED_AT =\n \"0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302\";\nexport const _7K_META_PACKAGE_ID =\n \"0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302\";\nexport const _7K_META_VAULT =\n \"0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c\";\nexport const _7K_META_CONFIG =\n \"0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56\";\nexport const _7K_PARTNER_ADDRESS =\n \"0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5\";\n","import { DevInspectResults } from \"@mysten/sui/client\";\nimport { EProvider, MetaQuote, MetaQuoteOptions } from \"../../types/metaAg\";\n\nexport enum MetaAgErrorCode {\n UNKNOWN = 1000,\n TIMEOUT = 1001,\n PROVIDER_NOT_FOUND = 1002,\n PROVIDER_NOT_SUPPORTED = 1003,\n INVALID_QUOTE = 1004,\n QUOTE_NOT_FOUND = 1005,\n INVALID_SIGNER_ADDRESS = 1006,\n PROVIDER_NOT_SUPPORT_SWAP = 1007,\n SIMULATION_FAILED = 1008,\n // OKX error\n OKX_FINALIZE_COMMAND_NOT_FOUND = 1100,\n}\n\nexport type MetaAgErrorDetailsMap = {\n [MetaAgErrorCode.UNKNOWN]: any;\n [MetaAgErrorCode.TIMEOUT]: { timeout: number };\n [MetaAgErrorCode.PROVIDER_NOT_FOUND]: { provider: EProvider };\n [MetaAgErrorCode.PROVIDER_NOT_SUPPORTED]: { provider: EProvider };\n [MetaAgErrorCode.INVALID_QUOTE]: {\n quote: MetaQuote;\n expectedProvider: EProvider;\n };\n [MetaAgErrorCode.QUOTE_NOT_FOUND]: {\n provider: EProvider;\n quoteOptions?: MetaQuoteOptions;\n };\n [MetaAgErrorCode.INVALID_SIGNER_ADDRESS]: { signer: string };\n [MetaAgErrorCode.PROVIDER_NOT_SUPPORT_SWAP]: { provider: EProvider };\n [MetaAgErrorCode.SIMULATION_FAILED]: { error: DevInspectResults[\"error\"] };\n // OKX error\n [MetaAgErrorCode.OKX_FINALIZE_COMMAND_NOT_FOUND]: { packageId: string };\n};\n\nexport type MetaAgErrorDetails<T extends MetaAgErrorCode> =\n T extends keyof MetaAgErrorDetailsMap ? MetaAgErrorDetailsMap[T] : never;\n\nexport class MetaAgError<T extends MetaAgErrorCode> extends Error {\n code: T;\n details?: MetaAgErrorDetails<T>;\n constructor(message: string, code?: T, details?: MetaAgErrorDetails<T>) {\n super(message);\n this.name = \"MetaAgError\";\n this.code = code ?? (MetaAgErrorCode.UNKNOWN as T);\n this.details = details;\n }\n\n static assert<T extends MetaAgErrorCode>(\n condition: any,\n message?: string | null,\n code?: T,\n details?: MetaAgErrorDetails<T>,\n ): asserts condition {\n if (!condition) {\n throw new MetaAgError(message ?? \"Assertion failed\", code, details);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKVGSSW22js = require('./chunk-KVGSSW22.js');var _sdk = require('@flowx-finance/sdk');var _uuid = require('uuid');var i=class{constructor(t,e){this.options=t;this.client=e;this.kind="flowx";this.quoter=new (0, _sdk.AggregatorQuoter)("mainnet",t.apiKey)}async quote(t){let e=await this.quoter.getRoutes({amountIn:t.amountIn,tokenIn:t.coinTypeIn,tokenOut:t.coinTypeOut,includeSources:this.options.sources,excludePools:this.options.excludePools,excludeSources:this.options.excludeSources,maxHops:this.options.maxHops,splitDistributionPercent:this.options.splitDistributionPercent});return{id:_uuid.v4.call(void 0, ),provider:"flowx",quote:e,amountIn:_nullishCoalesce(_optionalChain([e, 'access', _ => _.amountIn, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]), () => ("0")),rawAmountOut:_nullishCoalesce(_optionalChain([e, 'access', _4 => _4.amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]), () => ("0")),amountOut:_nullishCoalesce(_optionalChain([e, 'access', _7 => _7.amountOut, 'optionalAccess', _8 => _8.toString, 'call', _9 => _9()]), () => ("0")),coinTypeIn:t.coinTypeIn,coinTypeOut:t.coinTypeOut}}async swap(t){_chunkKVGSSW22js.l.assert(t.quote.provider==="flowx","Invalid quote",1004,{quote:t.quote,expectedProvider:"flowx"});let e=new (0, _sdk.TradeBuilder)("mainnet",t.quote.quote.routes);return e.sender(t.signer),e.slippage(1e4*100),e.commission(new (0, _sdk.Commission)(_chunkKVGSSW22js.k,t.quote.quote.coinOut,_sdk.CommissionType.PERCENTAGE,0,!0)),await e.build().swap({tx:t.tx,client:this.client,coinIn:t.coinIn})}};exports.FlowxProvider = i;
|
|
2
|
+
//# sourceMappingURL=flowx-6M54WFWO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/otis/Documents/7k-ts-sdk/dist/flowx-6M54WFWO.js","../src/features/metaAg/providers/flowx.ts"],"names":["FlowxProvider","options","client","AggregatorQuoter","quoteOptions","quote","v4","MetaAgError","builder","TradeBuilder","Commission","_7K_PARTNER_ADDRESS","CommissionType"],"mappings":"AAAA,uuBAA8C,yCCKvC,4BAGY,IAaNA,CAAAA,CAAN,KAAiE,CAGtE,WAAA,CACmBC,CAAAA,CACAC,CAAAA,CACjB,CAFiB,IAAA,CAAA,OAAA,CAAAD,CAAAA,CACA,IAAA,CAAA,MAAA,CAAAC,CAAAA,CAJnB,IAAA,CAAS,IAAA,CAAO,OAAA,CAMd,IAAA,CAAK,MAAA,CAAS,IAAIC,0BAAAA,CAAiB,SAAA,CAAWF,CAAAA,CAAQ,MAAM,CAC9D,CAEA,MAAM,KAAA,CAAMG,CAAAA,CAAoD,CAC9D,IAAMC,CAAAA,CAAQ,MAAM,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,CACxC,QAAA,CAAUD,CAAAA,CAAa,QAAA,CACvB,OAAA,CAASA,CAAAA,CAAa,UAAA,CACtB,QAAA,CAAUA,CAAAA,CAAa,WAAA,CACvB,cAAA,CAAgB,IAAA,CAAK,OAAA,CAAQ,OAAA,CAC7B,YAAA,CAAc,IAAA,CAAK,OAAA,CAAQ,YAAA,CAC3B,cAAA,CAAgB,IAAA,CAAK,OAAA,CAAQ,cAAA,CAC7B,OAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,OAAA,CACtB,wBAAA,CAA0B,IAAA,CAAK,OAAA,CAAQ,wBACzC,CAAC,CAAA,CACD,MAAO,CACL,EAAA,CAAIE,sBAAAA,CAAG,CACP,QAAA,CAAA,OAAA,CACA,KAAA,CAAOD,CAAAA,CACP,QAAA,kCAAUA,CAAAA,mBAAM,QAAA,6BAAU,QAAA,mBAAS,GAAA,SAAK,KAAA,CACxC,YAAA,kCAAcA,CAAAA,qBAAM,SAAA,6BAAW,QAAA,mBAAS,GAAA,SAAK,KAAA,CAC7C,SAAA,kCAAWA,CAAAA,qBAAM,SAAA,6BAAW,QAAA,mBAAS,GAAA,SAAK,KAAA,CAC1C,UAAA,CAAYD,CAAAA,CAAa,UAAA,CACzB,WAAA,CAAaA,CAAAA,CAAa,WAC5B,CACF,CAEA,MAAM,IAAA,CAAKH,CAAAA,CAA8D,CACvEM,kBAAAA,CAAY,MAAA,CACVN,CAAAA,CAAQ,KAAA,CAAM,QAAA,GAAa,OAAA,CAC3B,eAAA,CAAA,IAAA,CAEA,CAAE,KAAA,CAAOA,CAAAA,CAAQ,KAAA,CAAO,gBAAA,CAAA,OAAkC,CAC5D,CAAA,CACA,IAAMO,CAAAA,CAAU,IAAIC,sBAAAA,CAAa,SAAA,CAAWR,CAAAA,CAAQ,KAAA,CAAM,KAAA,CAAM,MAAM,CAAA,CACtE,OAAAO,CAAAA,CAAQ,MAAA,CAAOP,CAAAA,CAAQ,MAAM,CAAA,CAC7BO,CAAAA,CAAQ,QAAA,CAAS,GAAA,CAAQ,GAAG,CAAA,CAC5BA,CAAAA,CAAQ,UAAA,CACN,IAAIE,oBAAAA,CACFC,kBAAAA,CACAV,CAAAA,CAAQ,KAAA,CAAM,KAAA,CAAM,OAAA,CACpBW,mBAAAA,CAAe,UAAA,CACf,CAAA,CACA,CAAA,CACF,CACF,CAAA,CACY,MAAMJ,CAAAA,CAAQ,KAAA,CAAM,CAAA,CAAE,IAAA,CAAK,CACrC,EAAA,CAAIP,CAAAA,CAAQ,EAAA,CACZ,MAAA,CAAQ,IAAA,CAAK,MAAA,CACb,MAAA,CAAQA,CAAAA,CAAQ,MAClB,CAAC,CAEH,CACF,CAAA,CAAA,0BAAA","file":"/Users/otis/Documents/7k-ts-sdk/dist/flowx-6M54WFWO.js","sourcesContent":[null,"import {\n AggregatorQuoter,\n Commission,\n CommissionType,\n TradeBuilder,\n} from \"@flowx-finance/sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { TransactionObjectArgument } from \"@mysten/sui/transactions\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n EProvider,\n FlowxProviderOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class FlowxProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.FLOWX;\n private quoter: AggregatorQuoter;\n constructor(\n private readonly options: FlowxProviderOptions,\n private readonly client: SuiClient,\n ) {\n this.quoter = new AggregatorQuoter(\"mainnet\", options.apiKey);\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await this.quoter.getRoutes({\n amountIn: quoteOptions.amountIn,\n tokenIn: quoteOptions.coinTypeIn,\n tokenOut: quoteOptions.coinTypeOut,\n includeSources: this.options.sources,\n excludePools: this.options.excludePools,\n excludeSources: this.options.excludeSources,\n maxHops: this.options.maxHops,\n splitDistributionPercent: this.options.splitDistributionPercent,\n });\n return {\n id: v4(),\n provider: EProvider.FLOWX,\n quote: quote,\n amountIn: quote.amountIn?.toString() ?? \"0\",\n rawAmountOut: quote.amountOut?.toString() ?? \"0\",\n amountOut: quote.amountOut?.toString() ?? \"0\",\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap(options: MetaSwapOptions): Promise<TransactionObjectArgument> {\n MetaAgError.assert(\n options.quote.provider === EProvider.FLOWX,\n \"Invalid quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote: options.quote, expectedProvider: EProvider.FLOWX },\n );\n const builder = new TradeBuilder(\"mainnet\", options.quote.quote.routes);\n builder.sender(options.signer);\n builder.slippage(10000 * 100);\n builder.commission(\n new Commission(\n _7K_PARTNER_ADDRESS,\n options.quote.quote.coinOut,\n CommissionType.PERCENTAGE,\n 0,\n true,\n ),\n );\n const res = await builder.build().swap({\n tx: options.tx as any,\n client: this.client as any,\n coinIn: options.coinIn as any,\n });\n return res!;\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{k as o,l as r}from"./chunk-ETQEI4QC.mjs";import{AggregatorQuoter as n,Commission as u,CommissionType as a,TradeBuilder as s}from"@flowx-finance/sdk";import{v4 as m}from"uuid";var i=class{constructor(t,e){this.options=t;this.client=e;this.kind="flowx";this.quoter=new n("mainnet",t.apiKey)}async quote(t){let e=await this.quoter.getRoutes({amountIn:t.amountIn,tokenIn:t.coinTypeIn,tokenOut:t.coinTypeOut,includeSources:this.options.sources,excludePools:this.options.excludePools,excludeSources:this.options.excludeSources,maxHops:this.options.maxHops,splitDistributionPercent:this.options.splitDistributionPercent});return{id:m(),provider:"flowx",quote:e,amountIn:e.amountIn?.toString()??"0",rawAmountOut:e.amountOut?.toString()??"0",amountOut:e.amountOut?.toString()??"0",coinTypeIn:t.coinTypeIn,coinTypeOut:t.coinTypeOut}}async swap(t){r.assert(t.quote.provider==="flowx","Invalid quote",1004,{quote:t.quote,expectedProvider:"flowx"});let e=new s("mainnet",t.quote.quote.routes);return e.sender(t.signer),e.slippage(1e4*100),e.commission(new u(o,t.quote.quote.coinOut,a.PERCENTAGE,0,!0)),await e.build().swap({tx:t.tx,client:this.client,coinIn:t.coinIn})}};export{i as FlowxProvider};
|
|
2
|
+
//# sourceMappingURL=flowx-OXZZX5FD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/metaAg/providers/flowx.ts"],"sourcesContent":["import {\n AggregatorQuoter,\n Commission,\n CommissionType,\n TradeBuilder,\n} from \"@flowx-finance/sdk\";\nimport { SuiClient } from \"@mysten/sui/client\";\nimport { TransactionObjectArgument } from \"@mysten/sui/transactions\";\nimport { v4 } from \"uuid\";\nimport { _7K_PARTNER_ADDRESS } from \"../../../constants/_7k\";\nimport {\n AggregatorProvider,\n EProvider,\n FlowxProviderOptions,\n MetaQuote,\n MetaQuoteOptions,\n MetaSwapOptions,\n QuoteProvider,\n} from \"../../../types/metaAg\";\nimport { MetaAgError, MetaAgErrorCode } from \"../error\";\n\nexport class FlowxProvider implements QuoteProvider, AggregatorProvider {\n readonly kind = EProvider.FLOWX;\n private quoter: AggregatorQuoter;\n constructor(\n private readonly options: FlowxProviderOptions,\n private readonly client: SuiClient,\n ) {\n this.quoter = new AggregatorQuoter(\"mainnet\", options.apiKey);\n }\n\n async quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote> {\n const quote = await this.quoter.getRoutes({\n amountIn: quoteOptions.amountIn,\n tokenIn: quoteOptions.coinTypeIn,\n tokenOut: quoteOptions.coinTypeOut,\n includeSources: this.options.sources,\n excludePools: this.options.excludePools,\n excludeSources: this.options.excludeSources,\n maxHops: this.options.maxHops,\n splitDistributionPercent: this.options.splitDistributionPercent,\n });\n return {\n id: v4(),\n provider: EProvider.FLOWX,\n quote: quote,\n amountIn: quote.amountIn?.toString() ?? \"0\",\n rawAmountOut: quote.amountOut?.toString() ?? \"0\",\n amountOut: quote.amountOut?.toString() ?? \"0\",\n coinTypeIn: quoteOptions.coinTypeIn,\n coinTypeOut: quoteOptions.coinTypeOut,\n };\n }\n\n async swap(options: MetaSwapOptions): Promise<TransactionObjectArgument> {\n MetaAgError.assert(\n options.quote.provider === EProvider.FLOWX,\n \"Invalid quote\",\n MetaAgErrorCode.INVALID_QUOTE,\n { quote: options.quote, expectedProvider: EProvider.FLOWX },\n );\n const builder = new TradeBuilder(\"mainnet\", options.quote.quote.routes);\n builder.sender(options.signer);\n builder.slippage(10000 * 100);\n builder.commission(\n new Commission(\n _7K_PARTNER_ADDRESS,\n options.quote.quote.coinOut,\n CommissionType.PERCENTAGE,\n 0,\n true,\n ),\n );\n const res = await builder.build().swap({\n tx: options.tx as any,\n client: this.client as any,\n coinIn: options.coinIn as any,\n });\n return res!;\n }\n}\n"],"mappings":"gDAAA,OACE,oBAAAA,EACA,cAAAC,EACA,kBAAAC,EACA,gBAAAC,MACK,qBAGP,OAAS,MAAAC,MAAU,OAaZ,IAAMC,EAAN,KAAiE,CAGtE,YACmBC,EACAC,EACjB,CAFiB,aAAAD,EACA,YAAAC,EAJnB,KAAS,KAAO,QAMd,KAAK,OAAS,IAAIC,EAAiB,UAAWF,EAAQ,MAAM,CAC9D,CAEA,MAAM,MAAMG,EAAoD,CAC9D,IAAMC,EAAQ,MAAM,KAAK,OAAO,UAAU,CACxC,SAAUD,EAAa,SACvB,QAASA,EAAa,WACtB,SAAUA,EAAa,YACvB,eAAgB,KAAK,QAAQ,QAC7B,aAAc,KAAK,QAAQ,aAC3B,eAAgB,KAAK,QAAQ,eAC7B,QAAS,KAAK,QAAQ,QACtB,yBAA0B,KAAK,QAAQ,wBACzC,CAAC,EACD,MAAO,CACL,GAAIE,EAAG,EACP,iBACA,MAAOD,EACP,SAAUA,EAAM,UAAU,SAAS,GAAK,IACxC,aAAcA,EAAM,WAAW,SAAS,GAAK,IAC7C,UAAWA,EAAM,WAAW,SAAS,GAAK,IAC1C,WAAYD,EAAa,WACzB,YAAaA,EAAa,WAC5B,CACF,CAEA,MAAM,KAAKH,EAA8D,CACvEM,EAAY,OACVN,EAAQ,MAAM,WAAa,QAC3B,qBAEA,CAAE,MAAOA,EAAQ,MAAO,wBAAkC,CAC5D,EACA,IAAMO,EAAU,IAAIC,EAAa,UAAWR,EAAQ,MAAM,MAAM,MAAM,EACtE,OAAAO,EAAQ,OAAOP,EAAQ,MAAM,EAC7BO,EAAQ,SAAS,IAAQ,GAAG,EAC5BA,EAAQ,WACN,IAAIE,EACFC,EACAV,EAAQ,MAAM,MAAM,QACpBW,EAAe,WACf,EACA,EACF,CACF,EACY,MAAMJ,EAAQ,MAAM,EAAE,KAAK,CACrC,GAAIP,EAAQ,GACZ,OAAQ,KAAK,OACb,OAAQA,EAAQ,MAClB,CAAC,CAEH,CACF","names":["AggregatorQuoter","Commission","CommissionType","TradeBuilder","v4","FlowxProvider","options","client","AggregatorQuoter","quoteOptions","quote","v4","MetaAgError","builder","TradeBuilder","Commission","_7K_PARTNER_ADDRESS","CommissionType"]}
|