@7kprotocol/sdk-ts 3.4.2-beta.9 → 3.5.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 +45 -171
- package/lib/cjs/constants/_7k.js +2 -1
- package/lib/cjs/features/metaAg/index.js +13 -8
- package/lib/cjs/features/metaAg/providers/bluefin.js +4 -6
- package/lib/cjs/features/metaAg/providers/cetus.js +6 -14
- package/lib/cjs/features/metaAg/providers/flowx.js +4 -8
- package/lib/cjs/types/constants/_7k.d.ts +1 -0
- package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +0 -1
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +2 -3
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/cjs/types/types/metaAg.d.ts +9 -9
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/constants/_7k.js +1 -0
- package/lib/esm/features/metaAg/index.js +13 -8
- package/lib/esm/features/metaAg/providers/bluefin.js +4 -6
- package/lib/esm/features/metaAg/providers/cetus.js +6 -15
- package/lib/esm/features/metaAg/providers/flowx.js +4 -9
- package/lib/esm/types/constants/_7k.d.ts +1 -0
- package/lib/esm/types/constants/_7k.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +0 -1
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +2 -3
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/esm/types/types/metaAg.d.ts +9 -9
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# 7K TypeScript SDK
|
|
2
2
|
|
|
3
|
+
The 7K Protocol TypeScript SDK provides a comprehensive toolkit for interacting
|
|
4
|
+
with DeFi services on the Sui blockchain. It offers seamless integration with
|
|
5
|
+
token swaps, price feeds, limit orders, dollar-cost averaging (DCA), and
|
|
6
|
+
multi-provider aggregation services.
|
|
7
|
+
|
|
8
|
+
## Introduction
|
|
9
|
+
|
|
10
|
+
The 7K TypeScript SDK is designed to simplify DeFi development on Sui by
|
|
11
|
+
providing a unified, type-safe interface for accessing liquidity and trading
|
|
12
|
+
services. Whether you're building a wallet, trading application, or DeFi
|
|
13
|
+
protocol, this SDK offers the tools you need to integrate advanced trading
|
|
14
|
+
functionality.
|
|
15
|
+
|
|
16
|
+
Key features:
|
|
17
|
+
|
|
18
|
+
- **Meta Aggregator (Active Simulation)**: The SDK includes an active simulation
|
|
19
|
+
of the Meta Aggregator, allowing developers to test and compare quotes from
|
|
20
|
+
multiple sources — including Bluefin7K, FlowX, and Cetus. This provides a
|
|
21
|
+
preview of how the unified aggregator will optimize routing and liquidity
|
|
22
|
+
aggregation across providers.
|
|
23
|
+
|
|
24
|
+
➤ Additional aggregators and RFQ-based liquidity sources are planned for
|
|
25
|
+
integration in future releases.
|
|
26
|
+
|
|
27
|
+
- **Price Service**: Fetch token prices with support for single tokens and batch
|
|
28
|
+
queries
|
|
29
|
+
- **Limit Orders**: Place and manage limit orders for token swaps
|
|
30
|
+
- **DCA Orders**: Set up dollar-cost averaging strategies for automated
|
|
31
|
+
recurring purchases
|
|
32
|
+
- **BluefinX Integration**: Access RFQ-based trading with sponsored transactions
|
|
33
|
+
and MEV protection
|
|
34
|
+
- **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
35
|
+
- **Mainnet Support**: Production-ready SDK for Sui mainnet
|
|
36
|
+
- **Flexible Configuration**: Customize API keys, slippage, commissions, and
|
|
37
|
+
more
|
|
38
|
+
|
|
39
|
+
The SDK is built with developer experience in mind, providing both a default
|
|
40
|
+
export for convenience and named exports for tree-shaking and modular
|
|
41
|
+
development.
|
|
42
|
+
|
|
3
43
|
## Installation
|
|
4
44
|
|
|
5
45
|
```bash
|
|
@@ -12,7 +52,7 @@ This package has peer dependencies that are required for core functionality:
|
|
|
12
52
|
|
|
13
53
|
| Package | Version | Purpose | Required For |
|
|
14
54
|
| -------------------------- | --------- | ---------------------------- | ------------------ |
|
|
15
|
-
| `@mysten/sui` | `^1.
|
|
55
|
+
| `@mysten/sui` | `^1.44.0` | Sui blockchain interaction | Core functionality |
|
|
16
56
|
| `@pythnetwork/pyth-sui-js` | `^2.2.0` | Pyth price feeds integration | Price feeds |
|
|
17
57
|
|
|
18
58
|
**Required peer dependencies:**
|
|
@@ -75,65 +115,11 @@ or import specific functions as needed:
|
|
|
75
115
|
import { getQuote, buildTx } from "@7kprotocol/sdk-ts";
|
|
76
116
|
```
|
|
77
117
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Configuration is optional, but if provided, it must be set before invoking any
|
|
81
|
-
SDK functions.
|
|
82
|
-
|
|
83
|
-
### Set API Key
|
|
84
|
-
|
|
85
|
-
You can use our SDK with a default rate limit of **5 requests per second**
|
|
86
|
-
without needing an API key.
|
|
87
|
-
|
|
88
|
-
- For **frontend (in-browser) usage**, no API key is required, and the rate
|
|
89
|
-
limit cannot be increased.
|
|
90
|
-
|
|
91
|
-
- For **backend (server-side) usage**, the API key is **optional** for default
|
|
92
|
-
usage. However, to request a **higher rate limit**, you must provide both an
|
|
93
|
-
**API key** and **partner information**.
|
|
94
|
-
|
|
95
|
-
To request a rate limit increase, please submit your request at:
|
|
96
|
-
|
|
97
|
-
🔗 <https://7k.ag/collab> and select **"SDK - increase request rate"**.
|
|
98
|
-
|
|
99
|
-
| Usage | API Key Required | Default Rate Limit | Can Request Higher Rate Limit |
|
|
100
|
-
| -------- | ------------------------------------- | ------------------------------- | -------------------------------------------- |
|
|
101
|
-
| Frontend | No | 5 requests/second | No |
|
|
102
|
-
| Backend | Optional (required to increase limit) | 5 requests/second (without key) | Yes (requires API Key & partner information) |
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
import { Config } from "@7kprotocol/sdk-ts";
|
|
106
|
-
|
|
107
|
-
Config.setApiKey("YOUR_API_KEY");
|
|
108
|
-
console.log("API key", Config.getApiKey());
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Set BluefinX API key
|
|
112
|
-
|
|
113
|
-
Setting a BluefinX API key is optional. However, if you'd like to use one — for
|
|
114
|
-
example, to avoid rate limits when routing through BluefinX — you'll need to
|
|
115
|
-
request an API key directly from Bluefin.
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import { Config } from "@7kprotocol/sdk-ts";
|
|
119
|
-
|
|
120
|
-
Config.setBluefinXApiKey("YOUR_BLUEFINX_API_KEY");
|
|
121
|
-
console.log("BluefinX API key", Config.getBluefinXApiKey());
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Set Sui Client
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
import { SuiClient, getFullnodeUrl } from "@mysten/sui/client";
|
|
128
|
-
import { Config } from "@7kprotocol/sdk-ts";
|
|
118
|
+
Note: this package only supports **mainnet**.
|
|
129
119
|
|
|
130
|
-
|
|
131
|
-
const suiClient = new SuiClient({ url: getFullnodeUrl(network) });
|
|
132
|
-
Config.setSuiClient(suiClient);
|
|
133
|
-
console.log("Sui client", Config.getSuiClient());
|
|
134
|
-
```
|
|
120
|
+
## MetaAg (Multi-Provider Aggregation)
|
|
135
121
|
|
|
136
|
-
|
|
122
|
+
See [Meta Aggregator](docs/META_AG.md).
|
|
137
123
|
|
|
138
124
|
## Swap
|
|
139
125
|
|
|
@@ -151,121 +137,9 @@ See [Limit Orders](docs/LIMIT.md).
|
|
|
151
137
|
|
|
152
138
|
See [DCA Orders](docs/DCA.md).
|
|
153
139
|
|
|
154
|
-
## MetaAg (Multi-Provider Aggregation)
|
|
155
|
-
|
|
156
|
-
The MetaAg feature allows you to aggregate quotes from multiple DEX Aggregator
|
|
157
|
-
providers. By default, all available providers are enabled. You can optionally
|
|
158
|
-
configure specific providers or install optional dependencies to enable
|
|
159
|
-
additional providers.
|
|
160
|
-
|
|
161
|
-
### Using Default Providers
|
|
162
|
-
|
|
163
|
-
The Bluefin7K provider is built-in and works without additional dependencies:
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
import { MetaAg, EProvider } from "@7kprotocol/sdk-ts";
|
|
167
|
-
|
|
168
|
-
const metaAg = new MetaAg();
|
|
169
|
-
|
|
170
|
-
// Get quotes from all available providers
|
|
171
|
-
const quotes = await metaAg.quote({
|
|
172
|
-
amountIn: "1000000000", // 1 SUI (9 decimals)
|
|
173
|
-
coinInType:
|
|
174
|
-
"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
175
|
-
coinOutType:
|
|
176
|
-
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// Find the best quote
|
|
180
|
-
const bestQuote = quotes.reduce((best, current) =>
|
|
181
|
-
Number(current.amountOut) > Number(best.amountOut) ? current : best,
|
|
182
|
-
);
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Configuring Specific Providers
|
|
186
|
-
|
|
187
|
-
You can configure specific providers and their options:
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
const metaAg = new MetaAg({
|
|
191
|
-
providers: {
|
|
192
|
-
[EProvider.BLUEFIN7K]: {
|
|
193
|
-
apiKey: "your-bluefin-api-key", // Optional
|
|
194
|
-
},
|
|
195
|
-
[EProvider.FLOWX]: {
|
|
196
|
-
apiKey: "your-flowx-api-key", // Optional
|
|
197
|
-
},
|
|
198
|
-
[EProvider.CETUS]: {
|
|
199
|
-
apiKey: "your-cetus-api-key", // Optional
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Note**: To use Flowx or Cetus providers, you must install their respective
|
|
206
|
-
optional dependencies. See the
|
|
207
|
-
[Optional Dependencies](#optional-dependencies-for-metaag-providers) section
|
|
208
|
-
above.
|
|
209
|
-
|
|
210
|
-
### Sponsored Transactions
|
|
211
|
-
|
|
212
|
-
When building sponsored transactions, `tx.gas` can not be used for swap.
|
|
213
|
-
|
|
214
|
-
**Important considerations:**
|
|
215
|
-
|
|
216
|
-
1. **Gas coin usage**: Set `useGasCoin: false` when creating your coin input
|
|
217
|
-
object to prevent the SDK from trying to use `tx.gas`.
|
|
218
|
-
|
|
219
|
-
2. **Pyth oracle dependencies**: Transactions that use the gas coin cannot be
|
|
220
|
-
sponsored because Pyth oracle fees are paid from `tx.gas`. Exclude DEX
|
|
221
|
-
sources that depend on Pyth oracles.
|
|
222
|
-
|
|
223
|
-
**Example configuration:**
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
import { MetaAg, EProvider } from "@7kprotocol/sdk-ts";
|
|
227
|
-
import { coinWithBalance } from "@mysten/sui/transactions";
|
|
228
|
-
import { Protocol } from "@flowx-finance/sdk"; // Required for Flowx sources
|
|
229
|
-
import { CETUS, BLUEFIN } from "@cetusprotocol/aggregator-sdk
|
|
230
|
-
|
|
231
|
-
const metaAg = new MetaAg({
|
|
232
|
-
providers: {
|
|
233
|
-
[EProvider.BLUEFIN7K]: {
|
|
234
|
-
sources: ["cetus", "bluefin"], // Excludes Pyth oracle-based DEX
|
|
235
|
-
},
|
|
236
|
-
[EProvider.FLOWX]: {
|
|
237
|
-
sources: [Protocol.BLUEFIN, Protocol.CETUS, Protocol.FLOWX_V3],
|
|
238
|
-
},
|
|
239
|
-
[EProvider.CETUS]: {
|
|
240
|
-
sources: [CETUS, BLUEFIN],
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// Create coin input WITHOUT using the gas coin
|
|
246
|
-
const coinIn = coinWithBalance({
|
|
247
|
-
balance: 1000000000n, // 1 SUI
|
|
248
|
-
type: "0x2::sui::SUI",
|
|
249
|
-
useGasCoin: false, // Important: must be false for sponsored transactions
|
|
250
|
-
});
|
|
251
|
-
```
|
|
252
|
-
|
|
253
140
|
## Prices
|
|
254
141
|
|
|
255
|
-
|
|
256
|
-
import { getTokenPrice, getTokenPrices, getSuiPrice } from "@7kprotocol/sdk-ts";
|
|
257
|
-
|
|
258
|
-
const tokenPrice = await getTokenPrice(
|
|
259
|
-
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
const tokenPrices = await getTokenPrices([
|
|
263
|
-
"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
264
|
-
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
265
|
-
]);
|
|
266
|
-
|
|
267
|
-
const suiPrice = await getSuiPrice();
|
|
268
|
-
```
|
|
142
|
+
See [Prices](docs/PRICE.md).
|
|
269
143
|
|
|
270
144
|
## Miscellaneous
|
|
271
145
|
|
package/lib/cjs/constants/_7k.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._7K_META_CONFIG = exports._7K_META_VAULT = exports._7K_META_PACKAGE_ID = exports._7K_META_PUBLISHED_AT = exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
3
|
+
exports._7K_PARTNER_ADDRESS = exports._7K_META_CONFIG = exports._7K_META_VAULT = exports._7K_META_PACKAGE_ID = exports._7K_META_PUBLISHED_AT = exports._7K_VAULT = exports._7K_CONFIG = exports._7K_PACKAGE_ID = void 0;
|
|
4
4
|
exports._7K_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
|
|
5
5
|
//legacy V4: "0xe8f996ea6ff38c557c253d3b93cfe2ebf393816487266786371aa4532a9229f2";
|
|
6
6
|
//legacy V3: "0x7ea6e27ad7af6f3b8671d59df1aaebd7c03dddab893e52a714227b2f4fe91519";
|
|
@@ -14,3 +14,4 @@ exports._7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270c
|
|
|
14
14
|
exports._7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
15
15
|
exports._7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
16
16
|
exports._7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
|
|
17
|
+
exports._7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
|
|
@@ -54,7 +54,7 @@ class MetaAg {
|
|
|
54
54
|
constructor(options) {
|
|
55
55
|
this.providers = {};
|
|
56
56
|
this.options = {
|
|
57
|
-
providers: options?.providers
|
|
57
|
+
providers: { ...DEFAULT_PROVIDERS, ...options?.providers },
|
|
58
58
|
slippageBps: options?.slippageBps ?? 100,
|
|
59
59
|
fullnodeUrl: options?.fullnodeUrl ?? (0, client_1.getFullnodeUrl)("mainnet"),
|
|
60
60
|
hermesApi: options?.hermesApi ?? HERMES_API,
|
|
@@ -73,14 +73,13 @@ class MetaAg {
|
|
|
73
73
|
return p;
|
|
74
74
|
const providerOptions = this.options.providers[provider];
|
|
75
75
|
(0, condition_1.assert)(!!providerOptions, `Provider not found: ${provider}`);
|
|
76
|
-
// eslint-disable-next-line no-case-declarations
|
|
77
76
|
switch (provider) {
|
|
78
77
|
case metaAg_1.EProvider.BLUEFIN7K:
|
|
79
78
|
this.providers[metaAg_1.EProvider.BLUEFIN7K] = new bluefin_1.BluefinProvider(providerOptions, this.options, this.client);
|
|
80
79
|
break;
|
|
81
80
|
case metaAg_1.EProvider.FLOWX:
|
|
82
81
|
const { FlowxProvider } = await Promise.resolve().then(() => __importStar(require("./providers/flowx"))).catch(catchImportError(metaAg_1.EProvider.FLOWX));
|
|
83
|
-
this.providers[metaAg_1.EProvider.FLOWX] = new FlowxProvider(providerOptions, this.
|
|
82
|
+
this.providers[metaAg_1.EProvider.FLOWX] = new FlowxProvider(providerOptions, this.client);
|
|
84
83
|
break;
|
|
85
84
|
case metaAg_1.EProvider.CETUS:
|
|
86
85
|
const { CetusProvider } = await Promise.resolve().then(() => __importStar(require("./providers/cetus"))).catch(catchImportError(metaAg_1.EProvider.CETUS));
|
|
@@ -127,7 +126,12 @@ class MetaAg {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
async _quote(provider, options, simulation) {
|
|
130
|
-
const quote = await timeout(() =>
|
|
129
|
+
const quote = await timeout(async () => {
|
|
130
|
+
const quote = await provider.quote(options);
|
|
131
|
+
const { expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
|
|
132
|
+
quote.amountOut = expectedAmount;
|
|
133
|
+
return quote;
|
|
134
|
+
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinInType} to ${options.coinOutType}`);
|
|
131
135
|
if (simulation) {
|
|
132
136
|
if (simulation.onSimulated) {
|
|
133
137
|
this._simulate(provider, quote, simulation).then((payload) => {
|
|
@@ -156,7 +160,9 @@ class MetaAg {
|
|
|
156
160
|
coinInType: (0, utils_1.normalizeStructTag)(options.coinInType),
|
|
157
161
|
coinOutType: (0, utils_1.normalizeStructTag)(options.coinOutType),
|
|
158
162
|
};
|
|
159
|
-
const quotes = await Promise.allSettled(Object.
|
|
163
|
+
const quotes = await Promise.allSettled(Object.entries(this.options.providers)
|
|
164
|
+
.filter(([_k, v]) => !v.disabled)
|
|
165
|
+
.map(async ([provider]) => {
|
|
160
166
|
const p = await this._getProvider(provider);
|
|
161
167
|
return this._quote(p, opts, simulation);
|
|
162
168
|
}));
|
|
@@ -223,8 +229,7 @@ exports.MetaAg = MetaAg;
|
|
|
223
229
|
*/
|
|
224
230
|
const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
|
|
225
231
|
return (tx) => {
|
|
226
|
-
const { minAmount, expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.rawAmountOut, slippageBps, commissionBps,
|
|
227
|
-
tipBps);
|
|
232
|
+
const { minAmount, expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
|
|
228
233
|
if (tipBps > 0) {
|
|
229
234
|
tx.moveCall({
|
|
230
235
|
target: `${_7k_1._7K_META_PUBLISHED_AT}::vault::collect_tip`,
|
|
@@ -248,7 +253,7 @@ const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, comm
|
|
|
248
253
|
tx.pure.u64(minAmount),
|
|
249
254
|
tx.pure.u64(expectedAmount),
|
|
250
255
|
tx.pure.option("address", partner),
|
|
251
|
-
tx.pure.u64(
|
|
256
|
+
tx.pure.u64(commissionBps),
|
|
252
257
|
tx.pure.u64(0), // ps
|
|
253
258
|
],
|
|
254
259
|
});
|
|
@@ -4,11 +4,10 @@ exports.BluefinProvider = void 0;
|
|
|
4
4
|
const pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
6
|
const config_1 = require("../../../config");
|
|
7
|
+
const _7k_1 = require("../../../constants/_7k");
|
|
7
8
|
const apiEndpoints_1 = require("../../../constants/apiEndpoints");
|
|
8
|
-
const sui_1 = require("../../../constants/sui");
|
|
9
9
|
const metaAg_1 = require("../../../types/metaAg");
|
|
10
10
|
const condition_1 = require("../../../utils/condition");
|
|
11
|
-
const buildTx_1 = require("../../swap/buildTx");
|
|
12
11
|
const buildTxV2_1 = require("../../swap/buildTxV2");
|
|
13
12
|
const getQuote_1 = require("../../swap/getQuote");
|
|
14
13
|
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
@@ -37,14 +36,13 @@ class BluefinProvider {
|
|
|
37
36
|
excludedPools: this.options.excludedPools,
|
|
38
37
|
targetPools: this.options.targetPools,
|
|
39
38
|
});
|
|
40
|
-
const { expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.returnAmountWithDecimal.toString(), 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
41
39
|
return {
|
|
42
40
|
id: (0, uuid_1.v4)(),
|
|
43
41
|
provider: metaAg_1.EProvider.BLUEFIN7K,
|
|
44
42
|
quote,
|
|
45
43
|
amountIn: quote.swapAmountWithDecimal,
|
|
46
44
|
rawAmountOut: quote.returnAmountWithDecimal,
|
|
47
|
-
amountOut:
|
|
45
|
+
amountOut: quote.returnAmountWithDecimal,
|
|
48
46
|
coinTypeIn: options.coinInType,
|
|
49
47
|
coinTypeOut: options.coinOutType,
|
|
50
48
|
};
|
|
@@ -55,8 +53,8 @@ class BluefinProvider {
|
|
|
55
53
|
quoteResponse: quote.quote,
|
|
56
54
|
accountAddress: signer,
|
|
57
55
|
commission: {
|
|
58
|
-
commissionBps:
|
|
59
|
-
partner:
|
|
56
|
+
commissionBps: 0,
|
|
57
|
+
partner: _7k_1._7K_PARTNER_ADDRESS,
|
|
60
58
|
},
|
|
61
59
|
slippage: 1,
|
|
62
60
|
extendTx: {
|
|
@@ -3,24 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CetusProvider = void 0;
|
|
4
4
|
const aggregator_sdk_1 = require("@cetusprotocol/aggregator-sdk");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
|
+
const _7k_1 = require("../../../constants/_7k");
|
|
6
7
|
const metaAg_1 = require("../../../types/metaAg");
|
|
7
8
|
const condition_1 = require("../../../utils/condition");
|
|
8
|
-
const buildTx_1 = require("../../swap/buildTx");
|
|
9
9
|
class CetusProvider {
|
|
10
10
|
constructor(options, metaOptions, client) {
|
|
11
11
|
this.options = options;
|
|
12
|
-
this.metaOptions = metaOptions;
|
|
13
12
|
this.kind = metaAg_1.EProvider.CETUS;
|
|
14
13
|
this.cetusClient = new aggregator_sdk_1.AggregatorClient({
|
|
15
14
|
apiKey: options.apiKey,
|
|
16
|
-
overlayFeeReceiver: metaOptions.partner,
|
|
17
|
-
overlayFeeRate: metaOptions.partnerCommissionBps
|
|
18
|
-
? metaOptions.partnerCommissionBps / 10000
|
|
19
|
-
: undefined,
|
|
20
15
|
client,
|
|
21
16
|
endpoint: options.api,
|
|
22
17
|
env: aggregator_sdk_1.Env.Mainnet,
|
|
23
18
|
pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],
|
|
19
|
+
overlayFeeRate: 0,
|
|
20
|
+
overlayFeeReceiver: _7k_1._7K_PARTNER_ADDRESS,
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
23
|
async quote(quoteOptions) {
|
|
@@ -37,18 +34,13 @@ class CetusProvider {
|
|
|
37
34
|
liquidityChanges: this.options.liquidityChanges,
|
|
38
35
|
});
|
|
39
36
|
(0, condition_1.assert)(!!quote, "No quote found");
|
|
40
|
-
const bps = BigInt(this.metaOptions.partnerCommissionBps ?? 0);
|
|
41
|
-
// calc amount out before any commission fees
|
|
42
|
-
const amountOut = ((BigInt(quote.amountOut.toString()) * 10000n) /
|
|
43
|
-
(10000n - bps)).toString();
|
|
44
|
-
const { expectedAmount } = (0, buildTx_1.getExpectedReturn)(amountOut, 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
45
37
|
return {
|
|
46
38
|
id: (0, uuid_1.v4)(),
|
|
47
39
|
provider: metaAg_1.EProvider.CETUS,
|
|
48
40
|
quote,
|
|
49
|
-
amountIn: quote.amountIn.toString(),
|
|
50
|
-
rawAmountOut: amountOut,
|
|
51
|
-
amountOut:
|
|
41
|
+
amountIn: quote.amountIn.toString() || "0",
|
|
42
|
+
rawAmountOut: quote.amountOut.toString() || "0",
|
|
43
|
+
amountOut: quote.amountOut.toString() || "0",
|
|
52
44
|
coinTypeIn: quoteOptions.coinInType,
|
|
53
45
|
coinTypeOut: quoteOptions.coinOutType,
|
|
54
46
|
};
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FlowxProvider = void 0;
|
|
4
4
|
const sdk_1 = require("@flowx-finance/sdk");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
|
+
const _7k_1 = require("../../../constants/_7k");
|
|
6
7
|
const metaAg_1 = require("../../../types/metaAg");
|
|
7
8
|
const condition_1 = require("../../../utils/condition");
|
|
8
|
-
const buildTx_1 = require("../../swap/buildTx");
|
|
9
9
|
class FlowxProvider {
|
|
10
|
-
constructor(options,
|
|
10
|
+
constructor(options, client) {
|
|
11
11
|
this.options = options;
|
|
12
|
-
this.metaOptions = metaOptions;
|
|
13
12
|
this.client = client;
|
|
14
13
|
this.kind = metaAg_1.EProvider.FLOWX;
|
|
15
14
|
this.quoter = new sdk_1.AggregatorQuoter("mainnet", options.apiKey);
|
|
@@ -25,14 +24,13 @@ class FlowxProvider {
|
|
|
25
24
|
maxHops: this.options.maxHops,
|
|
26
25
|
splitDistributionPercent: this.options.splitDistributionPercent,
|
|
27
26
|
});
|
|
28
|
-
const { expectedAmount } = (0, buildTx_1.getExpectedReturn)(quote.amountOut?.toString() ?? "0", 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
29
27
|
return {
|
|
30
28
|
id: (0, uuid_1.v4)(),
|
|
31
29
|
provider: metaAg_1.EProvider.FLOWX,
|
|
32
30
|
quote: quote,
|
|
33
31
|
amountIn: quote.amountIn?.toString() ?? "0",
|
|
34
32
|
rawAmountOut: quote.amountOut?.toString() ?? "0",
|
|
35
|
-
amountOut:
|
|
33
|
+
amountOut: quote.amountOut?.toString() ?? "0",
|
|
36
34
|
coinTypeIn: quoteOptions.coinInType,
|
|
37
35
|
coinTypeOut: quoteOptions.coinOutType,
|
|
38
36
|
};
|
|
@@ -40,11 +38,9 @@ class FlowxProvider {
|
|
|
40
38
|
async swap(options) {
|
|
41
39
|
(0, condition_1.assert)(options.quote.provider === metaAg_1.EProvider.FLOWX, "Invalid quote");
|
|
42
40
|
const builder = new sdk_1.TradeBuilder("mainnet", options.quote.quote.routes);
|
|
43
|
-
if (this.metaOptions.partner) {
|
|
44
|
-
builder.commission(new sdk_1.Commission(this.metaOptions.partner, options.quote.quote.coinOut, sdk_1.CommissionType.PERCENTAGE, (this.metaOptions.partnerCommissionBps ?? 0) * 100, true));
|
|
45
|
-
}
|
|
46
41
|
builder.sender(options.signer);
|
|
47
42
|
builder.slippage(10000 * 100);
|
|
43
|
+
builder.commission(new sdk_1.Commission(_7k_1._7K_PARTNER_ADDRESS, options.quote.quote.coinOut, sdk_1.CommissionType.PERCENTAGE, 0, true));
|
|
48
44
|
const res = await builder.build().swap({
|
|
49
45
|
tx: options.tx,
|
|
50
46
|
client: this.client,
|
|
@@ -5,4 +5,5 @@ export declare const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049
|
|
|
5
5
|
export declare const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
6
6
|
export declare const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
7
7
|
export declare const _7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
|
|
8
|
+
export declare const _7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
|
|
8
9
|
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAuCZ,SAAS;YAqDT,MAAM;IAoCpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAuBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAQ/B,qBAAa,eAAgB,YAAW,UAAU;IAG9C,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAH9B,IAAI,YAAuB;gBAER,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,EACrD,MAAM,EAAE,SAAS;IAeb,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAsBpD,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,eAAe;CAiB1D"}
|
|
@@ -3,7 +3,6 @@ import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
|
3
3
|
import { AgProvider, CetusProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
4
|
export declare class CetusProvider implements AgProvider {
|
|
5
5
|
private readonly options;
|
|
6
|
-
private readonly metaOptions;
|
|
7
6
|
kind: EProvider;
|
|
8
7
|
private readonly cetusClient;
|
|
9
8
|
constructor(options: CetusProviderOptions, metaOptions: MetaAgOptions, client: SuiClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cetus.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/cetus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cetus.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/cetus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,UAAU;IAI5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH1B,IAAI,YAAmB;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;gBAE5B,OAAO,EAAE,oBAAoB,EAC9C,WAAW,EAAE,aAAa,EAC1B,MAAM,EAAE,SAAS;IAab,KAAK,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IA0BzD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAUzE"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import { AgProvider, EProvider, FlowxProviderOptions,
|
|
3
|
+
import { AgProvider, EProvider, FlowxProviderOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
4
|
export declare class FlowxProvider implements AgProvider {
|
|
5
5
|
private readonly options;
|
|
6
|
-
private readonly metaOptions;
|
|
7
6
|
private readonly client;
|
|
8
7
|
kind: EProvider;
|
|
9
8
|
private quoter;
|
|
10
|
-
constructor(options: FlowxProviderOptions,
|
|
9
|
+
constructor(options: FlowxProviderOptions, client: SuiClient);
|
|
11
10
|
quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
12
11
|
swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowx.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/flowx.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"flowx.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/flowx.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,UAAU;IAI5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,IAAI,YAAmB;IACvB,OAAO,CAAC,MAAM,CAAmB;gBAEd,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,SAAS;IAK9B,KAAK,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAuBzD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAqBzE"}
|
|
@@ -8,32 +8,31 @@ export declare enum EProvider {
|
|
|
8
8
|
CETUS = "cetus",
|
|
9
9
|
FLOWX = "flowx"
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
type ProviderBaseOptions = {
|
|
12
|
+
api?: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type BluefinProviderOptions = ProviderBaseOptions & {
|
|
12
17
|
sources?: SourceDex[];
|
|
13
18
|
maxPaths?: number;
|
|
14
19
|
excludedPools?: string[];
|
|
15
20
|
targetPools?: string[];
|
|
16
|
-
api?: string;
|
|
17
|
-
apiKey?: string;
|
|
18
21
|
};
|
|
19
|
-
export type FlowxProviderOptions = {
|
|
22
|
+
export type FlowxProviderOptions = ProviderBaseOptions & {
|
|
20
23
|
sources?: Protocol[];
|
|
21
24
|
excludePools?: string[];
|
|
22
25
|
excludeSources?: Protocol[];
|
|
23
26
|
maxHops?: number;
|
|
24
27
|
splitDistributionPercent?: number;
|
|
25
|
-
api?: string;
|
|
26
|
-
apiKey?: string;
|
|
27
28
|
};
|
|
28
|
-
export type CetusProviderOptions = {
|
|
29
|
+
export type CetusProviderOptions = ProviderBaseOptions & {
|
|
29
30
|
sources?: string[];
|
|
30
31
|
splitCount?: number;
|
|
31
32
|
splitAlgorithm?: string;
|
|
32
33
|
splitFactor?: number;
|
|
33
34
|
depth?: number;
|
|
34
35
|
liquidityChanges?: PreSwapLpChangeParams[];
|
|
35
|
-
api?: string;
|
|
36
|
-
apiKey?: string;
|
|
37
36
|
};
|
|
38
37
|
export interface MetaAgOptions {
|
|
39
38
|
/**If not specified, all providers will be used */
|
|
@@ -124,4 +123,5 @@ export declare abstract class AgProvider {
|
|
|
124
123
|
abstract quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
125
124
|
abstract swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
126
125
|
}
|
|
126
|
+
export {};
|
|
127
127
|
//# sourceMappingURL=metaAg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaAg.d.ts","sourceRoot":"","sources":["../../../../src/types/metaAg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,M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AE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAClE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAC5E"}
|
package/lib/esm/constants/_7k.js
CHANGED
|
@@ -11,3 +11,4 @@ export const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28
|
|
|
11
11
|
export const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
12
12
|
export const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
13
13
|
export const _7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
|
|
14
|
+
export const _7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
|
|
@@ -21,7 +21,7 @@ export class MetaAg {
|
|
|
21
21
|
options;
|
|
22
22
|
constructor(options) {
|
|
23
23
|
this.options = {
|
|
24
|
-
providers: options?.providers
|
|
24
|
+
providers: { ...DEFAULT_PROVIDERS, ...options?.providers },
|
|
25
25
|
slippageBps: options?.slippageBps ?? 100,
|
|
26
26
|
fullnodeUrl: options?.fullnodeUrl ?? getFullnodeUrl("mainnet"),
|
|
27
27
|
hermesApi: options?.hermesApi ?? HERMES_API,
|
|
@@ -40,14 +40,13 @@ export class MetaAg {
|
|
|
40
40
|
return p;
|
|
41
41
|
const providerOptions = this.options.providers[provider];
|
|
42
42
|
assert(!!providerOptions, `Provider not found: ${provider}`);
|
|
43
|
-
// eslint-disable-next-line no-case-declarations
|
|
44
43
|
switch (provider) {
|
|
45
44
|
case EProvider.BLUEFIN7K:
|
|
46
45
|
this.providers[EProvider.BLUEFIN7K] = new BluefinProvider(providerOptions, this.options, this.client);
|
|
47
46
|
break;
|
|
48
47
|
case EProvider.FLOWX:
|
|
49
48
|
const { FlowxProvider } = await import("./providers/flowx").catch(catchImportError(EProvider.FLOWX));
|
|
50
|
-
this.providers[EProvider.FLOWX] = new FlowxProvider(providerOptions, this.
|
|
49
|
+
this.providers[EProvider.FLOWX] = new FlowxProvider(providerOptions, this.client);
|
|
51
50
|
break;
|
|
52
51
|
case EProvider.CETUS:
|
|
53
52
|
const { CetusProvider } = await import("./providers/cetus").catch(catchImportError(EProvider.CETUS));
|
|
@@ -94,7 +93,12 @@ export class MetaAg {
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
async _quote(provider, options, simulation) {
|
|
97
|
-
const quote = await timeout(() =>
|
|
96
|
+
const quote = await timeout(async () => {
|
|
97
|
+
const quote = await provider.quote(options);
|
|
98
|
+
const { expectedAmount } = getExpectedReturn(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
|
|
99
|
+
quote.amountOut = expectedAmount;
|
|
100
|
+
return quote;
|
|
101
|
+
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinInType} to ${options.coinOutType}`);
|
|
98
102
|
if (simulation) {
|
|
99
103
|
if (simulation.onSimulated) {
|
|
100
104
|
this._simulate(provider, quote, simulation).then((payload) => {
|
|
@@ -123,7 +127,9 @@ export class MetaAg {
|
|
|
123
127
|
coinInType: normalizeStructTag(options.coinInType),
|
|
124
128
|
coinOutType: normalizeStructTag(options.coinOutType),
|
|
125
129
|
};
|
|
126
|
-
const quotes = await Promise.allSettled(Object.
|
|
130
|
+
const quotes = await Promise.allSettled(Object.entries(this.options.providers)
|
|
131
|
+
.filter(([_k, v]) => !v.disabled)
|
|
132
|
+
.map(async ([provider]) => {
|
|
127
133
|
const p = await this._getProvider(provider);
|
|
128
134
|
return this._quote(p, opts, simulation);
|
|
129
135
|
}));
|
|
@@ -189,8 +195,7 @@ export class MetaAg {
|
|
|
189
195
|
*/
|
|
190
196
|
const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
|
|
191
197
|
return (tx) => {
|
|
192
|
-
const { minAmount, expectedAmount } = getExpectedReturn(quote.rawAmountOut, slippageBps, commissionBps,
|
|
193
|
-
tipBps);
|
|
198
|
+
const { minAmount, expectedAmount } = getExpectedReturn(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
|
|
194
199
|
if (tipBps > 0) {
|
|
195
200
|
tx.moveCall({
|
|
196
201
|
target: `${_7K_META_PUBLISHED_AT}::vault::collect_tip`,
|
|
@@ -214,7 +219,7 @@ const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, comm
|
|
|
214
219
|
tx.pure.u64(minAmount),
|
|
215
220
|
tx.pure.u64(expectedAmount),
|
|
216
221
|
tx.pure.option("address", partner),
|
|
217
|
-
tx.pure.u64(
|
|
222
|
+
tx.pure.u64(commissionBps),
|
|
218
223
|
tx.pure.u64(0), // ps
|
|
219
224
|
],
|
|
220
225
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
import { Config } from "../../../config";
|
|
4
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
4
5
|
import { API_ENDPOINTS } from "../../../constants/apiEndpoints";
|
|
5
|
-
import { SUI_ADDRESS_ZERO } from "../../../constants/sui";
|
|
6
6
|
import { EProvider, } from "../../../types/metaAg";
|
|
7
7
|
import { assert } from "../../../utils/condition";
|
|
8
|
-
import { getExpectedReturn } from "../../swap/buildTx";
|
|
9
8
|
import { buildTxV2 } from "../../swap/buildTxV2";
|
|
10
9
|
import { getQuote } from "../../swap/getQuote";
|
|
11
10
|
const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
|
|
@@ -36,14 +35,13 @@ export class BluefinProvider {
|
|
|
36
35
|
excludedPools: this.options.excludedPools,
|
|
37
36
|
targetPools: this.options.targetPools,
|
|
38
37
|
});
|
|
39
|
-
const { expectedAmount } = getExpectedReturn(quote.returnAmountWithDecimal.toString(), 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
40
38
|
return {
|
|
41
39
|
id: v4(),
|
|
42
40
|
provider: EProvider.BLUEFIN7K,
|
|
43
41
|
quote,
|
|
44
42
|
amountIn: quote.swapAmountWithDecimal,
|
|
45
43
|
rawAmountOut: quote.returnAmountWithDecimal,
|
|
46
|
-
amountOut:
|
|
44
|
+
amountOut: quote.returnAmountWithDecimal,
|
|
47
45
|
coinTypeIn: options.coinInType,
|
|
48
46
|
coinTypeOut: options.coinOutType,
|
|
49
47
|
};
|
|
@@ -54,8 +52,8 @@ export class BluefinProvider {
|
|
|
54
52
|
quoteResponse: quote.quote,
|
|
55
53
|
accountAddress: signer,
|
|
56
54
|
commission: {
|
|
57
|
-
commissionBps:
|
|
58
|
-
partner:
|
|
55
|
+
commissionBps: 0,
|
|
56
|
+
partner: _7K_PARTNER_ADDRESS,
|
|
59
57
|
},
|
|
60
58
|
slippage: 1,
|
|
61
59
|
extendTx: {
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { AggregatorClient, Env } from "@cetusprotocol/aggregator-sdk";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
3
4
|
import { EProvider, } from "../../../types/metaAg";
|
|
4
5
|
import { assert } from "../../../utils/condition";
|
|
5
|
-
import { getExpectedReturn } from "../../swap/buildTx";
|
|
6
6
|
export class CetusProvider {
|
|
7
7
|
options;
|
|
8
|
-
metaOptions;
|
|
9
8
|
kind = EProvider.CETUS;
|
|
10
9
|
cetusClient;
|
|
11
10
|
constructor(options, metaOptions, client) {
|
|
12
11
|
this.options = options;
|
|
13
|
-
this.metaOptions = metaOptions;
|
|
14
12
|
this.cetusClient = new AggregatorClient({
|
|
15
13
|
apiKey: options.apiKey,
|
|
16
|
-
overlayFeeReceiver: metaOptions.partner,
|
|
17
|
-
overlayFeeRate: metaOptions.partnerCommissionBps
|
|
18
|
-
? metaOptions.partnerCommissionBps / 10000
|
|
19
|
-
: undefined,
|
|
20
14
|
client,
|
|
21
15
|
endpoint: options.api,
|
|
22
16
|
env: Env.Mainnet,
|
|
23
17
|
pythUrls: metaOptions.hermesApi ? [metaOptions.hermesApi] : [],
|
|
18
|
+
overlayFeeRate: 0,
|
|
19
|
+
overlayFeeReceiver: _7K_PARTNER_ADDRESS,
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
async quote(quoteOptions) {
|
|
@@ -37,18 +33,13 @@ export class CetusProvider {
|
|
|
37
33
|
liquidityChanges: this.options.liquidityChanges,
|
|
38
34
|
});
|
|
39
35
|
assert(!!quote, "No quote found");
|
|
40
|
-
const bps = BigInt(this.metaOptions.partnerCommissionBps ?? 0);
|
|
41
|
-
// calc amount out before any commission fees
|
|
42
|
-
const amountOut = ((BigInt(quote.amountOut.toString()) * 10000n) /
|
|
43
|
-
(10000n - bps)).toString();
|
|
44
|
-
const { expectedAmount } = getExpectedReturn(amountOut, 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
45
36
|
return {
|
|
46
37
|
id: v4(),
|
|
47
38
|
provider: EProvider.CETUS,
|
|
48
39
|
quote,
|
|
49
|
-
amountIn: quote.amountIn.toString(),
|
|
50
|
-
rawAmountOut: amountOut,
|
|
51
|
-
amountOut:
|
|
40
|
+
amountIn: quote.amountIn.toString() || "0",
|
|
41
|
+
rawAmountOut: quote.amountOut.toString() || "0",
|
|
42
|
+
amountOut: quote.amountOut.toString() || "0",
|
|
52
43
|
coinTypeIn: quoteOptions.coinInType,
|
|
53
44
|
coinTypeOut: quoteOptions.coinOutType,
|
|
54
45
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { AggregatorQuoter, Commission, CommissionType, TradeBuilder, } from "@flowx-finance/sdk";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
|
+
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
3
4
|
import { EProvider, } from "../../../types/metaAg";
|
|
4
5
|
import { assert } from "../../../utils/condition";
|
|
5
|
-
import { getExpectedReturn } from "../../swap/buildTx";
|
|
6
6
|
export class FlowxProvider {
|
|
7
7
|
options;
|
|
8
|
-
metaOptions;
|
|
9
8
|
client;
|
|
10
9
|
kind = EProvider.FLOWX;
|
|
11
10
|
quoter;
|
|
12
|
-
constructor(options,
|
|
11
|
+
constructor(options, client) {
|
|
13
12
|
this.options = options;
|
|
14
|
-
this.metaOptions = metaOptions;
|
|
15
13
|
this.client = client;
|
|
16
14
|
this.quoter = new AggregatorQuoter("mainnet", options.apiKey);
|
|
17
15
|
}
|
|
@@ -26,14 +24,13 @@ export class FlowxProvider {
|
|
|
26
24
|
maxHops: this.options.maxHops,
|
|
27
25
|
splitDistributionPercent: this.options.splitDistributionPercent,
|
|
28
26
|
});
|
|
29
|
-
const { expectedAmount } = getExpectedReturn(quote.amountOut?.toString() ?? "0", 0, this.metaOptions.partnerCommissionBps ?? 0, this.metaOptions.tipBps ?? 0);
|
|
30
27
|
return {
|
|
31
28
|
id: v4(),
|
|
32
29
|
provider: EProvider.FLOWX,
|
|
33
30
|
quote: quote,
|
|
34
31
|
amountIn: quote.amountIn?.toString() ?? "0",
|
|
35
32
|
rawAmountOut: quote.amountOut?.toString() ?? "0",
|
|
36
|
-
amountOut:
|
|
33
|
+
amountOut: quote.amountOut?.toString() ?? "0",
|
|
37
34
|
coinTypeIn: quoteOptions.coinInType,
|
|
38
35
|
coinTypeOut: quoteOptions.coinOutType,
|
|
39
36
|
};
|
|
@@ -41,11 +38,9 @@ export class FlowxProvider {
|
|
|
41
38
|
async swap(options) {
|
|
42
39
|
assert(options.quote.provider === EProvider.FLOWX, "Invalid quote");
|
|
43
40
|
const builder = new TradeBuilder("mainnet", options.quote.quote.routes);
|
|
44
|
-
if (this.metaOptions.partner) {
|
|
45
|
-
builder.commission(new Commission(this.metaOptions.partner, options.quote.quote.coinOut, CommissionType.PERCENTAGE, (this.metaOptions.partnerCommissionBps ?? 0) * 100, true));
|
|
46
|
-
}
|
|
47
41
|
builder.sender(options.signer);
|
|
48
42
|
builder.slippage(10000 * 100);
|
|
43
|
+
builder.commission(new Commission(_7K_PARTNER_ADDRESS, options.quote.quote.coinOut, CommissionType.PERCENTAGE, 0, true));
|
|
49
44
|
const res = await builder.build().swap({
|
|
50
45
|
tx: options.tx,
|
|
51
46
|
client: this.client,
|
|
@@ -5,4 +5,5 @@ export declare const _7K_META_PUBLISHED_AT = "0x17c0b1f7a6ad73f51268f16b8c06c049
|
|
|
5
5
|
export declare const _7K_META_PACKAGE_ID = "0x17c0b1f7a6ad73f51268f16b8c06c049eecc2f28a270cdd29c06e3d2dea23302";
|
|
6
6
|
export declare const _7K_META_VAULT = "0x9a8abd32fe5721307ce3b697cf982ee84e9ffbd58d667a4a199f1683c1a3d23c";
|
|
7
7
|
export declare const _7K_META_CONFIG = "0xbbb3a51877ed9b492f26f4e2181811cfb2bd70c532f6f7621263d122d5e96b56";
|
|
8
|
+
export declare const _7K_PARTNER_ADDRESS = "0x93ead46c1e48a9b62e25b6787f2ea6f75caedabb21726f12431acc4381f5f4c5";
|
|
8
9
|
//# sourceMappingURL=_7k.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"_7k.d.ts","sourceRoot":"","sources":["../../../../src/constants/_7k.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAKvE,eAAO,MAAM,UAAU,uEAC+C,CAAC;AAGvE,eAAO,MAAM,SAAS,uEACgD,CAAC;AAEvE,eAAO,MAAM,qBAAqB,uEACoC,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AACvE,eAAO,MAAM,cAAc,uEAC2C,CAAC;AACvE,eAAO,MAAM,eAAe,uEAC0C,CAAC;AACvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAY,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAML,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAa5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YAuCZ,SAAS;YAqDT,MAAM;IAoCpB;;;;;OAKG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,UAAU,CAAC,EAAE,qBAAqB,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC;IAuBvB;;;;;OAKG;IACG,IAAI,CACR,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,CAAC;IAkBrC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAQ/B,qBAAa,eAAgB,YAAW,UAAU;IAG9C,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAH9B,IAAI,YAAuB;gBAER,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,EACrD,MAAM,EAAE,SAAS;IAeb,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAsBpD,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,eAAe;CAiB1D"}
|
|
@@ -3,7 +3,6 @@ import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
|
3
3
|
import { AgProvider, CetusProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
4
|
export declare class CetusProvider implements AgProvider {
|
|
5
5
|
private readonly options;
|
|
6
|
-
private readonly metaOptions;
|
|
7
6
|
kind: EProvider;
|
|
8
7
|
private readonly cetusClient;
|
|
9
8
|
constructor(options: CetusProviderOptions, metaOptions: MetaAgOptions, client: SuiClient);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cetus.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/cetus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cetus.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/cetus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,UAAU;IAI5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH1B,IAAI,YAAmB;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;gBAE5B,OAAO,EAAE,oBAAoB,EAC9C,WAAW,EAAE,aAAa,EAC1B,MAAM,EAAE,SAAS;IAab,KAAK,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IA0BzD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAUzE"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import { AgProvider, EProvider, FlowxProviderOptions,
|
|
3
|
+
import { AgProvider, EProvider, FlowxProviderOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
4
|
export declare class FlowxProvider implements AgProvider {
|
|
5
5
|
private readonly options;
|
|
6
|
-
private readonly metaOptions;
|
|
7
6
|
private readonly client;
|
|
8
7
|
kind: EProvider;
|
|
9
8
|
private quoter;
|
|
10
|
-
constructor(options: FlowxProviderOptions,
|
|
9
|
+
constructor(options: FlowxProviderOptions, client: SuiClient);
|
|
11
10
|
quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
12
11
|
swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowx.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/flowx.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"flowx.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/flowx.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,UAAU;IAI5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,IAAI,YAAmB;IACvB,OAAO,CAAC,MAAM,CAAmB;gBAEd,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,SAAS;IAK9B,KAAK,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAuBzD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAqBzE"}
|
|
@@ -8,32 +8,31 @@ export declare enum EProvider {
|
|
|
8
8
|
CETUS = "cetus",
|
|
9
9
|
FLOWX = "flowx"
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
type ProviderBaseOptions = {
|
|
12
|
+
api?: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type BluefinProviderOptions = ProviderBaseOptions & {
|
|
12
17
|
sources?: SourceDex[];
|
|
13
18
|
maxPaths?: number;
|
|
14
19
|
excludedPools?: string[];
|
|
15
20
|
targetPools?: string[];
|
|
16
|
-
api?: string;
|
|
17
|
-
apiKey?: string;
|
|
18
21
|
};
|
|
19
|
-
export type FlowxProviderOptions = {
|
|
22
|
+
export type FlowxProviderOptions = ProviderBaseOptions & {
|
|
20
23
|
sources?: Protocol[];
|
|
21
24
|
excludePools?: string[];
|
|
22
25
|
excludeSources?: Protocol[];
|
|
23
26
|
maxHops?: number;
|
|
24
27
|
splitDistributionPercent?: number;
|
|
25
|
-
api?: string;
|
|
26
|
-
apiKey?: string;
|
|
27
28
|
};
|
|
28
|
-
export type CetusProviderOptions = {
|
|
29
|
+
export type CetusProviderOptions = ProviderBaseOptions & {
|
|
29
30
|
sources?: string[];
|
|
30
31
|
splitCount?: number;
|
|
31
32
|
splitAlgorithm?: string;
|
|
32
33
|
splitFactor?: number;
|
|
33
34
|
depth?: number;
|
|
34
35
|
liquidityChanges?: PreSwapLpChangeParams[];
|
|
35
|
-
api?: string;
|
|
36
|
-
apiKey?: string;
|
|
37
36
|
};
|
|
38
37
|
export interface MetaAgOptions {
|
|
39
38
|
/**If not specified, all providers will be used */
|
|
@@ -124,4 +123,5 @@ export declare abstract class AgProvider {
|
|
|
124
123
|
abstract quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
125
124
|
abstract swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
126
125
|
}
|
|
126
|
+
export {};
|
|
127
127
|
//# sourceMappingURL=metaAg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metaAg.d.ts","sourceRoot":"","sources":["../../../../src/types/metaAg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAExD,oBAAY,SAAS;IACnB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AACD,
|
|
1
|
+
{"version":3,"file":"metaAg.d.ts","sourceRoot":"","sources":["../../../../src/types/metaAg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO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,7 @@
|
|
|
71
71
|
"typescript-eslint": "^8.34.1"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@mysten/sui": "^1.
|
|
74
|
+
"@mysten/sui": "^1.44.0",
|
|
75
75
|
"@pythnetwork/pyth-sui-js": "^2.2.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|