@7kprotocol/sdk-ts 3.5.2-beta.1 → 3.5.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/lib/cjs/config/index.js +0 -9
- package/lib/cjs/constants/apiEndpoints.js +1 -1
- package/lib/cjs/features/metaAg/index.js +108 -98
- package/lib/cjs/features/metaAg/providers/bluefin.js +6 -6
- package/lib/cjs/features/metaAg/providers/cetus.js +4 -4
- package/lib/cjs/features/metaAg/providers/flowx.js +4 -4
- package/lib/cjs/features/swap/buildTx.js +0 -3
- package/lib/cjs/features/swap/buildTxV2.js +6 -10
- package/lib/cjs/features/swap/config.js +1 -2
- package/lib/cjs/features/swap/getQuote.js +2 -3
- package/lib/cjs/libs/protocols/bluefinx/client.js +1 -1
- package/lib/cjs/types/config/index.d.ts +0 -4
- package/lib/cjs/types/config/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/index.d.ts +2 -11
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +5 -4
- package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts +3 -1
- package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +1 -3
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/metaAg.js +4 -11
- package/lib/cjs/types/types/metaAg.d.ts +8 -60
- package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
- package/lib/cjs/types/utils/condition.d.ts +1 -1
- package/lib/cjs/types/utils/condition.d.ts.map +1 -1
- package/lib/esm/config/index.js +0 -9
- package/lib/esm/constants/apiEndpoints.js +1 -1
- package/lib/esm/features/metaAg/index.js +109 -99
- package/lib/esm/features/metaAg/providers/bluefin.js +6 -6
- package/lib/esm/features/metaAg/providers/cetus.js +4 -4
- package/lib/esm/features/metaAg/providers/flowx.js +4 -4
- package/lib/esm/features/swap/buildTx.js +0 -3
- package/lib/esm/features/swap/buildTxV2.js +2 -6
- package/lib/esm/features/swap/config.js +1 -2
- package/lib/esm/features/swap/getQuote.js +2 -3
- package/lib/esm/libs/protocols/bluefinx/client.js +1 -1
- package/lib/esm/types/config/index.d.ts +0 -4
- package/lib/esm/types/config/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/index.d.ts +2 -11
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts +5 -4
- package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
- package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
- package/lib/esm/types/features/swap/buildTxV2.d.ts +3 -3
- package/lib/esm/types/features/swap/buildTxV2.d.ts.map +1 -1
- package/lib/esm/types/features/swap/config.d.ts.map +1 -1
- package/lib/esm/types/features/swap/getQuote.d.ts +3 -1
- package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +1 -3
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/metaAg.js +2 -8
- package/lib/esm/types/types/metaAg.d.ts +8 -60
- package/lib/esm/types/types/metaAg.d.ts.map +1 -1
- package/lib/esm/types/utils/condition.d.ts +1 -1
- package/lib/esm/types/utils/condition.d.ts.map +1 -1
- package/package.json +2 -3
- package/lib/cjs/features/metaAg/common.js +0 -117
- package/lib/cjs/features/metaAg/providers/astro.js +0 -43
- package/lib/cjs/features/metaAg/providers/bluefinx.js +0 -87
- package/lib/cjs/features/metaAg/providers/okx.js +0 -181
- package/lib/cjs/types/features/metaAg/common.d.ts +0 -33
- package/lib/cjs/types/features/metaAg/common.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/astro.d.ts +0 -9
- package/lib/cjs/types/features/metaAg/providers/astro.d.ts.map +0 -1
- package/lib/cjs/types/features/metaAg/providers/bluefinx.d.ts +0 -10
- package/lib/cjs/types/features/metaAg/providers/bluefinx.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/okx.js +0 -6
- package/lib/cjs/types/types/okx.d.ts +0 -193
- package/lib/cjs/types/types/okx.d.ts.map +0 -1
- package/lib/esm/features/metaAg/common.js +0 -109
- package/lib/esm/features/metaAg/providers/astro.js +0 -40
- package/lib/esm/features/metaAg/providers/bluefinx.js +0 -84
- package/lib/esm/features/metaAg/providers/okx.js +0 -146
- package/lib/esm/types/features/metaAg/common.d.ts +0 -33
- package/lib/esm/types/features/metaAg/common.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/astro.d.ts +0 -9
- package/lib/esm/types/features/metaAg/providers/astro.d.ts.map +0 -1
- package/lib/esm/types/features/metaAg/providers/bluefinx.d.ts +0 -10
- package/lib/esm/types/features/metaAg/providers/bluefinx.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/okx.js +0 -5
- package/lib/esm/types/types/okx.d.ts +0 -193
- package/lib/esm/types/types/okx.d.ts.map +0 -1
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { getFullnodeUrl, SuiClient
|
|
1
|
+
import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { coinWithBalance, Transaction, } from "@mysten/sui/transactions";
|
|
3
|
-
import { normalizeStructTag
|
|
3
|
+
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
4
|
+
import { _7K_META_CONFIG, _7K_META_PACKAGE_ID, _7K_META_PUBLISHED_AT, _7K_META_VAULT, } from "../../constants/_7k";
|
|
4
5
|
import { SUI_ADDRESS_ZERO } from "../../constants/sui";
|
|
5
|
-
import { EProvider,
|
|
6
|
+
import { EProvider, } from "../../types/metaAg";
|
|
6
7
|
import { assert } from "../../utils/condition";
|
|
7
8
|
import { SuiClientUtils } from "../../utils/SuiClientUtils";
|
|
8
9
|
import { getExpectedReturn } from "../swap/buildTx";
|
|
9
|
-
import { metaSettle, simulateAggregator, simulateBluefinX, timeout, } from "./common";
|
|
10
10
|
import { BluefinProvider } from "./providers/bluefin";
|
|
11
|
-
import { BluefinXProvider } from "./providers/bluefinx";
|
|
12
|
-
import { OkxProvider, simulateOKXSwap } from "./providers/okx";
|
|
13
11
|
const HERMES_API = "https://hermes.pyth.network";
|
|
14
12
|
const DEFAULT_PROVIDERS = {
|
|
15
13
|
[EProvider.BLUEFIN7K]: {},
|
|
16
14
|
[EProvider.FLOWX]: {},
|
|
17
15
|
[EProvider.CETUS]: {},
|
|
18
|
-
[EProvider.ASTRO]: {},
|
|
19
|
-
[EProvider.BLUEFINX]: {},
|
|
20
16
|
};
|
|
21
17
|
export class MetaAg {
|
|
22
18
|
client;
|
|
@@ -56,16 +52,6 @@ export class MetaAg {
|
|
|
56
52
|
const { CetusProvider } = await import("./providers/cetus").catch(catchImportError(EProvider.CETUS));
|
|
57
53
|
this.providers[EProvider.CETUS] = new CetusProvider(providerOptions, this.options, this.client);
|
|
58
54
|
break;
|
|
59
|
-
case EProvider.OKX:
|
|
60
|
-
this.providers[EProvider.OKX] = new OkxProvider(providerOptions, this.options, this.client);
|
|
61
|
-
break;
|
|
62
|
-
case EProvider.BLUEFINX:
|
|
63
|
-
this.providers[EProvider.BLUEFINX] = new BluefinXProvider(providerOptions);
|
|
64
|
-
break;
|
|
65
|
-
case EProvider.ASTRO:
|
|
66
|
-
const { AstroProvider } = await import("./providers/astro").catch(catchImportError(EProvider.ASTRO));
|
|
67
|
-
this.providers[EProvider.ASTRO] = new AstroProvider(providerOptions);
|
|
68
|
-
break;
|
|
69
55
|
default:
|
|
70
56
|
throw new Error(`Provider not supported: ${provider}`);
|
|
71
57
|
}
|
|
@@ -73,56 +59,62 @@ export class MetaAg {
|
|
|
73
59
|
}
|
|
74
60
|
async _simulate(provider, quote, simulation) {
|
|
75
61
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
const tx = new Transaction();
|
|
63
|
+
const id = quote.id;
|
|
64
|
+
const coinOut = await provider.swap({
|
|
65
|
+
quote,
|
|
66
|
+
coinIn: coinWithBalance({
|
|
67
|
+
balance: BigInt(quote.amountIn),
|
|
68
|
+
type: quote.coinTypeIn,
|
|
69
|
+
useGasCoin: false,
|
|
70
|
+
}),
|
|
71
|
+
signer: simulation.sender,
|
|
72
|
+
tx,
|
|
73
|
+
});
|
|
74
|
+
tx.add(metaSettle(quote, coinOut, 10000, this.options.tipBps, this.options.partner, this.options.partnerCommissionBps));
|
|
75
|
+
tx.transferObjects([coinOut], simulation.sender);
|
|
76
|
+
const res = await timeout(() => this.inspector.devInspectTransactionBlock({
|
|
77
|
+
sender: simulation.sender,
|
|
78
|
+
transactionBlock: tx,
|
|
79
|
+
}), simulation.timeout ?? 2000, `simulation for ${provider.kind} provider with id ${id}`);
|
|
80
|
+
if (res.effects.status.status === "failure") {
|
|
81
|
+
throw new Error(res.error ?? "Simulation failed");
|
|
86
82
|
}
|
|
83
|
+
const amountOut = extractAmountOutWrapper(res.events);
|
|
84
|
+
return {
|
|
85
|
+
id,
|
|
86
|
+
simulatedAmountOut: amountOut,
|
|
87
|
+
gasUsed: res.effects.gasUsed,
|
|
88
|
+
provider: provider.kind,
|
|
89
|
+
};
|
|
87
90
|
}
|
|
88
91
|
catch (error) {
|
|
89
|
-
console.warn(
|
|
92
|
+
console.warn(`Failed to simulate ${provider.kind}: `, error);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
|
-
async _quote(provider, options) {
|
|
95
|
+
async _quote(provider, options, simulation) {
|
|
93
96
|
const quote = await timeout(async () => {
|
|
94
97
|
const quote = await provider.quote(options);
|
|
95
|
-
if (!quote)
|
|
96
|
-
return null;
|
|
97
98
|
const { expectedAmount } = getExpectedReturn(quote.rawAmountOut, 0, this.options.partnerCommissionBps, this.options.tipBps);
|
|
98
99
|
quote.amountOut = expectedAmount;
|
|
99
100
|
return quote;
|
|
100
|
-
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.
|
|
101
|
+
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinInType} to ${options.coinOutType}`);
|
|
102
|
+
if (simulation) {
|
|
103
|
+
if (simulation.onSimulated) {
|
|
104
|
+
this._simulate(provider, quote, simulation).then((payload) => {
|
|
105
|
+
if (payload) {
|
|
106
|
+
simulation.onSimulated?.(payload);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const updated = await this._simulate(provider, quote, simulation);
|
|
112
|
+
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
113
|
+
quote.gasUsed = updated?.gasUsed;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
101
116
|
return quote;
|
|
102
117
|
}
|
|
103
|
-
async _fastSwap({ quote, signer, useGasCoin, signTransaction }, getTransactionBlockParams) {
|
|
104
|
-
const tx = new Transaction();
|
|
105
|
-
const coin = await this.swap({
|
|
106
|
-
quote,
|
|
107
|
-
signer,
|
|
108
|
-
tx,
|
|
109
|
-
coinIn: coinWithBalance({
|
|
110
|
-
type: quote.coinTypeIn,
|
|
111
|
-
balance: BigInt(quote.amountIn),
|
|
112
|
-
useGasCoin,
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
tx.transferObjects([coin], signer);
|
|
116
|
-
tx.setSenderIfNotSet(signer);
|
|
117
|
-
const txBytes = await tx.build({ client: this.client });
|
|
118
|
-
const { signature, bytes } = await signTransaction(toBase64(txBytes));
|
|
119
|
-
return this.client.executeTransactionBlock({
|
|
120
|
-
transactionBlock: bytes,
|
|
121
|
-
signature,
|
|
122
|
-
options: getTransactionBlockParams?.options,
|
|
123
|
-
signal: getTransactionBlockParams?.signal,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
118
|
/**
|
|
127
119
|
* Get quotes from all providers
|
|
128
120
|
* @param options - quote options
|
|
@@ -132,38 +124,23 @@ export class MetaAg {
|
|
|
132
124
|
async quote(options, simulation) {
|
|
133
125
|
const opts = {
|
|
134
126
|
...options,
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
coinInType: normalizeStructTag(options.coinInType),
|
|
128
|
+
coinOutType: normalizeStructTag(options.coinOutType),
|
|
137
129
|
};
|
|
138
130
|
const quotes = await Promise.allSettled(Object.entries(this.options.providers)
|
|
139
131
|
.filter(([_k, v]) => !v.disabled)
|
|
140
132
|
.map(async ([provider]) => {
|
|
141
133
|
const p = await this._getProvider(provider);
|
|
142
|
-
return this._quote(p, opts);
|
|
134
|
+
return this._quote(p, opts, simulation);
|
|
143
135
|
}));
|
|
144
|
-
|
|
136
|
+
return quotes
|
|
145
137
|
.map((quote) => quote.status === "fulfilled"
|
|
146
138
|
? quote.value
|
|
147
139
|
: (console.log(quote.reason), null))
|
|
148
140
|
.filter((quote) => quote !== null);
|
|
149
|
-
if (simulation) {
|
|
150
|
-
const requests = result.map(async (quote) => {
|
|
151
|
-
const provider = await this._getProvider(quote.provider);
|
|
152
|
-
const updated = await this._simulate(provider, quote, simulation);
|
|
153
|
-
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
154
|
-
quote.gasUsed = updated?.gasUsed;
|
|
155
|
-
simulation?.onSimulated?.({ ...quote });
|
|
156
|
-
});
|
|
157
|
-
if (!simulation.onSimulated) {
|
|
158
|
-
await Promise.all(requests);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
141
|
}
|
|
163
142
|
/**
|
|
164
143
|
* Build transaction from quote
|
|
165
|
-
* @info Use this function to build composable transaction (ie: add more commands after the swap, consume the coin out object)
|
|
166
|
-
* @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie: BluefinX, Okx, ...) are not supported, please use `fastSwap` instead
|
|
167
144
|
* @param options - build tx options
|
|
168
145
|
* @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
|
|
169
146
|
* @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
|
|
@@ -171,32 +148,11 @@ export class MetaAg {
|
|
|
171
148
|
async swap(options, slippageBps) {
|
|
172
149
|
const provider = await this._getProvider(options.quote.provider);
|
|
173
150
|
assert(!!provider, `Provider not found: ${options.quote.provider}`);
|
|
174
|
-
assert(isAggregatorProvider(provider), `Provider does not support swap: ${provider.kind}`);
|
|
175
151
|
const coinOut = await provider.swap(options);
|
|
176
152
|
options.tx.add(metaSettle(options.quote, coinOut, slippageBps ?? this.options.slippageBps ?? 100, this.options.tipBps, this.options.partner, this.options.partnerCommissionBps));
|
|
177
153
|
options.tx.setSenderIfNotSet(options.signer);
|
|
178
154
|
return coinOut;
|
|
179
155
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Build, Sign, and Execute transaction in one step
|
|
182
|
-
* @param options - fast swap options
|
|
183
|
-
* @returns - txDigest of the transaction
|
|
184
|
-
*/
|
|
185
|
-
async fastSwap(options, getTransactionBlockParams) {
|
|
186
|
-
const provider = await this._getProvider(options.quote.provider);
|
|
187
|
-
if (isAggregatorProvider(provider)) {
|
|
188
|
-
return this._fastSwap(options, getTransactionBlockParams);
|
|
189
|
-
}
|
|
190
|
-
else if (isSwapAPIProvider(provider)) {
|
|
191
|
-
return this.client.waitForTransaction({
|
|
192
|
-
...getTransactionBlockParams,
|
|
193
|
-
digest: await provider.fastSwap(options),
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
throw new Error(`Provider not supported: ${provider.kind}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
156
|
/**
|
|
201
157
|
* Update meta aggregator options
|
|
202
158
|
* @param options - update options payload
|
|
@@ -229,17 +185,71 @@ export class MetaAg {
|
|
|
229
185
|
}
|
|
230
186
|
}
|
|
231
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* this settlement does not charge commission fee for partner, since all integrated aggregators already charge commission fee for partner
|
|
190
|
+
* @param quote Meta Aggregator Quote
|
|
191
|
+
* @param coinOut Coin Out Object
|
|
192
|
+
* @param slippageBps Slippage Bps
|
|
193
|
+
* @param tipBps Tip Bps default = 0
|
|
194
|
+
* @param partner address of partner for analytic default is zero address
|
|
195
|
+
*/
|
|
196
|
+
const metaSettle = (quote, coinOut, slippageBps = 100, tipBps = 0, partner, commissionBps = 0) => {
|
|
197
|
+
return (tx) => {
|
|
198
|
+
const { minAmount, expectedAmount } = getExpectedReturn(quote.rawAmountOut, slippageBps, commissionBps, tipBps);
|
|
199
|
+
if (tipBps > 0) {
|
|
200
|
+
tx.moveCall({
|
|
201
|
+
target: `${_7K_META_PUBLISHED_AT}::vault::collect_tip`,
|
|
202
|
+
typeArguments: [quote.coinTypeOut],
|
|
203
|
+
arguments: [
|
|
204
|
+
tx.object(_7K_META_VAULT),
|
|
205
|
+
tx.object(_7K_META_CONFIG),
|
|
206
|
+
coinOut,
|
|
207
|
+
tx.pure.u64(tipBps),
|
|
208
|
+
],
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
tx.moveCall({
|
|
212
|
+
target: `${_7K_META_PUBLISHED_AT}::settle::settle`,
|
|
213
|
+
typeArguments: [quote.coinTypeIn, quote.coinTypeOut],
|
|
214
|
+
arguments: [
|
|
215
|
+
tx.object(_7K_META_CONFIG),
|
|
216
|
+
tx.object(_7K_META_VAULT),
|
|
217
|
+
tx.pure.u64(quote.amountIn),
|
|
218
|
+
coinOut,
|
|
219
|
+
tx.pure.u64(minAmount),
|
|
220
|
+
tx.pure.u64(expectedAmount),
|
|
221
|
+
tx.pure.option("address", partner),
|
|
222
|
+
tx.pure.u64(commissionBps),
|
|
223
|
+
tx.pure.u64(0), // ps
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
const extractAmountOutWrapper = (events) => {
|
|
229
|
+
const swapEvent = events
|
|
230
|
+
.filter((event) => event.type === `${_7K_META_PACKAGE_ID}::settle::Swap`)
|
|
231
|
+
?.pop();
|
|
232
|
+
return swapEvent?.parsedJson?.amount_out;
|
|
233
|
+
};
|
|
232
234
|
const catchImportError = (provider) => {
|
|
233
235
|
return (e) => {
|
|
234
236
|
const map = {
|
|
235
237
|
[EProvider.CETUS]: "@cetusprotocol/aggregator-sdk",
|
|
236
238
|
[EProvider.FLOWX]: "@flowx-finance/sdk",
|
|
237
239
|
[EProvider.BLUEFIN7K]: "@7kprotocol/sdk-ts",
|
|
238
|
-
[EProvider.ASTRO]: "@naviprotocol/astros-aggregator-sdk",
|
|
239
|
-
[EProvider.OKX]: "",
|
|
240
|
-
[EProvider.BLUEFINX]: "",
|
|
241
240
|
};
|
|
242
241
|
console.warn(`Please install ${map[provider]} to use ${provider} provider`);
|
|
243
242
|
throw e;
|
|
244
243
|
};
|
|
245
244
|
};
|
|
245
|
+
const timeout = async (fn, timeout, msg) => {
|
|
246
|
+
if (timeout <= 0)
|
|
247
|
+
return fn();
|
|
248
|
+
return new Promise((resolve, reject) => {
|
|
249
|
+
const timer = setTimeout(() => reject(new Error(`Timeout ${msg ?? "operation"}`)), timeout);
|
|
250
|
+
fn()
|
|
251
|
+
.then(resolve)
|
|
252
|
+
.catch(reject)
|
|
253
|
+
.finally(() => clearTimeout(timer));
|
|
254
|
+
});
|
|
255
|
+
};
|
|
@@ -2,6 +2,7 @@ import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui
|
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
import { Config } from "../../../config";
|
|
4
4
|
import { _7K_PARTNER_ADDRESS } from "../../../constants/_7k";
|
|
5
|
+
import { API_ENDPOINTS } from "../../../constants/apiEndpoints";
|
|
5
6
|
import { EProvider, } from "../../../types/metaAg";
|
|
6
7
|
import { assert } from "../../../utils/condition";
|
|
7
8
|
import { buildTxV2 } from "../../swap/buildTxV2";
|
|
@@ -19,8 +20,6 @@ export class BluefinProvider {
|
|
|
19
20
|
const pythConnection = new SuiPriceServiceConnection(this.metaOptions.hermesApi);
|
|
20
21
|
if (options.apiKey)
|
|
21
22
|
Config.setApiKey(options.apiKey);
|
|
22
|
-
if (options.api)
|
|
23
|
-
Config.setApi(options.api);
|
|
24
23
|
Config.setSuiClient(client);
|
|
25
24
|
Config.setPythClient(pythClient);
|
|
26
25
|
Config.setPythConnection(pythConnection);
|
|
@@ -28,8 +27,9 @@ export class BluefinProvider {
|
|
|
28
27
|
async quote(options) {
|
|
29
28
|
const quote = await getQuote({
|
|
30
29
|
amountIn: options.amountIn,
|
|
31
|
-
tokenIn: options.
|
|
32
|
-
tokenOut: options.
|
|
30
|
+
tokenIn: options.coinInType,
|
|
31
|
+
tokenOut: options.coinOutType,
|
|
32
|
+
api: this.options.api || API_ENDPOINTS.MAIN,
|
|
33
33
|
sources: this.options.sources,
|
|
34
34
|
maxPaths: this.options.maxPaths,
|
|
35
35
|
excludedPools: this.options.excludedPools,
|
|
@@ -42,8 +42,8 @@ export class BluefinProvider {
|
|
|
42
42
|
amountIn: quote.swapAmountWithDecimal,
|
|
43
43
|
rawAmountOut: quote.returnAmountWithDecimal,
|
|
44
44
|
amountOut: quote.returnAmountWithDecimal,
|
|
45
|
-
coinTypeIn: options.
|
|
46
|
-
coinTypeOut: options.
|
|
45
|
+
coinTypeIn: options.coinInType,
|
|
46
|
+
coinTypeOut: options.coinOutType,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async swap({ quote, signer, tx, coinIn }) {
|
|
@@ -23,8 +23,8 @@ export class CetusProvider {
|
|
|
23
23
|
const quote = await this.cetusClient.findRouters({
|
|
24
24
|
amount: quoteOptions.amountIn,
|
|
25
25
|
byAmountIn: true,
|
|
26
|
-
from: quoteOptions.
|
|
27
|
-
target: quoteOptions.
|
|
26
|
+
from: quoteOptions.coinInType,
|
|
27
|
+
target: quoteOptions.coinOutType,
|
|
28
28
|
providers: this.options.sources,
|
|
29
29
|
splitCount: this.options.splitCount,
|
|
30
30
|
splitAlgorithm: this.options.splitAlgorithm,
|
|
@@ -40,8 +40,8 @@ export class CetusProvider {
|
|
|
40
40
|
amountIn: quote.amountIn.toString() || "0",
|
|
41
41
|
rawAmountOut: quote.amountOut.toString() || "0",
|
|
42
42
|
amountOut: quote.amountOut.toString() || "0",
|
|
43
|
-
coinTypeIn: quoteOptions.
|
|
44
|
-
coinTypeOut: quoteOptions.
|
|
43
|
+
coinTypeIn: quoteOptions.coinInType,
|
|
44
|
+
coinTypeOut: quoteOptions.coinOutType,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
async swap(options) {
|
|
@@ -16,8 +16,8 @@ export class FlowxProvider {
|
|
|
16
16
|
async quote(quoteOptions) {
|
|
17
17
|
const quote = await this.quoter.getRoutes({
|
|
18
18
|
amountIn: quoteOptions.amountIn,
|
|
19
|
-
tokenIn: quoteOptions.
|
|
20
|
-
tokenOut: quoteOptions.
|
|
19
|
+
tokenIn: quoteOptions.coinInType,
|
|
20
|
+
tokenOut: quoteOptions.coinOutType,
|
|
21
21
|
includeSources: this.options.sources,
|
|
22
22
|
excludePools: this.options.excludePools,
|
|
23
23
|
excludeSources: this.options.excludeSources,
|
|
@@ -31,8 +31,8 @@ export class FlowxProvider {
|
|
|
31
31
|
amountIn: quote.amountIn?.toString() ?? "0",
|
|
32
32
|
rawAmountOut: quote.amountOut?.toString() ?? "0",
|
|
33
33
|
amountOut: quote.amountOut?.toString() ?? "0",
|
|
34
|
-
coinTypeIn: quoteOptions.
|
|
35
|
-
coinTypeOut: quoteOptions.
|
|
34
|
+
coinTypeIn: quoteOptions.coinInType,
|
|
35
|
+
coinTypeOut: quoteOptions.coinOutType,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
async swap(options) {
|
|
@@ -168,9 +168,6 @@ export const buildBluefinXTx = async (tx, accountAddress, quoteResponse) => {
|
|
|
168
168
|
if (extra.quoteExpiresAtUtcMillis < Date.now()) {
|
|
169
169
|
throw new Error("Quote expired");
|
|
170
170
|
}
|
|
171
|
-
if (extra.taker !== accountAddress) {
|
|
172
|
-
throw new Error("Sender mismatch with quote");
|
|
173
|
-
}
|
|
174
171
|
tx.setSenderIfNotSet(accountAddress);
|
|
175
172
|
const bytes = await tx.build({
|
|
176
173
|
client: Config.getSuiClient(),
|
|
@@ -12,10 +12,7 @@ import { getConfig } from "./config";
|
|
|
12
12
|
* 2. Merging redundant swaps to the same pool within each wave
|
|
13
13
|
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
14
14
|
*/
|
|
15
|
-
export const buildTxV2 = async (
|
|
16
|
-
return buildTxV2Int(params);
|
|
17
|
-
};
|
|
18
|
-
export const buildTxV2Int = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }, beforeBuildBluefinXTx) => {
|
|
15
|
+
export const buildTxV2 = async ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }) => {
|
|
19
16
|
const isBluefinX = isBluefinXRouting(quoteResponse);
|
|
20
17
|
const _commission = {
|
|
21
18
|
...__commission,
|
|
@@ -61,7 +58,6 @@ export const buildTxV2Int = async ({ quoteResponse, accountAddress, slippage, co
|
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
if (isBluefinX) {
|
|
64
|
-
beforeBuildBluefinXTx?.(tx, coinOut);
|
|
65
61
|
return {
|
|
66
62
|
tx: await buildBluefinXTx(tx, accountAddress, quoteResponse),
|
|
67
63
|
coinOut,
|
|
@@ -70,7 +66,7 @@ export const buildTxV2Int = async ({ quoteResponse, accountAddress, slippage, co
|
|
|
70
66
|
tx.setSenderIfNotSet(accountAddress);
|
|
71
67
|
return { tx, coinOut };
|
|
72
68
|
};
|
|
73
|
-
const optimize = async (pythMap, config, routes, coinData, tx, accountAddress) => {
|
|
69
|
+
export const optimize = async (pythMap, config, routes, coinData, tx, accountAddress) => {
|
|
74
70
|
// Initialize route states with split coins
|
|
75
71
|
const routeStates = routes.map((route, index) => ({
|
|
76
72
|
routeIndex: index,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Config as _Config } from "../../config";
|
|
2
1
|
import { fetchClient } from "../../config/fetchClient";
|
|
3
2
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
4
3
|
export const DEFAULT_CONFIG = {
|
|
@@ -138,7 +137,7 @@ export async function getConfig() {
|
|
|
138
137
|
return config;
|
|
139
138
|
}
|
|
140
139
|
try {
|
|
141
|
-
const response = await fetchClient(`${
|
|
140
|
+
const response = await fetchClient(`${API_ENDPOINTS.MAIN}/config`);
|
|
142
141
|
const quoteResponse = (await response.json());
|
|
143
142
|
config = { ...config, ...quoteResponse };
|
|
144
143
|
configTs = Date.now();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
2
|
-
import { Config } from "../../config";
|
|
3
2
|
import { fetchClient } from "../../config/fetchClient";
|
|
4
3
|
import { API_ENDPOINTS } from "../../constants/apiEndpoints";
|
|
5
4
|
import { isBluefinXRouting, } from "../../types/aggregator";
|
|
@@ -37,7 +36,7 @@ export const ORACLE_BASED_SOURCES = new Set([
|
|
|
37
36
|
"steamm_oracle_quoter",
|
|
38
37
|
"steamm_oracle_quoter_v2",
|
|
39
38
|
]);
|
|
40
|
-
export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
|
|
39
|
+
export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, api, maxPaths, }) {
|
|
41
40
|
let sources = _sources;
|
|
42
41
|
if (isSponsored) {
|
|
43
42
|
sources = _sources.filter((s) => !ORACLE_BASED_SOURCES.has(s));
|
|
@@ -60,7 +59,7 @@ export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources
|
|
|
60
59
|
if (maxPaths) {
|
|
61
60
|
params.append("max_paths", maxPaths.toString());
|
|
62
61
|
}
|
|
63
|
-
const response = await fetchClient(`${
|
|
62
|
+
const response = await fetchClient(`${api || API_ENDPOINTS.MAIN}/quote?${params}`);
|
|
64
63
|
if (!response.ok) {
|
|
65
64
|
let responseText;
|
|
66
65
|
try {
|
|
@@ -8,7 +8,7 @@ const request = async (path, body) => {
|
|
|
8
8
|
if (bluefinXApiKey) {
|
|
9
9
|
headers.set("Bluefin-X-API-Key", bluefinXApiKey);
|
|
10
10
|
}
|
|
11
|
-
const res = await fetch(`${
|
|
11
|
+
const res = await fetch(`${API_ENDPOINTS.MAIN}/${path}`, {
|
|
12
12
|
method: "POST",
|
|
13
13
|
body: JSON.stringify(body),
|
|
14
14
|
headers,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
|
|
3
|
-
declare function setApi(url: string): void;
|
|
4
|
-
declare function getApi(): string;
|
|
5
3
|
declare function setApiKey(key: string): void;
|
|
6
4
|
declare function getApiKey(): string;
|
|
7
5
|
declare function setBluefinXApiKey(key: string): void;
|
|
@@ -13,8 +11,6 @@ declare function getPythClient(): SuiPythClient;
|
|
|
13
11
|
declare function setPythConnection(connection: SuiPriceServiceConnection): void;
|
|
14
12
|
declare function getPythConnection(): SuiPriceServiceConnection;
|
|
15
13
|
declare const Config: {
|
|
16
|
-
setApi: typeof setApi;
|
|
17
|
-
getApi: typeof getApi;
|
|
18
14
|
setApiKey: typeof setApiKey;
|
|
19
15
|
getApiKey: typeof getApiKey;
|
|
20
16
|
setBluefinXApiKey: typeof setBluefinXApiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAsBlC,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEpC;AAED,iBAAS,SAAS,IAAI,MAAM,CAE3B;AAED,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,iBAAS,iBAAiB,IAAI,MAAM,CAEnC;AAED,iBAAS,YAAY,IAAI,SAAS,CAEjC;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE7C;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAElD;AAED,iBAAS,aAAa,IAAI,aAAa,CAEtC;AAED,iBAAS,iBAAiB,CAAC,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAEtE;AAED,iBAAS,iBAAiB,IAAI,yBAAyB,CAEtD;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;CAWX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import { MetaAgOptions,
|
|
3
|
+
import { MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSimulationOptions, MetaSwapOptions } from "../../types/metaAg";
|
|
4
4
|
export declare class MetaAg {
|
|
5
5
|
client: SuiClient;
|
|
6
6
|
private providers;
|
|
@@ -10,7 +10,6 @@ export declare class MetaAg {
|
|
|
10
10
|
private _getProvider;
|
|
11
11
|
private _simulate;
|
|
12
12
|
private _quote;
|
|
13
|
-
private _fastSwap;
|
|
14
13
|
/**
|
|
15
14
|
* Get quotes from all providers
|
|
16
15
|
* @param options - quote options
|
|
@@ -20,19 +19,11 @@ export declare class MetaAg {
|
|
|
20
19
|
quote(options: MetaQuoteOptions, simulation?: MetaSimulationOptions): Promise<MetaQuote[]>;
|
|
21
20
|
/**
|
|
22
21
|
* Build transaction from quote
|
|
23
|
-
* @info Use this function to build composable transaction (ie: add more commands after the swap, consume the coin out object)
|
|
24
|
-
* @warning Providers that build transaction on the fly (typically RFQ, Swap-API providers ie: BluefinX, Okx, ...) are not supported, please use `fastSwap` instead
|
|
25
22
|
* @param options - build tx options
|
|
26
23
|
* @param slippageBps - slippage bps if not specified, fallback to global slippage bps, if none of them specified, default to 100
|
|
27
24
|
* @returns coin out object, you must consume it by transferObjects, or other sub sequence commands
|
|
28
25
|
*/
|
|
29
26
|
swap(options: MetaSwapOptions, slippageBps?: number): Promise<TransactionObjectArgument>;
|
|
30
|
-
/**
|
|
31
|
-
* Build, Sign, and Execute transaction in one step
|
|
32
|
-
* @param options - fast swap options
|
|
33
|
-
* @returns - txDigest of the transaction
|
|
34
|
-
*/
|
|
35
|
-
fastSwap(options: MetaFastSwapOptions, getTransactionBlockParams?: Omit<GetTransactionBlockParams, "digest">): Promise<SuiTransactionBlockResponse>;
|
|
36
27
|
/**
|
|
37
28
|
* Update meta aggregator options
|
|
38
29
|
* @param options - update options payload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,9 +1,9 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
|
-
import {
|
|
3
|
-
export declare class BluefinProvider implements
|
|
2
|
+
import { AgProvider, BluefinProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
3
|
+
export declare class BluefinProvider implements AgProvider {
|
|
4
4
|
private readonly options;
|
|
5
5
|
private readonly metaOptions;
|
|
6
|
-
|
|
6
|
+
kind: EProvider;
|
|
7
7
|
constructor(options: BluefinProviderOptions, metaOptions: Required<MetaAgOptions>, client: SuiClient);
|
|
8
8
|
quote(options: MetaQuoteOptions): Promise<MetaQuote>;
|
|
9
9
|
swap({ quote, signer, tx, coinIn }: MetaSwapOptions): Promise<import("@mysten/sui/dist/cjs/transactions").TransactionObjectArgument>;
|
|
@@ -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;
|
|
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"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
+
import { AgProvider, CetusProviderOptions, EProvider, MetaAgOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
|
+
export declare class CetusProvider implements AgProvider {
|
|
4
5
|
private readonly options;
|
|
5
|
-
|
|
6
|
+
kind: EProvider;
|
|
6
7
|
private readonly cetusClient;
|
|
7
8
|
constructor(options: CetusProviderOptions, metaOptions: MetaAgOptions, client: SuiClient);
|
|
8
9
|
quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
9
|
-
swap(options: MetaSwapOptions): Promise<
|
|
10
|
+
swap(options: MetaSwapOptions): Promise<TransactionObjectArgument>;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=cetus.d.ts.map
|
|
@@ -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;
|
|
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,10 +1,10 @@
|
|
|
1
1
|
import { SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import { TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
3
|
-
import {
|
|
4
|
-
export declare class FlowxProvider implements
|
|
3
|
+
import { AgProvider, EProvider, FlowxProviderOptions, MetaQuote, MetaQuoteOptions, MetaSwapOptions } from "../../../types/metaAg";
|
|
4
|
+
export declare class FlowxProvider implements AgProvider {
|
|
5
5
|
private readonly options;
|
|
6
6
|
private readonly client;
|
|
7
|
-
|
|
7
|
+
kind: EProvider;
|
|
8
8
|
private quoter;
|
|
9
9
|
constructor(options: FlowxProviderOptions, client: SuiClient);
|
|
10
10
|
quote(quoteOptions: MetaQuoteOptions): Promise<MetaQuote>;
|
|
@@ -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;AAGrE,OAAO,EACL,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EACL,aAAa,EACb,UAAU,EAEV,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,eAAO,MAAM,OAAO,GAAU,2GAQ3B,aAAa,KAAG,OAAO,CAAC,aAAa,CA+FvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,aAAa,EAAE,aAa3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,IAAI,WAAW,EACf,eAAe,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"buildTx.d.ts","sourceRoot":"","sources":["../../../../../src/features/swap/buildTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EACL,aAAa,EACb,UAAU,EAEV,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,eAAO,MAAM,OAAO,GAAU,2GAQ3B,aAAa,KAAG,OAAO,CAAC,aAAa,CA+FvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,WAAW,aAAa,EAAE,aAa3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,IAAI,WAAW,EACf,eAAe,aAAa,EAAE,oCAkB/B,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,QAAQ,SAAS,EAAE,EAAE,EACrB,cAAc,OAAO,SAWtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,eAAe,MAAM,EACrB,SAAQ,MAAU;;;;;CA8BnB,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,aAAa,yBAAyB,EAAE,EACxC,eAAe,aAAa,EAC5B,aAAa,MAAM,EACnB,aAAa,UAAU,MAEf,IAAI,WAAW,8BAiCxB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,IAAI,WAAW,EACf,gBAAgB,MAAM,EACtB,eAAe,aAAa,wBAsB7B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
-
import { BuildTxResult } from "../../types/aggregator";
|
|
2
|
+
import { BuildTxResult, Config, TxSorSwap } from "../../types/aggregator";
|
|
3
3
|
import { BuildTxParams, MultiSwapParams } from "../../types/tx";
|
|
4
4
|
/**
|
|
5
5
|
* Wave-based transaction builder that optimizes swap execution by:
|
|
@@ -7,8 +7,8 @@ import { BuildTxParams, MultiSwapParams } from "../../types/tx";
|
|
|
7
7
|
* 2. Merging redundant swaps to the same pool within each wave
|
|
8
8
|
* 3. Processing waves sequentially, passing intermediate tokens between waves
|
|
9
9
|
*/
|
|
10
|
-
export declare const buildTxV2: (
|
|
11
|
-
export declare const
|
|
10
|
+
export declare const buildTxV2: ({ quoteResponse, accountAddress, slippage, commission: __commission, devInspect, extendTx, isSponsored, }: BuildTxParams) => Promise<BuildTxResult>;
|
|
11
|
+
export declare const optimize: (pythMap: Record<string, string>, config: Config, routes: TxSorSwap[][], coinData: TransactionObjectArgument[], tx: Transaction, accountAddress: string) => Promise<TransactionObjectArgument[]>;
|
|
12
12
|
/**
|
|
13
13
|
* execute multiple swap in single transaction
|
|
14
14
|
*
|