@minswap/noodles-sdk 0.0.12 → 0.0.13
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/dist/index.cjs +1 -1687
- package/dist/index.js +1 -1512
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,1687 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
TradeFeeOptions: ()=>types_TradeFeeOptions,
|
|
37
|
-
getMoveObjectContent: ()=>getMoveObjectContent,
|
|
38
|
-
MoonbagsCalculation: ()=>calculation_MoonbagsCalculation,
|
|
39
|
-
SevenKAggregator: ()=>_7k_SevenKAggregator,
|
|
40
|
-
SupportedBondingCurve: ()=>types_SupportedBondingCurve,
|
|
41
|
-
CLOCK_OBJECT_ID: ()=>CLOCK_OBJECT_ID,
|
|
42
|
-
BlastFunCustomCalculation: ()=>custom_calculation_BlastFunCustomCalculation,
|
|
43
|
-
BluefinTx: ()=>bluefin_BluefinTx,
|
|
44
|
-
Bps: ()=>package_Bps,
|
|
45
|
-
BlastFunCustomTransaction: ()=>custom_transaction_BlastFunCustomTransaction,
|
|
46
|
-
BASE_BPS: ()=>BASE_BPS,
|
|
47
|
-
MoonbagsConstants: ()=>constants_MoonbagsConstants,
|
|
48
|
-
splitSuiCoinAfterFeeFromBuyTx: ()=>splitSuiCoinAfterFeeFromBuyTx,
|
|
49
|
-
DraftTransferTx: ()=>DraftTransferTx,
|
|
50
|
-
SUI_FULL_TYPE: ()=>SUI_FULL_TYPE,
|
|
51
|
-
getSplitCoinForTx: ()=>getSplitCoinForTx,
|
|
52
|
-
BlastFunSDKTransaction: ()=>sdk_transaction_BlastFunSDKTransaction,
|
|
53
|
-
AstrosAggregator: ()=>astros_AstrosAggregator,
|
|
54
|
-
SUI_TYPE: ()=>SUI_TYPE,
|
|
55
|
-
AftermathAggregator: ()=>aftermath_AftermathAggregator,
|
|
56
|
-
getSplitCoinsAfterFee: ()=>getSplitCoinsAfterFee,
|
|
57
|
-
addGasFee: ()=>addGasFee,
|
|
58
|
-
MoonbagsPackage: ()=>package_MoonbagsPackage,
|
|
59
|
-
NATIVE_USDC_TOKEN_TYPE: ()=>NATIVE_USDC_TOKEN_TYPE,
|
|
60
|
-
USDC_TOKEN_TYPE: ()=>USDC_TOKEN_TYPE,
|
|
61
|
-
getAmountAfterFee: ()=>getAmountAfterFee,
|
|
62
|
-
SUI_METADATA_OBJECT_ID: ()=>SUI_METADATA_OBJECT_ID,
|
|
63
|
-
SupportedAggregator: ()=>common_SupportedAggregator,
|
|
64
|
-
splitSuiCoinAfterFeeFromSellTx: ()=>splitSuiCoinAfterFeeFromSellTx,
|
|
65
|
-
createCompatibleSuiClient: ()=>createCompatibleSuiClient,
|
|
66
|
-
BLUEFIN_PACKAGE_ID: ()=>BLUEFIN_PACKAGE_ID,
|
|
67
|
-
MoonbagsTransaction: ()=>transaction_MoonbagsTransaction,
|
|
68
|
-
BlastFunConstants: ()=>constants_BlastFunConstants,
|
|
69
|
-
CetusAggregator: ()=>cetus_CetusAggregator,
|
|
70
|
-
adaptSuiClient: ()=>adaptSuiClient,
|
|
71
|
-
getCoinObjectIdsByAmount: ()=>getCoinObjectIdsByAmount,
|
|
72
|
-
getMoveObject: ()=>getMoveObject,
|
|
73
|
-
FlowXAggregator: ()=>flowx_FlowXAggregator,
|
|
74
|
-
adaptTransaction: ()=>adaptTransaction,
|
|
75
|
-
MathUtils: ()=>package_MathUtils,
|
|
76
|
-
BlastFunSDKCalculation: ()=>sdk_calculation_BlastFunSDKCalculation,
|
|
77
|
-
BlastFunPackage: ()=>package_BlastFunPackage,
|
|
78
|
-
getMemezPumpSDK: ()=>getMemezPumpSDK,
|
|
79
|
-
getNeededGasFee: ()=>getNeededGasFee
|
|
80
|
-
});
|
|
81
|
-
const cjs_namespaceObject = require("@7kprotocol/sdk-ts/cjs");
|
|
82
|
-
const transactions_namespaceObject = require("@mysten/sui/transactions");
|
|
83
|
-
const external_bignumber_js_namespaceObject = require("bignumber.js");
|
|
84
|
-
var external_bignumber_js_default = /*#__PURE__*/ __webpack_require__.n(external_bignumber_js_namespaceObject);
|
|
85
|
-
class _7k_SevenKAggregator {
|
|
86
|
-
_config;
|
|
87
|
-
_suiClient;
|
|
88
|
-
constructor(config, suiClient){
|
|
89
|
-
this._config = config;
|
|
90
|
-
this._suiClient = suiClient;
|
|
91
|
-
}
|
|
92
|
-
async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
|
|
93
|
-
try {
|
|
94
|
-
if (this._config.sevenKApiKey) cjs_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);
|
|
95
|
-
const tradeFeePercent = tradeFee ? tradeFee.tradeFeePercent : this._config.defaultTradeFee.tradeFeePercent;
|
|
96
|
-
return (0, cjs_namespaceObject.getQuote)({
|
|
97
|
-
tokenIn: coinInType,
|
|
98
|
-
tokenOut: coinOutType,
|
|
99
|
-
amountIn: coinInAmount.toString(),
|
|
100
|
-
commissionBps: 10000 * tradeFeePercent
|
|
101
|
-
});
|
|
102
|
-
} catch (_err) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async getTransaction({ walletAddress, completeRoute, slippage, tradeFee }) {
|
|
107
|
-
let tradeFeePercent;
|
|
108
|
-
let tradeFeeRecipientAddress;
|
|
109
|
-
if (tradeFee) {
|
|
110
|
-
tradeFeePercent = tradeFee.tradeFeePercent;
|
|
111
|
-
tradeFeeRecipientAddress = tradeFee.tradeFeeRecipientAddress;
|
|
112
|
-
} else {
|
|
113
|
-
tradeFeePercent = this._config.defaultTradeFee.tradeFeePercent;
|
|
114
|
-
tradeFeeRecipientAddress = this._config.defaultTradeFee.tradeFeeRecipientAddress;
|
|
115
|
-
}
|
|
116
|
-
const transaction = await (0, cjs_namespaceObject.buildTx)({
|
|
117
|
-
quoteResponse: completeRoute,
|
|
118
|
-
slippage,
|
|
119
|
-
accountAddress: walletAddress,
|
|
120
|
-
commission: {
|
|
121
|
-
partner: tradeFeeRecipientAddress,
|
|
122
|
-
commissionBps: 10000 * tradeFeePercent
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
if (transaction.tx instanceof cjs_namespaceObject.BluefinXTx) {
|
|
126
|
-
const newTransaction = transactions_namespaceObject.Transaction.from(transaction.tx.txBytes);
|
|
127
|
-
return newTransaction.build({
|
|
128
|
-
client: this._suiClient
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
transaction.tx.setSender(walletAddress);
|
|
132
|
-
return transaction.tx.build({
|
|
133
|
-
client: this._suiClient
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
(function(SevenKAggregator) {
|
|
138
|
-
function toCommonTradeRoutes(tradeRouteResponse) {
|
|
139
|
-
const routes = [];
|
|
140
|
-
if (!tradeRouteResponse.routes || 0 === tradeRouteResponse.routes.length) return null;
|
|
141
|
-
for (const route of tradeRouteResponse.routes){
|
|
142
|
-
const paths = [];
|
|
143
|
-
const allTokenDecimal = {};
|
|
144
|
-
for (const path of route.hops){
|
|
145
|
-
for (const t of path.pool.allTokens)allTokenDecimal[t.address] = t.decimal;
|
|
146
|
-
const pathDecimalIn = allTokenDecimal[path.tokenIn] ?? 0;
|
|
147
|
-
const pathDecimalOut = allTokenDecimal[path.tokenOut] ?? 0;
|
|
148
|
-
const pathAmountIn = BigInt(new (external_bignumber_js_default())(path.tokenInAmount).multipliedBy(10 ** pathDecimalIn).toFixed(0, 3));
|
|
149
|
-
const pathAmountOut = BigInt(new (external_bignumber_js_default())(path.tokenOutAmount).multipliedBy(10 ** pathDecimalOut).toFixed(0, 3));
|
|
150
|
-
paths.push({
|
|
151
|
-
poolAddress: path.poolId,
|
|
152
|
-
coinIn: path.tokenIn,
|
|
153
|
-
coinOut: path.tokenOut,
|
|
154
|
-
amountIn: pathAmountIn,
|
|
155
|
-
amountOut: pathAmountOut
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
if (0 === paths.length) continue;
|
|
159
|
-
const routeDecimalIn = allTokenDecimal[route.tokenIn] ?? 0;
|
|
160
|
-
const routeDecimalOut = allTokenDecimal[route.tokenOut] ?? 0;
|
|
161
|
-
const routeAmountIn = BigInt(new (external_bignumber_js_default())(route.tokenInAmount).multipliedBy(10 ** routeDecimalIn).toFixed(0, 3));
|
|
162
|
-
const routeAmountOut = BigInt(new (external_bignumber_js_default())(route.tokenOutAmount).multipliedBy(10 ** routeDecimalOut).toFixed(0, 3));
|
|
163
|
-
routes.push({
|
|
164
|
-
paths: paths,
|
|
165
|
-
coinIn: route.tokenIn,
|
|
166
|
-
coinOut: route.tokenOut,
|
|
167
|
-
amountIn: routeAmountIn,
|
|
168
|
-
amountOut: routeAmountOut
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (0 === routes.length) return null;
|
|
172
|
-
return {
|
|
173
|
-
coinIn: tradeRouteResponse.tokenIn,
|
|
174
|
-
coinOut: tradeRouteResponse.tokenOut,
|
|
175
|
-
amountIn: BigInt(tradeRouteResponse.swapAmountWithDecimal),
|
|
176
|
-
amountOut: BigInt(tradeRouteResponse.returnAmountWithDecimal),
|
|
177
|
-
routes: routes
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
SevenKAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
|
|
181
|
-
})(_7k_SevenKAggregator || (_7k_SevenKAggregator = {}));
|
|
182
|
-
const external_aftermath_ts_sdk_namespaceObject = require("aftermath-ts-sdk");
|
|
183
|
-
class aftermath_AftermathAggregator {
|
|
184
|
-
_config;
|
|
185
|
-
_aftermathClient;
|
|
186
|
-
_suiClient;
|
|
187
|
-
constructor(config, suiClient){
|
|
188
|
-
this._config = config;
|
|
189
|
-
this._suiClient = suiClient;
|
|
190
|
-
}
|
|
191
|
-
async aftermathClient() {
|
|
192
|
-
if (this._aftermathClient) return this._aftermathClient;
|
|
193
|
-
if (this._config.aftermathApiEndpoint) this._aftermathClient = new external_aftermath_ts_sdk_namespaceObject.Aftermath(this._config.aftermathApiEndpoint);
|
|
194
|
-
else this._aftermathClient = new external_aftermath_ts_sdk_namespaceObject.Aftermath("MAINNET");
|
|
195
|
-
await this._aftermathClient.init();
|
|
196
|
-
if (this._config.aftermathApiKey) {
|
|
197
|
-
const keypair = external_aftermath_ts_sdk_namespaceObject.Helpers.keypairFromPrivateKey(this._config.aftermathApiKey);
|
|
198
|
-
await this._aftermathClient.Auth().init({
|
|
199
|
-
async signMessageCallback ({ message }) {
|
|
200
|
-
const { signature } = await keypair.signPersonalMessage(message);
|
|
201
|
-
return {
|
|
202
|
-
signature
|
|
203
|
-
};
|
|
204
|
-
},
|
|
205
|
-
walletAddress: keypair.toSuiAddress()
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
return this._aftermathClient;
|
|
209
|
-
}
|
|
210
|
-
async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
|
|
211
|
-
let externalFee;
|
|
212
|
-
externalFee = tradeFee ? {
|
|
213
|
-
recipient: tradeFee.tradeFeeRecipientAddress,
|
|
214
|
-
feePercentage: tradeFee.tradeFeePercent
|
|
215
|
-
} : {
|
|
216
|
-
recipient: this._config.defaultTradeFee.tradeFeeRecipientAddress,
|
|
217
|
-
feePercentage: this._config.defaultTradeFee.tradeFeePercent
|
|
218
|
-
};
|
|
219
|
-
const client = await this.aftermathClient();
|
|
220
|
-
return client.Router().getCompleteTradeRouteGivenAmountIn({
|
|
221
|
-
coinInAmount,
|
|
222
|
-
coinInType,
|
|
223
|
-
coinOutType,
|
|
224
|
-
externalFee
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
async getTransaction({ completeRoute, walletAddress, slippage }) {
|
|
228
|
-
const client = await this.aftermathClient();
|
|
229
|
-
const transaction = await client.Router().getTransactionForCompleteTradeRoute({
|
|
230
|
-
completeRoute,
|
|
231
|
-
walletAddress,
|
|
232
|
-
slippage,
|
|
233
|
-
isSponsoredTx: false
|
|
234
|
-
});
|
|
235
|
-
transaction.setSender(walletAddress);
|
|
236
|
-
return transaction.build({
|
|
237
|
-
client: this._suiClient
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
(function(AftermathAggregator) {
|
|
242
|
-
function toCommonTradeRoutes(tradeRoute) {
|
|
243
|
-
if (0 === tradeRoute.routes.length) return null;
|
|
244
|
-
const routes = [];
|
|
245
|
-
for (const route of tradeRoute.routes){
|
|
246
|
-
const paths = [];
|
|
247
|
-
for (const path of route.paths)paths.push({
|
|
248
|
-
poolAddress: path.poolId,
|
|
249
|
-
coinIn: path.coinIn.type,
|
|
250
|
-
coinOut: path.coinOut.type,
|
|
251
|
-
amountIn: BigInt(path.coinIn.amount),
|
|
252
|
-
amountOut: BigInt(path.coinOut.amount)
|
|
253
|
-
});
|
|
254
|
-
if (0 !== paths.length) routes.push({
|
|
255
|
-
paths: paths,
|
|
256
|
-
coinIn: route.coinIn.type,
|
|
257
|
-
coinOut: route.coinOut.type,
|
|
258
|
-
amountIn: route.coinIn.amount,
|
|
259
|
-
amountOut: route.coinOut.amount
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
if (0 === routes.length) return null;
|
|
263
|
-
return {
|
|
264
|
-
coinIn: tradeRoute.coinIn.type,
|
|
265
|
-
coinOut: tradeRoute.coinOut.type,
|
|
266
|
-
amountIn: tradeRoute.coinIn.amount,
|
|
267
|
-
amountOut: tradeRoute.coinOut.amount,
|
|
268
|
-
routes: routes
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
AftermathAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
|
|
272
|
-
})(aftermath_AftermathAggregator || (aftermath_AftermathAggregator = {}));
|
|
273
|
-
const astros_aggregator_sdk_namespaceObject = require("@naviprotocol/astros-aggregator-sdk");
|
|
274
|
-
function isSuiCoin(coin) {
|
|
275
|
-
return "0x2::sui::SUI" === coin || "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI" === coin;
|
|
276
|
-
}
|
|
277
|
-
class astros_AstrosAggregator {
|
|
278
|
-
_config;
|
|
279
|
-
_suiClient;
|
|
280
|
-
constructor(config, suiClient){
|
|
281
|
-
this._config = config;
|
|
282
|
-
this._suiClient = suiClient;
|
|
283
|
-
}
|
|
284
|
-
async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
|
|
285
|
-
try {
|
|
286
|
-
let serviceFee;
|
|
287
|
-
serviceFee = tradeFee ? {
|
|
288
|
-
fee: tradeFee.tradeFeePercent,
|
|
289
|
-
receiverAddress: tradeFee.tradeFeeRecipientAddress
|
|
290
|
-
} : {
|
|
291
|
-
fee: this._config.defaultTradeFee.tradeFeePercent,
|
|
292
|
-
receiverAddress: this._config.defaultTradeFee.tradeFeeRecipientAddress
|
|
293
|
-
};
|
|
294
|
-
return (0, astros_aggregator_sdk_namespaceObject.getQuote)(coinInType, coinOutType, coinInAmount, this._config.astrosApiKey, {
|
|
295
|
-
byAmountIn: true,
|
|
296
|
-
serviceFee: serviceFee
|
|
297
|
-
});
|
|
298
|
-
} catch (_err) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
returnMergedCoins(txb, coins, amount) {
|
|
303
|
-
if (coins.length < 2) return txb.object(coins[0].coinObjectId);
|
|
304
|
-
let mergedBalance = 0;
|
|
305
|
-
const mergeList = [];
|
|
306
|
-
coins.sort((a, b)=>Number(b.balance) - Number(a.balance)).slice(1).forEach((coin)=>{
|
|
307
|
-
if (mergedBalance >= amount) return;
|
|
308
|
-
mergedBalance += Number(coin.balance);
|
|
309
|
-
mergeList.push(coin.coinObjectId);
|
|
310
|
-
});
|
|
311
|
-
const baseObj = coins[0].coinObjectId;
|
|
312
|
-
txb.mergeCoins(baseObj, mergeList);
|
|
313
|
-
return txb.object(baseObj);
|
|
314
|
-
}
|
|
315
|
-
async getTransaction({ completeRoute: quote, walletAddress, slippage, tradeFee }) {
|
|
316
|
-
let serviceFee;
|
|
317
|
-
serviceFee = tradeFee ? {
|
|
318
|
-
fee: tradeFee.tradeFeePercent,
|
|
319
|
-
receiverAddress: tradeFee.tradeFeeRecipientAddress
|
|
320
|
-
} : {
|
|
321
|
-
fee: this._config.defaultTradeFee.tradeFeePercent,
|
|
322
|
-
receiverAddress: this._config.defaultTradeFee.tradeFeeRecipientAddress
|
|
323
|
-
};
|
|
324
|
-
const minAmountOut = new (external_bignumber_js_default())(quote.amount_out).multipliedBy(1 - slippage - serviceFee.fee).toNumber();
|
|
325
|
-
const txb = new transactions_namespaceObject.Transaction();
|
|
326
|
-
let coinIn;
|
|
327
|
-
if (isSuiCoin(quote.from)) coinIn = txb.splitCoins(txb.gas, [
|
|
328
|
-
txb.pure.u64(quote.amount_in)
|
|
329
|
-
]);
|
|
330
|
-
else {
|
|
331
|
-
const coins = await (0, astros_aggregator_sdk_namespaceObject.getCoins)(this._suiClient, walletAddress, quote.from);
|
|
332
|
-
const mergedCoins = this.returnMergedCoins(txb, coins.data, Number.parseFloat(quote.amount_in));
|
|
333
|
-
coinIn = txb.splitCoins(mergedCoins, [
|
|
334
|
-
txb.pure.u64(quote.amount_in)
|
|
335
|
-
]);
|
|
336
|
-
}
|
|
337
|
-
const coinB = await (0, astros_aggregator_sdk_namespaceObject.buildSwapPTBFromQuote)(walletAddress, txb, minAmountOut, coinIn, quote, void 0, false, this._config.astrosApiKey, {
|
|
338
|
-
serviceFee: serviceFee
|
|
339
|
-
});
|
|
340
|
-
txb.transferObjects([
|
|
341
|
-
coinB
|
|
342
|
-
], walletAddress);
|
|
343
|
-
txb.setSender(walletAddress);
|
|
344
|
-
return txb.build({
|
|
345
|
-
client: this._suiClient
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
(function(AstrosAggregator) {
|
|
350
|
-
function toCommonTradeRoutes(tradeRoute, coinInType, coinOutType) {
|
|
351
|
-
if (0 === tradeRoute.routes.length) return null;
|
|
352
|
-
const routes = [];
|
|
353
|
-
for (const route of tradeRoute.routes){
|
|
354
|
-
const paths = [];
|
|
355
|
-
for (const path of route.path)paths.push({
|
|
356
|
-
poolAddress: path.id,
|
|
357
|
-
coinIn: path.from,
|
|
358
|
-
coinOut: path.target,
|
|
359
|
-
amountIn: BigInt(path.amount_in),
|
|
360
|
-
amountOut: BigInt(path.amount_out)
|
|
361
|
-
});
|
|
362
|
-
if (0 !== paths.length) routes.push({
|
|
363
|
-
amountIn: BigInt(route.amount_in),
|
|
364
|
-
amountOut: BigInt(route.amount_out),
|
|
365
|
-
coinIn: paths[0].coinIn,
|
|
366
|
-
coinOut: paths[paths.length - 1].coinOut,
|
|
367
|
-
paths: paths
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
if (0 === routes.length) return null;
|
|
371
|
-
return {
|
|
372
|
-
coinIn: coinInType,
|
|
373
|
-
coinOut: coinOutType,
|
|
374
|
-
amountIn: BigInt(tradeRoute.amount_in),
|
|
375
|
-
amountOut: BigInt(tradeRoute.amount_out),
|
|
376
|
-
routes: routes
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
AstrosAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
|
|
380
|
-
})(astros_AstrosAggregator || (astros_AstrosAggregator = {}));
|
|
381
|
-
const aggregator_sdk_namespaceObject = require("@cetusprotocol/aggregator-sdk");
|
|
382
|
-
const external_bn_js_namespaceObject = require("bn.js");
|
|
383
|
-
var external_bn_js_default = /*#__PURE__*/ __webpack_require__.n(external_bn_js_namespaceObject);
|
|
384
|
-
(function(TradeFeeOptions) {
|
|
385
|
-
function equals(a, b) {
|
|
386
|
-
return a.tradeFeePercent === b.tradeFeePercent && a.tradeFeeRecipientAddress === b.tradeFeeRecipientAddress;
|
|
387
|
-
}
|
|
388
|
-
TradeFeeOptions.equals = equals;
|
|
389
|
-
})(types_TradeFeeOptions || (types_TradeFeeOptions = {}));
|
|
390
|
-
var types_TradeFeeOptions;
|
|
391
|
-
class cetus_CetusAggregator {
|
|
392
|
-
_config;
|
|
393
|
-
_suiClient;
|
|
394
|
-
_cetusClient;
|
|
395
|
-
constructor(config, suiClient){
|
|
396
|
-
this._config = config;
|
|
397
|
-
this._suiClient = suiClient;
|
|
398
|
-
}
|
|
399
|
-
cetusClient(walletAddress, tradeFee) {
|
|
400
|
-
if (tradeFee && !types_TradeFeeOptions.equals(tradeFee, this._config.defaultTradeFee)) return new aggregator_sdk_namespaceObject.AggregatorClient({
|
|
401
|
-
client: this._suiClient,
|
|
402
|
-
overlayFeeReceiver: tradeFee.tradeFeeRecipientAddress,
|
|
403
|
-
overlayFeeRate: tradeFee.tradeFeePercent,
|
|
404
|
-
env: aggregator_sdk_namespaceObject.Env.Mainnet,
|
|
405
|
-
signer: walletAddress,
|
|
406
|
-
...this._config.cetusApiKey && this._config.cetusApiEndpoint ? {
|
|
407
|
-
apiKey: this._config.cetusApiKey,
|
|
408
|
-
endpoint: this._config.cetusApiEndpoint
|
|
409
|
-
} : {},
|
|
410
|
-
partner: this._config.cetusPartnerId
|
|
411
|
-
});
|
|
412
|
-
if (this._cetusClient) return this._cetusClient;
|
|
413
|
-
this._cetusClient = new aggregator_sdk_namespaceObject.AggregatorClient({
|
|
414
|
-
client: this._suiClient,
|
|
415
|
-
overlayFeeReceiver: this._config.defaultTradeFee.tradeFeeRecipientAddress,
|
|
416
|
-
overlayFeeRate: this._config.defaultTradeFee.tradeFeePercent,
|
|
417
|
-
env: aggregator_sdk_namespaceObject.Env.Mainnet,
|
|
418
|
-
signer: walletAddress,
|
|
419
|
-
...this._config.cetusApiKey && this._config.cetusApiEndpoint ? {
|
|
420
|
-
apiKey: this._config.cetusApiKey,
|
|
421
|
-
endpoint: this._config.cetusApiEndpoint
|
|
422
|
-
} : {},
|
|
423
|
-
partner: this._config.cetusPartnerId
|
|
424
|
-
});
|
|
425
|
-
return this._cetusClient;
|
|
426
|
-
}
|
|
427
|
-
async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
|
|
428
|
-
const client = this.cetusClient(void 0, tradeFee);
|
|
429
|
-
return client.findRouters({
|
|
430
|
-
from: coinInType,
|
|
431
|
-
target: coinOutType,
|
|
432
|
-
amount: new (external_bn_js_default())(coinInAmount.toString()),
|
|
433
|
-
byAmountIn: true
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
async getTransaction({ completeRoute: routers, walletAddress, slippage, tradeFee }) {
|
|
437
|
-
const txb = new transactions_namespaceObject.Transaction();
|
|
438
|
-
const client = this.cetusClient(walletAddress, tradeFee);
|
|
439
|
-
await client.fastRouterSwap({
|
|
440
|
-
router: routers,
|
|
441
|
-
txb,
|
|
442
|
-
slippage
|
|
443
|
-
});
|
|
444
|
-
await client.devInspectTransactionBlock(txb);
|
|
445
|
-
txb.setSender(walletAddress);
|
|
446
|
-
return txb.build({
|
|
447
|
-
client: this._suiClient
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
(function(CetusAggregator) {
|
|
452
|
-
function toCommonTradeRoutes(tradeRoute, coinInType, coinOutType) {
|
|
453
|
-
if (0 === tradeRoute.paths.length) return null;
|
|
454
|
-
const routes = [];
|
|
455
|
-
const allPaths = [];
|
|
456
|
-
let currentRoute = [];
|
|
457
|
-
for(let i = 0; i < tradeRoute.paths.length; i++){
|
|
458
|
-
const currentPath = tradeRoute.paths[i];
|
|
459
|
-
const tradePath = {
|
|
460
|
-
poolAddress: currentPath.id,
|
|
461
|
-
amountIn: BigInt(currentPath.amountIn),
|
|
462
|
-
amountOut: BigInt(currentPath.amountOut),
|
|
463
|
-
coinIn: currentPath.from,
|
|
464
|
-
coinOut: currentPath.target
|
|
465
|
-
};
|
|
466
|
-
currentRoute.push(tradePath);
|
|
467
|
-
if (i === tradeRoute.paths.length - 1) allPaths.push([
|
|
468
|
-
...currentRoute
|
|
469
|
-
]);
|
|
470
|
-
else {
|
|
471
|
-
const nextPath = tradeRoute.paths[i + 1];
|
|
472
|
-
if (currentPath.target !== nextPath.from) {
|
|
473
|
-
allPaths.push([
|
|
474
|
-
...currentRoute
|
|
475
|
-
]);
|
|
476
|
-
currentRoute = [];
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
for (const pathGroup of allPaths)if (0 !== pathGroup.length) routes.push({
|
|
481
|
-
amountIn: pathGroup[0].amountIn,
|
|
482
|
-
amountOut: pathGroup[pathGroup.length - 1].amountOut,
|
|
483
|
-
coinIn: pathGroup[0].coinIn,
|
|
484
|
-
coinOut: pathGroup[pathGroup.length - 1].coinOut,
|
|
485
|
-
paths: pathGroup
|
|
486
|
-
});
|
|
487
|
-
if (0 === routes.length) return null;
|
|
488
|
-
return {
|
|
489
|
-
coinIn: coinInType,
|
|
490
|
-
coinOut: coinOutType,
|
|
491
|
-
amountIn: BigInt(tradeRoute.amountIn.toString(10)),
|
|
492
|
-
amountOut: BigInt(tradeRoute.amountOut.toString(10)),
|
|
493
|
-
routes: routes
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
CetusAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
|
|
497
|
-
})(cetus_CetusAggregator || (cetus_CetusAggregator = {}));
|
|
498
|
-
var common_SupportedAggregator = /*#__PURE__*/ function(SupportedAggregator) {
|
|
499
|
-
SupportedAggregator["ASTROS"] = "ASTROS";
|
|
500
|
-
SupportedAggregator["AFTERMATH"] = "AFTERMATH";
|
|
501
|
-
SupportedAggregator["SEVENK"] = "7K";
|
|
502
|
-
SupportedAggregator["CETUS"] = "CETUS";
|
|
503
|
-
SupportedAggregator["FLOWX"] = "FLOWX";
|
|
504
|
-
return SupportedAggregator;
|
|
505
|
-
}({});
|
|
506
|
-
const sdk_namespaceObject = require("@flowx-finance/sdk");
|
|
507
|
-
function getInputPercent(percent) {
|
|
508
|
-
return 1e6 * percent;
|
|
509
|
-
}
|
|
510
|
-
class flowx_FlowXAggregator {
|
|
511
|
-
_config;
|
|
512
|
-
_suiClient;
|
|
513
|
-
constructor(config, suiClient){
|
|
514
|
-
this._config = config;
|
|
515
|
-
this._suiClient = suiClient;
|
|
516
|
-
}
|
|
517
|
-
getCommission(coinInType, tradeFee) {
|
|
518
|
-
let tradeFeePercent;
|
|
519
|
-
let tradeFeeRecipientAddress;
|
|
520
|
-
if (tradeFee) {
|
|
521
|
-
tradeFeePercent = tradeFee.tradeFeePercent;
|
|
522
|
-
tradeFeeRecipientAddress = tradeFee.tradeFeeRecipientAddress;
|
|
523
|
-
} else {
|
|
524
|
-
tradeFeePercent = this._config.defaultTradeFee.tradeFeePercent;
|
|
525
|
-
tradeFeeRecipientAddress = this._config.defaultTradeFee.tradeFeeRecipientAddress;
|
|
526
|
-
}
|
|
527
|
-
return new sdk_namespaceObject.Commission(tradeFeeRecipientAddress, new sdk_namespaceObject.Coin(coinInType), sdk_namespaceObject.CommissionType.PERCENTAGE, getInputPercent(tradeFeePercent), true);
|
|
528
|
-
}
|
|
529
|
-
async getTradeRoute({ coinInAmount, coinInType, coinOutType, tradeFee }) {
|
|
530
|
-
const quoter = new sdk_namespaceObject.AggregatorQuoter("mainnet", this._config.flowxApiKey);
|
|
531
|
-
try {
|
|
532
|
-
return quoter.getRoutes({
|
|
533
|
-
tokenIn: coinInType,
|
|
534
|
-
tokenOut: coinOutType,
|
|
535
|
-
amountIn: coinInAmount.toString(),
|
|
536
|
-
commission: this.getCommission(coinInType, tradeFee)
|
|
537
|
-
});
|
|
538
|
-
} catch (_err) {
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
async getTransaction({ walletAddress, completeRoute, slippage, tradeFee }) {
|
|
543
|
-
const tradeBuilder = new sdk_namespaceObject.TradeBuilder("mainnet", completeRoute.routes);
|
|
544
|
-
const result = tradeBuilder.sender(walletAddress).slippage(getInputPercent(slippage)).commission(this.getCommission(completeRoute.coinIn.coinType, tradeFee)).build();
|
|
545
|
-
return result.buildTransaction({
|
|
546
|
-
client: this._suiClient
|
|
547
|
-
}).then((tx)=>{
|
|
548
|
-
tx.setSender(walletAddress);
|
|
549
|
-
return tx.build({
|
|
550
|
-
client: this._suiClient
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
(function(FlowXAggregator) {
|
|
556
|
-
function toCommonTradeRoutes(tradeRoute) {
|
|
557
|
-
if (0 === tradeRoute.routes.length) return null;
|
|
558
|
-
const routes = [];
|
|
559
|
-
for (const route of tradeRoute.routes){
|
|
560
|
-
const paths = [];
|
|
561
|
-
for (const path of route.paths)paths.push({
|
|
562
|
-
amountIn: BigInt(path.amountIn.toString()),
|
|
563
|
-
amountOut: BigInt(path.amountOut.toString()),
|
|
564
|
-
coinIn: path.input.coinType,
|
|
565
|
-
coinOut: path.output.coinType,
|
|
566
|
-
poolAddress: path.pool.id
|
|
567
|
-
});
|
|
568
|
-
if (0 !== paths.length) routes.push({
|
|
569
|
-
amountIn: BigInt(route.amountIn.toString()),
|
|
570
|
-
amountOut: BigInt(route.amountOut.toString()),
|
|
571
|
-
coinIn: route.input.coinType,
|
|
572
|
-
coinOut: route.output.coinType,
|
|
573
|
-
paths: paths
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
if (0 === routes.length) return null;
|
|
577
|
-
return {
|
|
578
|
-
coinIn: tradeRoute.coinIn.coinType,
|
|
579
|
-
coinOut: tradeRoute.coinOut.coinType,
|
|
580
|
-
amountIn: BigInt(tradeRoute.amountIn.toString()),
|
|
581
|
-
amountOut: BigInt(tradeRoute.amountOut.toString()),
|
|
582
|
-
routes: routes
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
FlowXAggregator.toCommonTradeRoutes = toCommonTradeRoutes;
|
|
586
|
-
})(flowx_FlowXAggregator || (flowx_FlowXAggregator = {}));
|
|
587
|
-
(function(BlastFunConstants) {
|
|
588
|
-
BlastFunConstants.PACKAGE_ID_V4 = "0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd";
|
|
589
|
-
BlastFunConstants.MEMEZ_AV_OBJECT_ID = "0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0";
|
|
590
|
-
})(constants_BlastFunConstants || (constants_BlastFunConstants = {}));
|
|
591
|
-
var constants_BlastFunConstants;
|
|
592
|
-
const SUI_TYPE = "0x2::sui::SUI";
|
|
593
|
-
const SUI_FULL_TYPE = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
594
|
-
const USDC_TOKEN_TYPE = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN";
|
|
595
|
-
const NATIVE_USDC_TOKEN_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
596
|
-
const SUI_METADATA_OBJECT_ID = "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3";
|
|
597
|
-
const CLOCK_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
598
|
-
const orderByKey = (array, key, sortBy)=>{
|
|
599
|
-
if (!array?.length) return;
|
|
600
|
-
let swapped;
|
|
601
|
-
do {
|
|
602
|
-
swapped = false;
|
|
603
|
-
for(let i = 0; i < array.length - 1; i++){
|
|
604
|
-
const a = BigInt(array[i][key]);
|
|
605
|
-
const b = BigInt(array[i + 1][key]);
|
|
606
|
-
if ("desc" === sortBy ? a < b : a > b) {
|
|
607
|
-
const temp = array[i];
|
|
608
|
-
array[i] = array[i + 1];
|
|
609
|
-
array[i + 1] = temp;
|
|
610
|
-
swapped = true;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}while (swapped);
|
|
614
|
-
return array;
|
|
615
|
-
};
|
|
616
|
-
const getCoinObjectIdsByAmount = async (suiClient, address, amount, coinType)=>{
|
|
617
|
-
let coinBalances = [];
|
|
618
|
-
let hasNextPage = true;
|
|
619
|
-
let nextCursor;
|
|
620
|
-
while(hasNextPage)try {
|
|
621
|
-
const coins = await suiClient.getCoins({
|
|
622
|
-
owner: address,
|
|
623
|
-
coinType,
|
|
624
|
-
cursor: nextCursor
|
|
625
|
-
});
|
|
626
|
-
coinBalances = [
|
|
627
|
-
...coinBalances,
|
|
628
|
-
...coins.data
|
|
629
|
-
];
|
|
630
|
-
hasNextPage = coins.hasNextPage;
|
|
631
|
-
nextCursor = coins.nextCursor;
|
|
632
|
-
} catch (error) {
|
|
633
|
-
console.error("Error fetching data:", error);
|
|
634
|
-
hasNextPage = false;
|
|
635
|
-
}
|
|
636
|
-
const coinObj = orderByKey(coinBalances.map((item)=>({
|
|
637
|
-
...item,
|
|
638
|
-
balance: item.balance
|
|
639
|
-
})), "balance", "desc") ?? [];
|
|
640
|
-
let balance = "0";
|
|
641
|
-
const objectIds = [];
|
|
642
|
-
const objectCoins = [];
|
|
643
|
-
for (const coin of coinObj){
|
|
644
|
-
balance = (BigInt(coin.balance) + BigInt(balance)).toString(10);
|
|
645
|
-
objectIds.push(coin.coinObjectId);
|
|
646
|
-
objectCoins.push(coin);
|
|
647
|
-
if (BigInt(balance) >= BigInt(amount)) break;
|
|
648
|
-
}
|
|
649
|
-
return {
|
|
650
|
-
objectIds,
|
|
651
|
-
balance,
|
|
652
|
-
objectCoins
|
|
653
|
-
};
|
|
654
|
-
};
|
|
655
|
-
async function addGasFee(params, suiClient) {
|
|
656
|
-
const { inheritTx, sender, feeAmount, suiInputAmount } = params;
|
|
657
|
-
const tx = inheritTx || new transactions_namespaceObject.Transaction();
|
|
658
|
-
tx.setGasBudget(feeAmount);
|
|
659
|
-
const { objectCoins } = await getCoinObjectIdsByAmount(suiClient, sender, (BigInt(suiInputAmount || "0") + feeAmount).toString(), SUI_FULL_TYPE);
|
|
660
|
-
tx.setGasPayment(objectCoins.map((c)=>({
|
|
661
|
-
objectId: c.coinObjectId,
|
|
662
|
-
version: c.version,
|
|
663
|
-
digest: c.digest
|
|
664
|
-
})));
|
|
665
|
-
return tx;
|
|
666
|
-
}
|
|
667
|
-
const BLUEFIN_PACKAGE_ID = "0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";
|
|
668
|
-
(function(BluefinTx) {
|
|
669
|
-
function transferOrDestroyZeroCoin(tx, coinType, coin, address) {
|
|
670
|
-
tx.moveCall({
|
|
671
|
-
target: `${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,
|
|
672
|
-
typeArguments: [
|
|
673
|
-
coinType
|
|
674
|
-
],
|
|
675
|
-
arguments: [
|
|
676
|
-
coin,
|
|
677
|
-
tx.pure.address(address)
|
|
678
|
-
]
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
BluefinTx.transferOrDestroyZeroCoin = transferOrDestroyZeroCoin;
|
|
682
|
-
})(bluefin_BluefinTx || (bluefin_BluefinTx = {}));
|
|
683
|
-
var bluefin_BluefinTx;
|
|
684
|
-
const utils_namespaceObject = require("@mysten/sui/utils");
|
|
685
|
-
async function getSplitCoinForTx(params, suiClient) {
|
|
686
|
-
const { account, amount, splits, coinType, inheritTx, inspecTransaction, isSponsored = false } = params;
|
|
687
|
-
const tx = inheritTx ?? new transactions_namespaceObject.Transaction();
|
|
688
|
-
const { objectIds } = await getCoinObjectIdsByAmount(suiClient, account, amount, coinType);
|
|
689
|
-
const coinObjectId = objectIds[0];
|
|
690
|
-
if ((0, utils_namespaceObject.normalizeStructTag)(coinType) === (0, utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE) && !isSponsored) {
|
|
691
|
-
let coin;
|
|
692
|
-
if (inspecTransaction) {
|
|
693
|
-
if (objectIds.length > 1) tx.mergeCoins(tx.object(coinObjectId), objectIds.slice(1).map((item)=>tx.object(item)));
|
|
694
|
-
coin = tx.splitCoins(tx.object(coinObjectId), splits);
|
|
695
|
-
} else coin = tx.splitCoins(tx.gas, splits);
|
|
696
|
-
return {
|
|
697
|
-
tx,
|
|
698
|
-
coinData: coin
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
if (objectIds.length > 1) tx.mergeCoins(tx.object(coinObjectId), objectIds.slice(1).map((item)=>tx.object(item)));
|
|
702
|
-
const coinData = tx.splitCoins(tx.object(coinObjectId), splits);
|
|
703
|
-
return {
|
|
704
|
-
tx,
|
|
705
|
-
coinData
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
const BASE_BPS = 10000;
|
|
709
|
-
function getSplitCoinsAfterFee(amount, fee) {
|
|
710
|
-
const amountNum = BigInt(amount);
|
|
711
|
-
const feeNum = BigInt(Number(fee) * BASE_BPS);
|
|
712
|
-
if (feeNum === BigInt(0)) return [
|
|
713
|
-
amountNum.toString()
|
|
714
|
-
];
|
|
715
|
-
const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
|
|
716
|
-
const remainingAmount = amountNum - feeAmount;
|
|
717
|
-
return [
|
|
718
|
-
remainingAmount.toString(),
|
|
719
|
-
feeAmount.toString()
|
|
720
|
-
];
|
|
721
|
-
}
|
|
722
|
-
function getAmountAfterFee(amount, fee) {
|
|
723
|
-
if (!fee || Number(fee) <= 0) return BigInt(amount);
|
|
724
|
-
const amountNum = BigInt(amount);
|
|
725
|
-
const feeNum = BigInt(Number(fee) * BASE_BPS);
|
|
726
|
-
if (feeNum === BigInt(0)) return amountNum;
|
|
727
|
-
const feeAmount = amountNum * feeNum / BigInt(BASE_BPS);
|
|
728
|
-
return amountNum - feeAmount;
|
|
729
|
-
}
|
|
730
|
-
async function getNeededGasFee(suiClient, tx, sender, bufferPercent) {
|
|
731
|
-
const { effects: { gasUsed, status } } = await suiClient.devInspectTransactionBlock({
|
|
732
|
-
sender,
|
|
733
|
-
transactionBlock: tx
|
|
734
|
-
});
|
|
735
|
-
if ("success" !== status.status) throw new Error(`Transaction failed during dev inspect: ${status.error ?? ""}`);
|
|
736
|
-
const fee = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
737
|
-
const feeNum = BigInt(Number(bufferPercent) * BASE_BPS);
|
|
738
|
-
return fee * (BigInt(BASE_BPS) + feeNum) / BigInt(BASE_BPS);
|
|
739
|
-
}
|
|
740
|
-
const tiny_invariant_namespaceObject = require("@minswap/tiny-invariant");
|
|
741
|
-
var tiny_invariant_default = /*#__PURE__*/ __webpack_require__.n(tiny_invariant_namespaceObject);
|
|
742
|
-
async function getMoveObjectContent(suiClient, objectId) {
|
|
743
|
-
const moveObject = await getMoveObject(suiClient, objectId);
|
|
744
|
-
return moveObject.fields;
|
|
745
|
-
}
|
|
746
|
-
async function getMoveObject(suiClient, objectId) {
|
|
747
|
-
const objRes = await suiClient.getObject({
|
|
748
|
-
id: objectId,
|
|
749
|
-
options: {
|
|
750
|
-
showContent: true
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
const content = objRes.data?.content;
|
|
754
|
-
tiny_invariant_default()(content, "Pool object not found or has no content");
|
|
755
|
-
tiny_invariant_default()("moveObject" === content.dataType, "Object is not a Move object");
|
|
756
|
-
return content;
|
|
757
|
-
}
|
|
758
|
-
function adaptSuiClient(client) {
|
|
759
|
-
return client;
|
|
760
|
-
}
|
|
761
|
-
function adaptTransaction(transaction) {
|
|
762
|
-
return transaction;
|
|
763
|
-
}
|
|
764
|
-
function createCompatibleSuiClient(client) {
|
|
765
|
-
return new Proxy(client, {
|
|
766
|
-
get (target, prop) {
|
|
767
|
-
const value = target[prop];
|
|
768
|
-
if ("function" == typeof value) return value.bind(target);
|
|
769
|
-
return value;
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
(function(MathUtils) {
|
|
774
|
-
(function(U64) {
|
|
775
|
-
function mulDivUp(a, b, c) {
|
|
776
|
-
let roundUp = BigInt(0);
|
|
777
|
-
if (a * b % c > BigInt(0)) roundUp = BigInt(1);
|
|
778
|
-
return a * b / c + roundUp;
|
|
779
|
-
}
|
|
780
|
-
U64.mulDivUp = mulDivUp;
|
|
781
|
-
})(MathUtils.U64 || (MathUtils.U64 = {}));
|
|
782
|
-
})(package_MathUtils || (package_MathUtils = {}));
|
|
783
|
-
(function(Bps) {
|
|
784
|
-
function calcUp(bps, amount) {
|
|
785
|
-
const bpsValue = BigInt(bps.pos0);
|
|
786
|
-
const denominator = BigInt(10000);
|
|
787
|
-
let roundUp;
|
|
788
|
-
roundUp = bpsValue * amount % denominator !== BigInt(0) ? BigInt(1) : BigInt(0);
|
|
789
|
-
return bpsValue * amount / denominator + roundUp;
|
|
790
|
-
}
|
|
791
|
-
Bps.calcUp = calcUp;
|
|
792
|
-
function sub(lhs, rhs) {
|
|
793
|
-
tiny_invariant_default()(BigInt(lhs.pos0) >= BigInt(rhs.pos0), "Bps underflow");
|
|
794
|
-
return {
|
|
795
|
-
pos0: (BigInt(lhs.pos0) - BigInt(rhs.pos0)).toString()
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
Bps.sub = sub;
|
|
799
|
-
function value(bps) {
|
|
800
|
-
return BigInt(bps.pos0);
|
|
801
|
-
}
|
|
802
|
-
Bps.value = value;
|
|
803
|
-
function new_(bps) {
|
|
804
|
-
return {
|
|
805
|
-
pos0: assertOverflow(bps).toString()
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
Bps.new_ = new_;
|
|
809
|
-
function assertOverflow(bps) {
|
|
810
|
-
tiny_invariant_default()(BigInt(bps) <= BigInt(10000), "Bps overflow");
|
|
811
|
-
return BigInt(bps);
|
|
812
|
-
}
|
|
813
|
-
Bps.assertOverflow = assertOverflow;
|
|
814
|
-
})(package_Bps || (package_Bps = {}));
|
|
815
|
-
(function(BlastFunPackage) {
|
|
816
|
-
(function(MemezFun) {
|
|
817
|
-
async function isSniperProtectedMemezFun(suiClient, poolId) {
|
|
818
|
-
const memezFun = await getMoveObjectContent(suiClient, poolId);
|
|
819
|
-
return memezFun.public_key.length > 0;
|
|
820
|
-
}
|
|
821
|
-
MemezFun.isSniperProtectedMemezFun = isSniperProtectedMemezFun;
|
|
822
|
-
})(BlastFunPackage.MemezFun || (BlastFunPackage.MemezFun = {}));
|
|
823
|
-
(function(MemezFees) {
|
|
824
|
-
function takeWithDiscount(fee, amount, discountBps) {
|
|
825
|
-
if ("Value" === fee.variant) {
|
|
826
|
-
const amountRequired = BigInt(fee.fields.pos0);
|
|
827
|
-
if (amountRequired === BigInt(0)) return BigInt(0);
|
|
828
|
-
if (amount >= amountRequired) return amountRequired;
|
|
829
|
-
throw new Error(`Insufficient amount to cover fee. Required: ${amountRequired}, provided: ${amount}`);
|
|
830
|
-
}
|
|
831
|
-
if ("Percentage" === fee.variant) {
|
|
832
|
-
const feeBps = fee.fields.pos0.fields;
|
|
833
|
-
if (BigInt(feeBps.pos0) === BigInt(0)) return BigInt(0);
|
|
834
|
-
const discountedFee = package_Bps.calcUp(package_Bps.sub(feeBps, discountBps), amount);
|
|
835
|
-
if (amount >= discountedFee) return discountedFee;
|
|
836
|
-
throw new Error(`Insufficient amount to cover fee. Required: ${discountedFee}, provided: ${amount}`);
|
|
837
|
-
}
|
|
838
|
-
throw new Error("Unknown fee variant");
|
|
839
|
-
}
|
|
840
|
-
MemezFees.takeWithDiscount = takeWithDiscount;
|
|
841
|
-
function calculateWithDiscount(fee, discountBps, amount) {
|
|
842
|
-
if ("Value" === fee.variant) return BigInt(fee.fields.pos0);
|
|
843
|
-
if ("Percentage" === fee.variant) {
|
|
844
|
-
const feeBps = fee.fields.pos0.fields;
|
|
845
|
-
return package_Bps.calcUp(package_Bps.sub(feeBps, discountBps), amount);
|
|
846
|
-
}
|
|
847
|
-
throw new Error("Unknown fee variant");
|
|
848
|
-
}
|
|
849
|
-
MemezFees.calculateWithDiscount = calculateWithDiscount;
|
|
850
|
-
})(BlastFunPackage.MemezFees || (BlastFunPackage.MemezFees = {}));
|
|
851
|
-
(function(MemezBurner) {
|
|
852
|
-
function calculate(burner, poolMemeBalance) {
|
|
853
|
-
const burnerFee = package_Bps.value(burner.fee.fields);
|
|
854
|
-
if (burnerFee === BigInt(0) || poolMemeBalance === BigInt(0)) return package_Bps.new_(0);
|
|
855
|
-
if (poolMemeBalance >= BigInt(burner.target_liquidity)) return package_Bps.new_(0);
|
|
856
|
-
const baseBps = BigInt(10000);
|
|
857
|
-
return package_Bps.new_(package_MathUtils.U64.mulDivUp(package_Bps.value(burner.fee.fields), package_MathUtils.U64.mulDivUp(poolMemeBalance, baseBps, BigInt(burner.target_liquidity)), baseBps));
|
|
858
|
-
}
|
|
859
|
-
MemezBurner.calculate = calculate;
|
|
860
|
-
})(BlastFunPackage.MemezBurner || (BlastFunPackage.MemezBurner = {}));
|
|
861
|
-
(function(MemezPump) {
|
|
862
|
-
async function getPumpState(suiClient, memezFun) {
|
|
863
|
-
return await getMoveObjectContent(suiClient, memezFun.inner_state);
|
|
864
|
-
}
|
|
865
|
-
MemezPump.getPumpState = getPumpState;
|
|
866
|
-
function pump(pumpState, quoteAmount) {
|
|
867
|
-
const constantProduct = pumpState.constant_product.fields;
|
|
868
|
-
const quoteSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.quote_swap_fee, quoteAmount, constantProduct.quote_referrer_fee.fields);
|
|
869
|
-
const quoteAfterFee = quoteAmount - quoteSwapFee;
|
|
870
|
-
const memeBalance = BigInt(constantProduct.meme_balance);
|
|
871
|
-
const quoteBalance = BigInt(constantProduct.quote_balance);
|
|
872
|
-
const virtualLiquidity = BigInt(constantProduct.virtual_liquidity);
|
|
873
|
-
const memeOutExpected = memeBalance * quoteAfterFee / (virtualLiquidity + quoteBalance + quoteAfterFee);
|
|
874
|
-
const memeSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.meme_swap_fee, memeOutExpected, constantProduct.meme_referrer_fee.fields);
|
|
875
|
-
return memeOutExpected - memeSwapFee;
|
|
876
|
-
}
|
|
877
|
-
MemezPump.pump = pump;
|
|
878
|
-
function dump(pumpState, memeAmount) {
|
|
879
|
-
const constantProduct = pumpState.constant_product.fields;
|
|
880
|
-
const memeSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.meme_swap_fee, memeAmount, constantProduct.meme_referrer_fee.fields);
|
|
881
|
-
const inputAmount = memeAmount - memeSwapFee;
|
|
882
|
-
const memeBalance = BigInt(constantProduct.meme_balance);
|
|
883
|
-
const quoteBalance = BigInt(constantProduct.quote_balance);
|
|
884
|
-
const virtualLiquidity = BigInt(constantProduct.virtual_liquidity);
|
|
885
|
-
const burnBps = BlastFunPackage.MemezBurner.calculate(constantProduct.burner.fields, quoteBalance);
|
|
886
|
-
const burnAmount = package_Bps.calcUp(burnBps, inputAmount);
|
|
887
|
-
const inputAmountAfterFee = inputAmount - (package_Bps.value(burnBps) !== BigInt(0) ? burnAmount : BigInt(0));
|
|
888
|
-
let quoteOutBeforeFee = (virtualLiquidity + quoteBalance) * inputAmountAfterFee / (memeBalance + inputAmountAfterFee);
|
|
889
|
-
if (quoteOutBeforeFee > quoteBalance) quoteOutBeforeFee = quoteBalance;
|
|
890
|
-
const quoteSwapFee = BlastFunPackage.MemezFees.takeWithDiscount(constantProduct.quote_swap_fee, quoteOutBeforeFee, constantProduct.quote_referrer_fee.fields);
|
|
891
|
-
return quoteOutBeforeFee - quoteSwapFee;
|
|
892
|
-
}
|
|
893
|
-
MemezPump.dump = dump;
|
|
894
|
-
})(BlastFunPackage.MemezPump || (BlastFunPackage.MemezPump = {}));
|
|
895
|
-
})(package_BlastFunPackage || (package_BlastFunPackage = {}));
|
|
896
|
-
var package_MathUtils, package_Bps, package_BlastFunPackage;
|
|
897
|
-
(function(BlastFunCustomCalculation) {
|
|
898
|
-
async function getCurveAmountAfterBuy(params, suiClient) {
|
|
899
|
-
let { suiAmount, poolId, frontendFee } = params;
|
|
900
|
-
const memezFun = await getMoveObjectContent(suiClient, poolId);
|
|
901
|
-
const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
|
|
902
|
-
suiAmount = getAmountAfterFee(suiAmount, frontendFee);
|
|
903
|
-
return package_BlastFunPackage.MemezPump.pump(pumpState, suiAmount);
|
|
904
|
-
}
|
|
905
|
-
BlastFunCustomCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
|
|
906
|
-
async function getSuiAmountAfterSell(params, suiClient) {
|
|
907
|
-
const { curveAmount, poolId, frontendFee } = params;
|
|
908
|
-
const memezFun = await getMoveObjectContent(suiClient, poolId);
|
|
909
|
-
const pumpState = await package_BlastFunPackage.MemezPump.getPumpState(suiClient, memezFun);
|
|
910
|
-
const suiAmount = package_BlastFunPackage.MemezPump.dump(pumpState, curveAmount);
|
|
911
|
-
return getAmountAfterFee(suiAmount, frontendFee);
|
|
912
|
-
}
|
|
913
|
-
BlastFunCustomCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
|
|
914
|
-
})(custom_calculation_BlastFunCustomCalculation || (custom_calculation_BlastFunCustomCalculation = {}));
|
|
915
|
-
var custom_calculation_BlastFunCustomCalculation;
|
|
916
|
-
async function splitSuiCoinAfterFeeFromBuyTx(params, suiClient) {
|
|
917
|
-
const { inputAmount, accountAddress, frontendFee, frontendFeeRecipient, extendTx, isSponsored } = params;
|
|
918
|
-
tiny_invariant_default()(params.inCoinType === SUI_FULL_TYPE || params.inCoinType === SUI_TYPE, "Input must be SUI");
|
|
919
|
-
const { tx: _tx, coinIn } = extendTx || {};
|
|
920
|
-
const splitSui = getSplitCoinsAfterFee(inputAmount, frontendFee || "0");
|
|
921
|
-
const tx = _tx || new transactions_namespaceObject.Transaction();
|
|
922
|
-
let coinData;
|
|
923
|
-
if (coinIn) {
|
|
924
|
-
coinData = tx.splitCoins(coinIn, splitSui);
|
|
925
|
-
bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, SUI_FULL_TYPE, coinIn, accountAddress);
|
|
926
|
-
} else {
|
|
927
|
-
const { coinData: _data } = await getSplitCoinForTx({
|
|
928
|
-
account: accountAddress,
|
|
929
|
-
amount: inputAmount,
|
|
930
|
-
splits: splitSui,
|
|
931
|
-
coinType: SUI_FULL_TYPE,
|
|
932
|
-
inheritTx: tx,
|
|
933
|
-
isSponsored: isSponsored || false
|
|
934
|
-
}, suiClient);
|
|
935
|
-
coinData = _data;
|
|
936
|
-
}
|
|
937
|
-
let inputSuiCoin;
|
|
938
|
-
if (frontendFee && frontendFeeRecipient) {
|
|
939
|
-
const [_inputSuiCoin, frontendFeeCoin] = coinData;
|
|
940
|
-
inputSuiCoin = _inputSuiCoin;
|
|
941
|
-
tx.transferObjects([
|
|
942
|
-
frontendFeeCoin
|
|
943
|
-
], tx.pure.address(frontendFeeRecipient || accountAddress));
|
|
944
|
-
} else [inputSuiCoin] = coinData;
|
|
945
|
-
return {
|
|
946
|
-
tx,
|
|
947
|
-
coinOut: inputSuiCoin
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
async function splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin) {
|
|
951
|
-
tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
|
|
952
|
-
if (Number(params.frontendFee || 0) <= 0) return {
|
|
953
|
-
tx,
|
|
954
|
-
coinOut: suiCoin
|
|
955
|
-
};
|
|
956
|
-
const suiCoinValue = tx.moveCall({
|
|
957
|
-
target: "0x2::coin::value",
|
|
958
|
-
typeArguments: [
|
|
959
|
-
params.outCoinType
|
|
960
|
-
],
|
|
961
|
-
arguments: [
|
|
962
|
-
suiCoin
|
|
963
|
-
]
|
|
964
|
-
});
|
|
965
|
-
const suiCoinFeeValue = tx.moveCall({
|
|
966
|
-
target: `${BLUEFIN_PACKAGE_ID}::math::mul_div_u64`,
|
|
967
|
-
typeArguments: [],
|
|
968
|
-
arguments: [
|
|
969
|
-
suiCoinValue,
|
|
970
|
-
tx.pure.u64(BigInt(Number(params.frontendFee || "0") * BASE_BPS)),
|
|
971
|
-
tx.pure.u64(BigInt(BASE_BPS))
|
|
972
|
-
]
|
|
973
|
-
});
|
|
974
|
-
const suiCoinFee = tx.moveCall({
|
|
975
|
-
target: "0x2::coin::split",
|
|
976
|
-
typeArguments: [
|
|
977
|
-
params.outCoinType
|
|
978
|
-
],
|
|
979
|
-
arguments: [
|
|
980
|
-
suiCoin,
|
|
981
|
-
suiCoinFeeValue
|
|
982
|
-
]
|
|
983
|
-
});
|
|
984
|
-
tx.transferObjects([
|
|
985
|
-
suiCoinFee
|
|
986
|
-
], tx.pure.address(params.frontendFeeRecipient || params.accountAddress));
|
|
987
|
-
return {
|
|
988
|
-
tx,
|
|
989
|
-
coinOut: suiCoin
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
var types_SupportedBondingCurve = /*#__PURE__*/ function(SupportedBondingCurve) {
|
|
993
|
-
SupportedBondingCurve["BLAST_FUN"] = "BLAST_FUN";
|
|
994
|
-
SupportedBondingCurve["MOONBAGS"] = "MOONBAGS";
|
|
995
|
-
return SupportedBondingCurve;
|
|
996
|
-
}({});
|
|
997
|
-
(function(BlastFunCustomTransaction) {
|
|
998
|
-
async function getAllowedVersions(_tx) {
|
|
999
|
-
const tx = _tx || new transactions_namespaceObject.Transaction();
|
|
1000
|
-
return tx.moveCall({
|
|
1001
|
-
target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,
|
|
1002
|
-
arguments: [
|
|
1003
|
-
tx.object(constants_BlastFunConstants.MEMEZ_AV_OBJECT_ID)
|
|
1004
|
-
],
|
|
1005
|
-
typeArguments: []
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
BlastFunCustomTransaction.getAllowedVersions = getAllowedVersions;
|
|
1009
|
-
async function buildBuyTx(params, suiClient) {
|
|
1010
|
-
tiny_invariant_default()(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(suiClient, params.poolId), "This coin is a sniper protected coin, please use the Blast Fun website to trade it.");
|
|
1011
|
-
const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
|
|
1012
|
-
tiny_invariant_default()(suiCoinIn, "Coin out is required");
|
|
1013
|
-
const curveCoin = tx.moveCall({
|
|
1014
|
-
target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,
|
|
1015
|
-
typeArguments: [
|
|
1016
|
-
params.outCoinType,
|
|
1017
|
-
SUI_FULL_TYPE
|
|
1018
|
-
],
|
|
1019
|
-
arguments: [
|
|
1020
|
-
tx.object(params.poolId),
|
|
1021
|
-
suiCoinIn,
|
|
1022
|
-
tx.pure.vector("address", []),
|
|
1023
|
-
tx.pure.vector("vector<u8>", []),
|
|
1024
|
-
tx.pure.u64(params.minAmountOut),
|
|
1025
|
-
await getAllowedVersions(tx)
|
|
1026
|
-
]
|
|
1027
|
-
});
|
|
1028
|
-
return {
|
|
1029
|
-
tx,
|
|
1030
|
-
coinOut: curveCoin
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
BlastFunCustomTransaction.buildBuyTx = buildBuyTx;
|
|
1034
|
-
async function buildSellTx(params, suiClient) {
|
|
1035
|
-
tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
|
|
1036
|
-
const memezFun = await getMoveObjectContent(suiClient, params.poolId);
|
|
1037
|
-
const { tx, coinData } = await getSplitCoinForTx({
|
|
1038
|
-
amount: params.inputAmount,
|
|
1039
|
-
coinType: params.inCoinType,
|
|
1040
|
-
inheritTx: params.extendTx?.tx,
|
|
1041
|
-
account: params.accountAddress,
|
|
1042
|
-
splits: [
|
|
1043
|
-
params.inputAmount
|
|
1044
|
-
]
|
|
1045
|
-
}, suiClient);
|
|
1046
|
-
const [inputCoin] = coinData;
|
|
1047
|
-
const [suiCoin] = tx.moveCall({
|
|
1048
|
-
target: `${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,
|
|
1049
|
-
typeArguments: [
|
|
1050
|
-
params.inCoinType,
|
|
1051
|
-
params.outCoinType
|
|
1052
|
-
],
|
|
1053
|
-
arguments: [
|
|
1054
|
-
tx.object(params.poolId),
|
|
1055
|
-
tx.object(memezFun.ipx_meme_coin_treasury),
|
|
1056
|
-
inputCoin,
|
|
1057
|
-
tx.pure.vector("address", []),
|
|
1058
|
-
tx.pure.u64(params.minAmountOut),
|
|
1059
|
-
await getAllowedVersions(tx)
|
|
1060
|
-
]
|
|
1061
|
-
});
|
|
1062
|
-
return await splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin);
|
|
1063
|
-
}
|
|
1064
|
-
BlastFunCustomTransaction.buildSellTx = buildSellTx;
|
|
1065
|
-
})(custom_transaction_BlastFunCustomTransaction || (custom_transaction_BlastFunCustomTransaction = {}));
|
|
1066
|
-
var custom_transaction_BlastFunCustomTransaction;
|
|
1067
|
-
const memez_fun_sdk_namespaceObject = require("@interest-protocol/memez-fun-sdk");
|
|
1068
|
-
const sui_core_sdk_namespaceObject = require("@interest-protocol/sui-core-sdk");
|
|
1069
|
-
const client_namespaceObject = require("@mysten/sui/client");
|
|
1070
|
-
const payload = {
|
|
1071
|
-
network: sui_core_sdk_namespaceObject.Network.MAINNET,
|
|
1072
|
-
fullNodeUrl: (0, client_namespaceObject.getFullnodeUrl)("mainnet")
|
|
1073
|
-
};
|
|
1074
|
-
const memezPump = new memez_fun_sdk_namespaceObject.MemezPumpSDK(payload);
|
|
1075
|
-
function getMemezPumpSDK() {
|
|
1076
|
-
return memezPump;
|
|
1077
|
-
}
|
|
1078
|
-
(function(BlastFunSDKCalculation) {
|
|
1079
|
-
async function getCurveAmountAfterBuy(params) {
|
|
1080
|
-
let { suiAmount, poolId, frontendFee } = params;
|
|
1081
|
-
suiAmount = getAmountAfterFee(suiAmount, frontendFee);
|
|
1082
|
-
const { memeAmountOut } = await getMemezPumpSDK().quotePump({
|
|
1083
|
-
pool: poolId,
|
|
1084
|
-
amount: suiAmount
|
|
1085
|
-
});
|
|
1086
|
-
return memeAmountOut;
|
|
1087
|
-
}
|
|
1088
|
-
BlastFunSDKCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
|
|
1089
|
-
async function getSuiAmountAfterSell(params) {
|
|
1090
|
-
const { curveAmount, poolId, frontendFee } = params;
|
|
1091
|
-
const { quoteAmountOut } = await getMemezPumpSDK().quoteDump({
|
|
1092
|
-
pool: poolId,
|
|
1093
|
-
amount: curveAmount
|
|
1094
|
-
});
|
|
1095
|
-
return getAmountAfterFee(quoteAmountOut, frontendFee);
|
|
1096
|
-
}
|
|
1097
|
-
BlastFunSDKCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
|
|
1098
|
-
})(sdk_calculation_BlastFunSDKCalculation || (sdk_calculation_BlastFunSDKCalculation = {}));
|
|
1099
|
-
var sdk_calculation_BlastFunSDKCalculation;
|
|
1100
|
-
(function(BlastFunSDKTransaction) {
|
|
1101
|
-
async function buildBuyTx(params, suiClient) {
|
|
1102
|
-
const { tx, coinOut: suiCoinIn } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
|
|
1103
|
-
tiny_invariant_default()(suiCoinIn, "Coin out is required");
|
|
1104
|
-
const { memeCoin, tx: tx2 } = await getMemezPumpSDK().pump({
|
|
1105
|
-
pool: params.poolId,
|
|
1106
|
-
quoteCoin: suiCoinIn,
|
|
1107
|
-
minAmountOut: params.minAmountOut,
|
|
1108
|
-
tx
|
|
1109
|
-
});
|
|
1110
|
-
return {
|
|
1111
|
-
tx: tx2,
|
|
1112
|
-
coinOut: memeCoin
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
BlastFunSDKTransaction.buildBuyTx = buildBuyTx;
|
|
1116
|
-
async function buildSellTx(params, suiClient) {
|
|
1117
|
-
tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
|
|
1118
|
-
const { tx, coinData } = await getSplitCoinForTx({
|
|
1119
|
-
amount: params.inputAmount,
|
|
1120
|
-
coinType: params.inCoinType,
|
|
1121
|
-
inheritTx: params.extendTx?.tx,
|
|
1122
|
-
account: params.accountAddress,
|
|
1123
|
-
splits: [
|
|
1124
|
-
params.inputAmount
|
|
1125
|
-
]
|
|
1126
|
-
}, suiClient);
|
|
1127
|
-
const [inputCoin] = coinData;
|
|
1128
|
-
const { quoteCoin, tx: tx2 } = await getMemezPumpSDK().dump({
|
|
1129
|
-
pool: params.poolId,
|
|
1130
|
-
memeCoin: inputCoin,
|
|
1131
|
-
tx,
|
|
1132
|
-
minAmountOut: params.minAmountOut
|
|
1133
|
-
});
|
|
1134
|
-
return await splitSuiCoinAfterFeeFromSellTx(tx2, params, quoteCoin);
|
|
1135
|
-
}
|
|
1136
|
-
BlastFunSDKTransaction.buildSellTx = buildSellTx;
|
|
1137
|
-
async function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
|
|
1138
|
-
tiny_invariant_default()(coinInType === SUI_TYPE, "coinInType must be SUI for buy transaction");
|
|
1139
|
-
tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
|
|
1140
|
-
tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
|
|
1141
|
-
tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
|
|
1142
|
-
const inputAmount = coinInAmount;
|
|
1143
|
-
const outputAmount = await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({
|
|
1144
|
-
poolId: poolId,
|
|
1145
|
-
suiAmount: inputAmount,
|
|
1146
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
|
|
1147
|
-
});
|
|
1148
|
-
const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
|
|
1149
|
-
let { tx, coinOut } = await buildBuyTx({
|
|
1150
|
-
accountAddress: walletAddress,
|
|
1151
|
-
inCoinType: coinInType,
|
|
1152
|
-
outCoinType: coinOutType,
|
|
1153
|
-
inputAmount: inputAmount.toString(),
|
|
1154
|
-
minAmountOut: minAmountOut.toString(),
|
|
1155
|
-
poolId: poolId,
|
|
1156
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0,
|
|
1157
|
-
frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
|
|
1158
|
-
extendTx: void 0,
|
|
1159
|
-
isSponsored: false
|
|
1160
|
-
}, suiClient);
|
|
1161
|
-
tiny_invariant_default()(coinOut, "Coin out is required");
|
|
1162
|
-
tx.transferObjects([
|
|
1163
|
-
coinOut
|
|
1164
|
-
], tx.pure.address(walletAddress));
|
|
1165
|
-
tx.setSender(walletAddress);
|
|
1166
|
-
const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
|
|
1167
|
-
tx = await addGasFee({
|
|
1168
|
-
inheritTx: tx,
|
|
1169
|
-
sender: walletAddress,
|
|
1170
|
-
feeAmount,
|
|
1171
|
-
suiInputAmount: inputAmount
|
|
1172
|
-
}, suiClient);
|
|
1173
|
-
return tx.build({
|
|
1174
|
-
client: suiClient
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
BlastFunSDKTransaction.getBuyTransaction = getBuyTransaction;
|
|
1178
|
-
async function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
|
|
1179
|
-
tiny_invariant_default()(coinOutType === SUI_TYPE, "coinOutType must be SUI for sell transaction");
|
|
1180
|
-
tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
|
|
1181
|
-
tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
|
|
1182
|
-
tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
|
|
1183
|
-
const inputAmount = coinInAmount;
|
|
1184
|
-
const outputAmount = await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({
|
|
1185
|
-
poolId: poolId,
|
|
1186
|
-
curveAmount: inputAmount,
|
|
1187
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
|
|
1188
|
-
});
|
|
1189
|
-
const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
|
|
1190
|
-
let { tx, coinOut } = await buildSellTx({
|
|
1191
|
-
accountAddress: walletAddress,
|
|
1192
|
-
inCoinType: coinInType,
|
|
1193
|
-
outCoinType: coinOutType,
|
|
1194
|
-
inputAmount: inputAmount.toString(),
|
|
1195
|
-
minAmountOut: minAmountOut.toString(),
|
|
1196
|
-
poolId: poolId,
|
|
1197
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0,
|
|
1198
|
-
frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
|
|
1199
|
-
extendTx: void 0,
|
|
1200
|
-
isSponsored: false
|
|
1201
|
-
}, suiClient);
|
|
1202
|
-
tiny_invariant_default()(coinOut, "Coin out is required");
|
|
1203
|
-
tx.transferObjects([
|
|
1204
|
-
coinOut
|
|
1205
|
-
], tx.pure.address(walletAddress));
|
|
1206
|
-
tx.setSender(walletAddress);
|
|
1207
|
-
const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
|
|
1208
|
-
tx = await addGasFee({
|
|
1209
|
-
inheritTx: tx,
|
|
1210
|
-
sender: walletAddress,
|
|
1211
|
-
feeAmount
|
|
1212
|
-
}, suiClient);
|
|
1213
|
-
return tx.build({
|
|
1214
|
-
client: suiClient
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
BlastFunSDKTransaction.getSellTransaction = getSellTransaction;
|
|
1218
|
-
})(sdk_transaction_BlastFunSDKTransaction || (sdk_transaction_BlastFunSDKTransaction = {}));
|
|
1219
|
-
var sdk_transaction_BlastFunSDKTransaction;
|
|
1220
|
-
(function(MoonbagsConstants) {
|
|
1221
|
-
MoonbagsConstants.PACKAGE_ID = "0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290";
|
|
1222
|
-
MoonbagsConstants.CONFIG_OBJECT_ID = "0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499";
|
|
1223
|
-
MoonbagsConstants.LOCK_CONFIG_OBJECT_ID = "0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be";
|
|
1224
|
-
MoonbagsConstants.BURN_MANAGER_OBJECT_ID = "0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845";
|
|
1225
|
-
MoonbagsConstants.POOLS_OBJECT_ID = "0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0";
|
|
1226
|
-
MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
1227
|
-
MoonbagsConstants.FEE_DENOMINATOR = BigInt(10000);
|
|
1228
|
-
})(constants_MoonbagsConstants || (constants_MoonbagsConstants = {}));
|
|
1229
|
-
var constants_MoonbagsConstants;
|
|
1230
|
-
(function(MoonbagsPackage) {
|
|
1231
|
-
(function(Curves) {
|
|
1232
|
-
function calculateAddLiquidityCost(tokenIn, tokenReserve, tokenAmount) {
|
|
1233
|
-
const availableReserve = tokenReserve - tokenAmount;
|
|
1234
|
-
const numerator = tokenIn * tokenReserve;
|
|
1235
|
-
const fraction = numerator / availableReserve;
|
|
1236
|
-
return fraction - tokenIn;
|
|
1237
|
-
}
|
|
1238
|
-
Curves.calculateAddLiquidityCost = calculateAddLiquidityCost;
|
|
1239
|
-
function calculateRemoveLiquidityReturn(tokenIn, tokenReserve, tokenRemoved) {
|
|
1240
|
-
const denominator = tokenIn + tokenRemoved;
|
|
1241
|
-
const fraction = tokenIn * tokenReserve / denominator;
|
|
1242
|
-
return tokenReserve - fraction;
|
|
1243
|
-
}
|
|
1244
|
-
Curves.calculateRemoveLiquidityReturn = calculateRemoveLiquidityReturn;
|
|
1245
|
-
function calculateTokenAmountReceived(tokenIn, tokenReserve, tokenOutReserve) {
|
|
1246
|
-
const denominator = tokenIn + tokenOutReserve;
|
|
1247
|
-
const fraction = tokenIn * tokenReserve / denominator;
|
|
1248
|
-
return tokenReserve - fraction;
|
|
1249
|
-
}
|
|
1250
|
-
Curves.calculateTokenAmountReceived = calculateTokenAmountReceived;
|
|
1251
|
-
})(MoonbagsPackage.Curves || (MoonbagsPackage.Curves = {}));
|
|
1252
|
-
(function(Moonbags) {
|
|
1253
|
-
async function getDynamicVirtualTokenReserves(suiClient, poolId) {
|
|
1254
|
-
const result = await suiClient.getDynamicFieldObject({
|
|
1255
|
-
parentId: poolId,
|
|
1256
|
-
name: {
|
|
1257
|
-
type: "vector<u8>",
|
|
1258
|
-
value: "virtual_token_reserves"
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
if (!result.data) return;
|
|
1262
|
-
return BigInt(result.data.content.fields.value);
|
|
1263
|
-
}
|
|
1264
|
-
Moonbags.getDynamicVirtualTokenReserves = getDynamicVirtualTokenReserves;
|
|
1265
|
-
function buyExactInReturnsWithLock(params) {
|
|
1266
|
-
const { inputAmount, amountIn, pool, config, dynamicVirtualTokenReserves } = params;
|
|
1267
|
-
const virtualSuiReserves = BigInt(pool.virtual_sui_reserves);
|
|
1268
|
-
const virtualTokenReserves = BigInt(pool.virtual_token_reserves);
|
|
1269
|
-
const remainTokenReserves = BigInt(pool.remain_token_reserves.fields.balance);
|
|
1270
|
-
const expectedOut = MoonbagsPackage.Curves.calculateRemoveLiquidityReturn(virtualSuiReserves, virtualTokenReserves, amountIn);
|
|
1271
|
-
const availableOut = virtualTokenReserves - (dynamicVirtualTokenReserves || remainTokenReserves);
|
|
1272
|
-
let finalOut = expectedOut;
|
|
1273
|
-
let usedSui = amountIn;
|
|
1274
|
-
if (expectedOut > availableOut) {
|
|
1275
|
-
finalOut = availableOut;
|
|
1276
|
-
usedSui = MoonbagsPackage.Curves.calculateAddLiquidityCost(virtualSuiReserves, virtualTokenReserves, availableOut) + BigInt(1);
|
|
1277
|
-
}
|
|
1278
|
-
const feeAmount = usedSui * BigInt(config.platform_fee) / constants_MoonbagsConstants.FEE_DENOMINATOR;
|
|
1279
|
-
tiny_invariant_default()(inputAmount >= usedSui + feeAmount, "Input amount is less than used SUI + fee");
|
|
1280
|
-
return {
|
|
1281
|
-
receivedCurve: finalOut,
|
|
1282
|
-
receivedSui: inputAmount - usedSui - feeAmount
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1285
|
-
Moonbags.buyExactInReturnsWithLock = buyExactInReturnsWithLock;
|
|
1286
|
-
function sellReturns(params) {
|
|
1287
|
-
const { amountIn, pool, config } = params;
|
|
1288
|
-
const virtualSuiReserves = BigInt(pool.virtual_sui_reserves);
|
|
1289
|
-
const virtualTokenReserves = BigInt(pool.virtual_token_reserves);
|
|
1290
|
-
const realSuiReserves = BigInt(pool.real_sui_reserves.fields.balance);
|
|
1291
|
-
let rawSuiOut = MoonbagsPackage.Curves.calculateRemoveLiquidityReturn(virtualTokenReserves, virtualSuiReserves, amountIn);
|
|
1292
|
-
if (rawSuiOut > realSuiReserves) rawSuiOut = realSuiReserves;
|
|
1293
|
-
const feeAmount = rawSuiOut * BigInt(config.platform_fee) / constants_MoonbagsConstants.FEE_DENOMINATOR;
|
|
1294
|
-
const finalSuiOut = rawSuiOut - feeAmount;
|
|
1295
|
-
return {
|
|
1296
|
-
receivedCurve: BigInt(0),
|
|
1297
|
-
receivedSui: finalSuiOut
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
Moonbags.sellReturns = sellReturns;
|
|
1301
|
-
})(MoonbagsPackage.Moonbags || (MoonbagsPackage.Moonbags = {}));
|
|
1302
|
-
})(package_MoonbagsPackage || (package_MoonbagsPackage = {}));
|
|
1303
|
-
var package_MoonbagsPackage;
|
|
1304
|
-
(function(MoonbagsCalculation) {
|
|
1305
|
-
async function getCurveAmountAfterBuy(params, suiClient) {
|
|
1306
|
-
let { suiAmount, poolId, frontendFee } = params;
|
|
1307
|
-
const [poolMoveStruct, configMoveStruct, dynamicVirtualTokenReserves] = await Promise.all([
|
|
1308
|
-
getMoveObjectContent(suiClient, poolId),
|
|
1309
|
-
getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID),
|
|
1310
|
-
package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(suiClient, poolId)
|
|
1311
|
-
]);
|
|
1312
|
-
const pool = poolMoveStruct;
|
|
1313
|
-
const config = configMoveStruct;
|
|
1314
|
-
if (void 0 !== frontendFee) suiAmount = getAmountAfterFee(suiAmount, frontendFee);
|
|
1315
|
-
const usedSui = suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
|
|
1316
|
-
const { receivedCurve } = package_MoonbagsPackage.Moonbags.buyExactInReturnsWithLock({
|
|
1317
|
-
inputAmount: suiAmount,
|
|
1318
|
-
amountIn: usedSui,
|
|
1319
|
-
pool,
|
|
1320
|
-
config,
|
|
1321
|
-
dynamicVirtualTokenReserves
|
|
1322
|
-
});
|
|
1323
|
-
return receivedCurve;
|
|
1324
|
-
}
|
|
1325
|
-
MoonbagsCalculation.getCurveAmountAfterBuy = getCurveAmountAfterBuy;
|
|
1326
|
-
async function getSuiAmountAfterSell(params, suiClient) {
|
|
1327
|
-
const { curveAmount, poolId, frontendFee } = params;
|
|
1328
|
-
const [poolMoveStruct, configMoveStruct] = await Promise.all([
|
|
1329
|
-
getMoveObjectContent(suiClient, poolId),
|
|
1330
|
-
getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID)
|
|
1331
|
-
]);
|
|
1332
|
-
const pool = poolMoveStruct;
|
|
1333
|
-
const config = configMoveStruct;
|
|
1334
|
-
const { receivedSui } = package_MoonbagsPackage.Moonbags.sellReturns({
|
|
1335
|
-
amountIn: curveAmount,
|
|
1336
|
-
pool,
|
|
1337
|
-
config
|
|
1338
|
-
});
|
|
1339
|
-
if (void 0 !== frontendFee) return getAmountAfterFee(receivedSui, frontendFee);
|
|
1340
|
-
return receivedSui;
|
|
1341
|
-
}
|
|
1342
|
-
MoonbagsCalculation.getSuiAmountAfterSell = getSuiAmountAfterSell;
|
|
1343
|
-
async function getUsedSuiForTx(params, suiClient) {
|
|
1344
|
-
let { suiAmount, frontendFee } = params;
|
|
1345
|
-
const configMoveStruct = await getMoveObjectContent(suiClient, constants_MoonbagsConstants.CONFIG_OBJECT_ID);
|
|
1346
|
-
const config = configMoveStruct;
|
|
1347
|
-
if (void 0 !== frontendFee) suiAmount = getAmountAfterFee(suiAmount, frontendFee);
|
|
1348
|
-
return suiAmount * constants_MoonbagsConstants.FEE_DENOMINATOR / (constants_MoonbagsConstants.FEE_DENOMINATOR + BigInt(config.platform_fee));
|
|
1349
|
-
}
|
|
1350
|
-
MoonbagsCalculation.getUsedSuiForTx = getUsedSuiForTx;
|
|
1351
|
-
})(calculation_MoonbagsCalculation || (calculation_MoonbagsCalculation = {}));
|
|
1352
|
-
var calculation_MoonbagsCalculation;
|
|
1353
|
-
(function(MoonbagsTransaction) {
|
|
1354
|
-
async function buildBuyTx(params, suiClient) {
|
|
1355
|
-
const { tx, coinOut } = await splitSuiCoinAfterFeeFromBuyTx(params, suiClient);
|
|
1356
|
-
tiny_invariant_default()(coinOut, "Coin out is required");
|
|
1357
|
-
const usedSui = await calculation_MoonbagsCalculation.getUsedSuiForTx({
|
|
1358
|
-
suiAmount: BigInt(params.inputAmount),
|
|
1359
|
-
frontendFee: params.frontendFee
|
|
1360
|
-
}, suiClient);
|
|
1361
|
-
const [suiCoin, curveCoin] = tx.moveCall({
|
|
1362
|
-
target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,
|
|
1363
|
-
typeArguments: [
|
|
1364
|
-
params.outCoinType
|
|
1365
|
-
],
|
|
1366
|
-
arguments: [
|
|
1367
|
-
tx.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
|
|
1368
|
-
tx.object(constants_MoonbagsConstants.LOCK_CONFIG_OBJECT_ID),
|
|
1369
|
-
coinOut,
|
|
1370
|
-
tx.pure.u64(usedSui),
|
|
1371
|
-
tx.pure.u64(params.minAmountOut),
|
|
1372
|
-
tx.object(constants_MoonbagsConstants.BURN_MANAGER_OBJECT_ID),
|
|
1373
|
-
tx.object(constants_MoonbagsConstants.POOLS_OBJECT_ID),
|
|
1374
|
-
tx.object(constants_MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID),
|
|
1375
|
-
tx.object(SUI_METADATA_OBJECT_ID),
|
|
1376
|
-
tx.object(CLOCK_OBJECT_ID)
|
|
1377
|
-
]
|
|
1378
|
-
});
|
|
1379
|
-
bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, SUI_FULL_TYPE, suiCoin, params.accountAddress);
|
|
1380
|
-
return {
|
|
1381
|
-
tx,
|
|
1382
|
-
coinOut: curveCoin
|
|
1383
|
-
};
|
|
1384
|
-
}
|
|
1385
|
-
MoonbagsTransaction.buildBuyTx = buildBuyTx;
|
|
1386
|
-
async function buildSellTx(params, suiClient) {
|
|
1387
|
-
tiny_invariant_default()(params.outCoinType === SUI_FULL_TYPE || params.outCoinType === SUI_TYPE, "Output must be SUI");
|
|
1388
|
-
const { tx, coinData } = await getSplitCoinForTx({
|
|
1389
|
-
amount: params.inputAmount,
|
|
1390
|
-
coinType: params.inCoinType,
|
|
1391
|
-
inheritTx: params.extendTx?.tx,
|
|
1392
|
-
account: params.accountAddress,
|
|
1393
|
-
splits: [
|
|
1394
|
-
params.inputAmount
|
|
1395
|
-
]
|
|
1396
|
-
}, suiClient);
|
|
1397
|
-
const [inputCoin] = coinData;
|
|
1398
|
-
const [suiCoin, curveCoin] = tx.moveCall({
|
|
1399
|
-
target: `${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,
|
|
1400
|
-
typeArguments: [
|
|
1401
|
-
params.inCoinType
|
|
1402
|
-
],
|
|
1403
|
-
arguments: [
|
|
1404
|
-
tx.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),
|
|
1405
|
-
inputCoin,
|
|
1406
|
-
tx.pure.u64(params.minAmountOut),
|
|
1407
|
-
tx.object(CLOCK_OBJECT_ID)
|
|
1408
|
-
]
|
|
1409
|
-
});
|
|
1410
|
-
bluefin_BluefinTx.transferOrDestroyZeroCoin(tx, params.inCoinType, curveCoin, params.accountAddress);
|
|
1411
|
-
return await splitSuiCoinAfterFeeFromSellTx(tx, params, suiCoin);
|
|
1412
|
-
}
|
|
1413
|
-
MoonbagsTransaction.buildSellTx = buildSellTx;
|
|
1414
|
-
async function getBuyTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
|
|
1415
|
-
tiny_invariant_default()(coinInType === SUI_TYPE, "coinInType must be SUI for buy transaction");
|
|
1416
|
-
tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
|
|
1417
|
-
tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
|
|
1418
|
-
tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
|
|
1419
|
-
const inputAmount = coinInAmount;
|
|
1420
|
-
const outputAmount = await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({
|
|
1421
|
-
poolId: poolId,
|
|
1422
|
-
suiAmount: inputAmount,
|
|
1423
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
|
|
1424
|
-
}, suiClient);
|
|
1425
|
-
const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
|
|
1426
|
-
let { tx, coinOut } = await buildBuyTx({
|
|
1427
|
-
accountAddress: walletAddress,
|
|
1428
|
-
inCoinType: coinInType,
|
|
1429
|
-
outCoinType: coinOutType,
|
|
1430
|
-
inputAmount: inputAmount.toString(),
|
|
1431
|
-
minAmountOut: minAmountOut.toString(),
|
|
1432
|
-
poolId: poolId,
|
|
1433
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0,
|
|
1434
|
-
frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
|
|
1435
|
-
extendTx: void 0,
|
|
1436
|
-
isSponsored: false
|
|
1437
|
-
}, suiClient);
|
|
1438
|
-
tiny_invariant_default()(coinOut, "Coin out is required");
|
|
1439
|
-
tx.transferObjects([
|
|
1440
|
-
coinOut
|
|
1441
|
-
], tx.pure.address(walletAddress));
|
|
1442
|
-
tx.setSender(walletAddress);
|
|
1443
|
-
const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
|
|
1444
|
-
tx = await addGasFee({
|
|
1445
|
-
inheritTx: tx,
|
|
1446
|
-
sender: walletAddress,
|
|
1447
|
-
feeAmount,
|
|
1448
|
-
suiInputAmount: inputAmount
|
|
1449
|
-
}, suiClient);
|
|
1450
|
-
return tx.build({
|
|
1451
|
-
client: suiClient
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
MoonbagsTransaction.getBuyTransaction = getBuyTransaction;
|
|
1455
|
-
async function getSellTransaction({ coinInAmount, coinInType, coinOutType, poolId, slippage, walletAddress, tradeFee }, suiClient) {
|
|
1456
|
-
tiny_invariant_default()(coinOutType === SUI_TYPE, "coinOutType must be SUI for sell transaction");
|
|
1457
|
-
tiny_invariant_default()(coinOutType !== coinInType, "coinOutType must be different from coinInType");
|
|
1458
|
-
tiny_invariant_default()(slippage >= 0 && slippage < 1, "slippage must be between 0 (inclusive) and 1 (exclusive)");
|
|
1459
|
-
tiny_invariant_default()(coinInAmount > 0, "coinInAmount must be greater than 0");
|
|
1460
|
-
const inputAmount = coinInAmount;
|
|
1461
|
-
const outputAmount = await calculation_MoonbagsCalculation.getSuiAmountAfterSell({
|
|
1462
|
-
poolId: poolId,
|
|
1463
|
-
curveAmount: inputAmount,
|
|
1464
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0
|
|
1465
|
-
}, suiClient);
|
|
1466
|
-
const minAmountOut = BigInt(new (external_bignumber_js_default())(outputAmount.toString()).multipliedBy(1 - slippage).toFixed(0, 3));
|
|
1467
|
-
let { tx, coinOut } = await buildSellTx({
|
|
1468
|
-
accountAddress: walletAddress,
|
|
1469
|
-
inCoinType: coinInType,
|
|
1470
|
-
outCoinType: coinOutType,
|
|
1471
|
-
inputAmount: inputAmount.toString(),
|
|
1472
|
-
minAmountOut: minAmountOut.toString(),
|
|
1473
|
-
poolId: poolId,
|
|
1474
|
-
frontendFee: tradeFee ? tradeFee.tradeFeePercent : void 0,
|
|
1475
|
-
frontendFeeRecipient: tradeFee ? tradeFee.tradeFeeRecipientAddress : void 0,
|
|
1476
|
-
extendTx: void 0,
|
|
1477
|
-
isSponsored: false
|
|
1478
|
-
}, suiClient);
|
|
1479
|
-
tiny_invariant_default()(coinOut, "Coin out is required");
|
|
1480
|
-
tx.transferObjects([
|
|
1481
|
-
coinOut
|
|
1482
|
-
], tx.pure.address(walletAddress));
|
|
1483
|
-
tx.setSender(walletAddress);
|
|
1484
|
-
const feeAmount = await getNeededGasFee(suiClient, tx, walletAddress, 0);
|
|
1485
|
-
tx = await addGasFee({
|
|
1486
|
-
inheritTx: tx,
|
|
1487
|
-
sender: walletAddress,
|
|
1488
|
-
feeAmount
|
|
1489
|
-
}, suiClient);
|
|
1490
|
-
return tx.build({
|
|
1491
|
-
client: suiClient
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
MoonbagsTransaction.getSellTransaction = getSellTransaction;
|
|
1495
|
-
})(transaction_MoonbagsTransaction || (transaction_MoonbagsTransaction = {}));
|
|
1496
|
-
var transaction_MoonbagsTransaction;
|
|
1497
|
-
const ed25519_namespaceObject = require("@mysten/sui/keypairs/ed25519");
|
|
1498
|
-
const CONSTANTS = {
|
|
1499
|
-
GAS_FEE_BUFFER_PERCENTAGE: 0.1
|
|
1500
|
-
};
|
|
1501
|
-
class DraftTransferTx {
|
|
1502
|
-
suiClient;
|
|
1503
|
-
constructor(suiClient){
|
|
1504
|
-
this.suiClient = suiClient;
|
|
1505
|
-
}
|
|
1506
|
-
validatePrivateKey(privateKey, expectedSender) {
|
|
1507
|
-
tiny_invariant_default()(privateKey?.trim(), "Private key is required");
|
|
1508
|
-
const keypair = ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(privateKey);
|
|
1509
|
-
const derivedAddress = keypair.getPublicKey().toSuiAddress();
|
|
1510
|
-
if (derivedAddress !== expectedSender) throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
|
|
1511
|
-
return keypair;
|
|
1512
|
-
}
|
|
1513
|
-
async createDraft(sender, recipient, amountMIST) {
|
|
1514
|
-
tiny_invariant_default()(sender?.trim(), "Sender address is required");
|
|
1515
|
-
tiny_invariant_default()(recipient?.trim(), "Recipient address is required");
|
|
1516
|
-
tiny_invariant_default()(sender !== recipient, "Sender and recipient cannot be the same");
|
|
1517
|
-
tiny_invariant_default()(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
|
|
1518
|
-
try {
|
|
1519
|
-
let transaction = new transactions_namespaceObject.Transaction();
|
|
1520
|
-
const [coin] = transaction.splitCoins(transaction.gas, [
|
|
1521
|
-
amountMIST
|
|
1522
|
-
]);
|
|
1523
|
-
transaction.transferObjects([
|
|
1524
|
-
coin
|
|
1525
|
-
], recipient);
|
|
1526
|
-
transaction.setSender(sender);
|
|
1527
|
-
const referenceGasPrice = await this.suiClient.getReferenceGasPrice();
|
|
1528
|
-
transaction.setGasPrice(referenceGasPrice);
|
|
1529
|
-
const feeAmount = await getNeededGasFee(this.suiClient, transaction, sender, CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);
|
|
1530
|
-
transaction = await addGasFee({
|
|
1531
|
-
inheritTx: transaction,
|
|
1532
|
-
sender,
|
|
1533
|
-
feeAmount,
|
|
1534
|
-
suiInputAmount: amountMIST
|
|
1535
|
-
}, this.suiClient);
|
|
1536
|
-
const txBytes = await transaction.build({
|
|
1537
|
-
client: this.suiClient
|
|
1538
|
-
});
|
|
1539
|
-
const txDraftBase64 = Buffer.from(txBytes).toString("base64");
|
|
1540
|
-
const txDigest = await transaction.getDigest();
|
|
1541
|
-
return {
|
|
1542
|
-
sender,
|
|
1543
|
-
recipient,
|
|
1544
|
-
amountMIST,
|
|
1545
|
-
txDraftBase64,
|
|
1546
|
-
txDigest
|
|
1547
|
-
};
|
|
1548
|
-
} catch (error) {
|
|
1549
|
-
throw new Error(`Failed to create draft transaction: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
async execute(draftTx, privateKey) {
|
|
1553
|
-
try {
|
|
1554
|
-
tiny_invariant_default()(draftTx, "Draft transaction is required");
|
|
1555
|
-
tiny_invariant_default()(draftTx.txDraftBase64?.trim(), "Transaction data is required");
|
|
1556
|
-
const keypair = this.validatePrivateKey(privateKey, draftTx.sender);
|
|
1557
|
-
const txBytes = (0, utils_namespaceObject.fromBase64)(draftTx.txDraftBase64);
|
|
1558
|
-
const { signature } = await keypair.signTransaction(txBytes);
|
|
1559
|
-
const result = await this.suiClient.executeTransactionBlock({
|
|
1560
|
-
transactionBlock: txBytes,
|
|
1561
|
-
signature
|
|
1562
|
-
});
|
|
1563
|
-
return {
|
|
1564
|
-
success: true,
|
|
1565
|
-
txDigest: result.digest,
|
|
1566
|
-
effects: result.effects
|
|
1567
|
-
};
|
|
1568
|
-
} catch (error) {
|
|
1569
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
1570
|
-
return {
|
|
1571
|
-
success: false,
|
|
1572
|
-
error: errorMessage
|
|
1573
|
-
};
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
async getTransactionStatus(txDigest) {
|
|
1577
|
-
tiny_invariant_default()(txDigest?.trim(), "Transaction digest is required");
|
|
1578
|
-
try {
|
|
1579
|
-
const txResponse = await this.suiClient.getTransactionBlock({
|
|
1580
|
-
digest: txDigest,
|
|
1581
|
-
options: {
|
|
1582
|
-
showEffects: true
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
if (!txResponse?.effects?.status) return "pending";
|
|
1586
|
-
return "success" === txResponse.effects.status.status ? "success" : "failure";
|
|
1587
|
-
} catch (error) {
|
|
1588
|
-
if (error instanceof Error) {
|
|
1589
|
-
if (error.message.includes("not found") || error.message.includes("Could not find")) return "pending";
|
|
1590
|
-
}
|
|
1591
|
-
return "failure";
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
exports.AftermathAggregator = __webpack_exports__.AftermathAggregator;
|
|
1596
|
-
exports.AstrosAggregator = __webpack_exports__.AstrosAggregator;
|
|
1597
|
-
exports.BASE_BPS = __webpack_exports__.BASE_BPS;
|
|
1598
|
-
exports.BLUEFIN_PACKAGE_ID = __webpack_exports__.BLUEFIN_PACKAGE_ID;
|
|
1599
|
-
exports.BlastFunConstants = __webpack_exports__.BlastFunConstants;
|
|
1600
|
-
exports.BlastFunCustomCalculation = __webpack_exports__.BlastFunCustomCalculation;
|
|
1601
|
-
exports.BlastFunCustomTransaction = __webpack_exports__.BlastFunCustomTransaction;
|
|
1602
|
-
exports.BlastFunPackage = __webpack_exports__.BlastFunPackage;
|
|
1603
|
-
exports.BlastFunSDKCalculation = __webpack_exports__.BlastFunSDKCalculation;
|
|
1604
|
-
exports.BlastFunSDKTransaction = __webpack_exports__.BlastFunSDKTransaction;
|
|
1605
|
-
exports.BluefinTx = __webpack_exports__.BluefinTx;
|
|
1606
|
-
exports.Bps = __webpack_exports__.Bps;
|
|
1607
|
-
exports.CLOCK_OBJECT_ID = __webpack_exports__.CLOCK_OBJECT_ID;
|
|
1608
|
-
exports.CetusAggregator = __webpack_exports__.CetusAggregator;
|
|
1609
|
-
exports.DraftTransferTx = __webpack_exports__.DraftTransferTx;
|
|
1610
|
-
exports.FlowXAggregator = __webpack_exports__.FlowXAggregator;
|
|
1611
|
-
exports.MathUtils = __webpack_exports__.MathUtils;
|
|
1612
|
-
exports.MoonbagsCalculation = __webpack_exports__.MoonbagsCalculation;
|
|
1613
|
-
exports.MoonbagsConstants = __webpack_exports__.MoonbagsConstants;
|
|
1614
|
-
exports.MoonbagsPackage = __webpack_exports__.MoonbagsPackage;
|
|
1615
|
-
exports.MoonbagsTransaction = __webpack_exports__.MoonbagsTransaction;
|
|
1616
|
-
exports.NATIVE_USDC_TOKEN_TYPE = __webpack_exports__.NATIVE_USDC_TOKEN_TYPE;
|
|
1617
|
-
exports.SUI_FULL_TYPE = __webpack_exports__.SUI_FULL_TYPE;
|
|
1618
|
-
exports.SUI_METADATA_OBJECT_ID = __webpack_exports__.SUI_METADATA_OBJECT_ID;
|
|
1619
|
-
exports.SUI_TYPE = __webpack_exports__.SUI_TYPE;
|
|
1620
|
-
exports.SevenKAggregator = __webpack_exports__.SevenKAggregator;
|
|
1621
|
-
exports.SupportedAggregator = __webpack_exports__.SupportedAggregator;
|
|
1622
|
-
exports.SupportedBondingCurve = __webpack_exports__.SupportedBondingCurve;
|
|
1623
|
-
exports.TradeFeeOptions = __webpack_exports__.TradeFeeOptions;
|
|
1624
|
-
exports.USDC_TOKEN_TYPE = __webpack_exports__.USDC_TOKEN_TYPE;
|
|
1625
|
-
exports.adaptSuiClient = __webpack_exports__.adaptSuiClient;
|
|
1626
|
-
exports.adaptTransaction = __webpack_exports__.adaptTransaction;
|
|
1627
|
-
exports.addGasFee = __webpack_exports__.addGasFee;
|
|
1628
|
-
exports.createCompatibleSuiClient = __webpack_exports__.createCompatibleSuiClient;
|
|
1629
|
-
exports.getAmountAfterFee = __webpack_exports__.getAmountAfterFee;
|
|
1630
|
-
exports.getCoinObjectIdsByAmount = __webpack_exports__.getCoinObjectIdsByAmount;
|
|
1631
|
-
exports.getMemezPumpSDK = __webpack_exports__.getMemezPumpSDK;
|
|
1632
|
-
exports.getMoveObject = __webpack_exports__.getMoveObject;
|
|
1633
|
-
exports.getMoveObjectContent = __webpack_exports__.getMoveObjectContent;
|
|
1634
|
-
exports.getNeededGasFee = __webpack_exports__.getNeededGasFee;
|
|
1635
|
-
exports.getSplitCoinForTx = __webpack_exports__.getSplitCoinForTx;
|
|
1636
|
-
exports.getSplitCoinsAfterFee = __webpack_exports__.getSplitCoinsAfterFee;
|
|
1637
|
-
exports.splitSuiCoinAfterFeeFromBuyTx = __webpack_exports__.splitSuiCoinAfterFeeFromBuyTx;
|
|
1638
|
-
exports.splitSuiCoinAfterFeeFromSellTx = __webpack_exports__.splitSuiCoinAfterFeeFromSellTx;
|
|
1639
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
1640
|
-
"AftermathAggregator",
|
|
1641
|
-
"AstrosAggregator",
|
|
1642
|
-
"BASE_BPS",
|
|
1643
|
-
"BLUEFIN_PACKAGE_ID",
|
|
1644
|
-
"BlastFunConstants",
|
|
1645
|
-
"BlastFunCustomCalculation",
|
|
1646
|
-
"BlastFunCustomTransaction",
|
|
1647
|
-
"BlastFunPackage",
|
|
1648
|
-
"BlastFunSDKCalculation",
|
|
1649
|
-
"BlastFunSDKTransaction",
|
|
1650
|
-
"BluefinTx",
|
|
1651
|
-
"Bps",
|
|
1652
|
-
"CLOCK_OBJECT_ID",
|
|
1653
|
-
"CetusAggregator",
|
|
1654
|
-
"DraftTransferTx",
|
|
1655
|
-
"FlowXAggregator",
|
|
1656
|
-
"MathUtils",
|
|
1657
|
-
"MoonbagsCalculation",
|
|
1658
|
-
"MoonbagsConstants",
|
|
1659
|
-
"MoonbagsPackage",
|
|
1660
|
-
"MoonbagsTransaction",
|
|
1661
|
-
"NATIVE_USDC_TOKEN_TYPE",
|
|
1662
|
-
"SUI_FULL_TYPE",
|
|
1663
|
-
"SUI_METADATA_OBJECT_ID",
|
|
1664
|
-
"SUI_TYPE",
|
|
1665
|
-
"SevenKAggregator",
|
|
1666
|
-
"SupportedAggregator",
|
|
1667
|
-
"SupportedBondingCurve",
|
|
1668
|
-
"TradeFeeOptions",
|
|
1669
|
-
"USDC_TOKEN_TYPE",
|
|
1670
|
-
"adaptSuiClient",
|
|
1671
|
-
"adaptTransaction",
|
|
1672
|
-
"addGasFee",
|
|
1673
|
-
"createCompatibleSuiClient",
|
|
1674
|
-
"getAmountAfterFee",
|
|
1675
|
-
"getCoinObjectIdsByAmount",
|
|
1676
|
-
"getMemezPumpSDK",
|
|
1677
|
-
"getMoveObject",
|
|
1678
|
-
"getMoveObjectContent",
|
|
1679
|
-
"getNeededGasFee",
|
|
1680
|
-
"getSplitCoinForTx",
|
|
1681
|
-
"getSplitCoinsAfterFee",
|
|
1682
|
-
"splitSuiCoinAfterFeeFromBuyTx",
|
|
1683
|
-
"splitSuiCoinAfterFeeFromSellTx"
|
|
1684
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
1685
|
-
Object.defineProperty(exports, '__esModule', {
|
|
1686
|
-
value: true
|
|
1687
|
-
});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var types_TradeFeeOptions,constants_BlastFunConstants,package_MathUtils,package_Bps,package_BlastFunPackage,custom_calculation_BlastFunCustomCalculation,bluefin_BluefinTx,custom_transaction_BlastFunCustomTransaction,sdk_calculation_BlastFunSDKCalculation,sdk_transaction_BlastFunSDKTransaction,constants_MoonbagsConstants,package_MoonbagsPackage,calculation_MoonbagsCalculation,transaction_MoonbagsTransaction,__webpack_require__={};__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{TradeFeeOptions:()=>types_TradeFeeOptions,getMoveObjectContent:()=>getMoveObjectContent,MoonbagsCalculation:()=>calculation_MoonbagsCalculation,SevenKAggregator:()=>_7k_SevenKAggregator,SupportedBondingCurve:()=>types_SupportedBondingCurve,CLOCK_OBJECT_ID:()=>CLOCK_OBJECT_ID,BlastFunCustomCalculation:()=>custom_calculation_BlastFunCustomCalculation,BluefinTx:()=>bluefin_BluefinTx,Bps:()=>package_Bps,BlastFunCustomTransaction:()=>custom_transaction_BlastFunCustomTransaction,BASE_BPS:()=>BASE_BPS,MoonbagsConstants:()=>constants_MoonbagsConstants,splitSuiCoinAfterFeeFromBuyTx:()=>splitSuiCoinAfterFeeFromBuyTx,DraftTransferTx:()=>DraftTransferTx,SUI_FULL_TYPE:()=>SUI_FULL_TYPE,getSplitCoinForTx:()=>getSplitCoinForTx,BlastFunSDKTransaction:()=>sdk_transaction_BlastFunSDKTransaction,AstrosAggregator:()=>astros_AstrosAggregator,SUI_TYPE:()=>SUI_TYPE,AftermathAggregator:()=>aftermath_AftermathAggregator,getSplitCoinsAfterFee:()=>getSplitCoinsAfterFee,addGasFee:()=>addGasFee,MoonbagsPackage:()=>package_MoonbagsPackage,NATIVE_USDC_TOKEN_TYPE:()=>NATIVE_USDC_TOKEN_TYPE,USDC_TOKEN_TYPE:()=>USDC_TOKEN_TYPE,getAmountAfterFee:()=>getAmountAfterFee,SUI_METADATA_OBJECT_ID:()=>SUI_METADATA_OBJECT_ID,SupportedAggregator:()=>common_SupportedAggregator,splitSuiCoinAfterFeeFromSellTx:()=>splitSuiCoinAfterFeeFromSellTx,createCompatibleSuiClient:()=>createCompatibleSuiClient,BLUEFIN_PACKAGE_ID:()=>BLUEFIN_PACKAGE_ID,MoonbagsTransaction:()=>transaction_MoonbagsTransaction,BlastFunConstants:()=>constants_BlastFunConstants,CetusAggregator:()=>cetus_CetusAggregator,adaptSuiClient:()=>adaptSuiClient,getCoinObjectIdsByAmount:()=>getCoinObjectIdsByAmount,getMoveObject:()=>getMoveObject,FlowXAggregator:()=>flowx_FlowXAggregator,adaptTransaction:()=>adaptTransaction,MathUtils:()=>package_MathUtils,BlastFunSDKCalculation:()=>sdk_calculation_BlastFunSDKCalculation,BlastFunPackage:()=>package_BlastFunPackage,getMemezPumpSDK:()=>getMemezPumpSDK,getNeededGasFee:()=>getNeededGasFee});const cjs_namespaceObject=require("@7kprotocol/sdk-ts/cjs"),transactions_namespaceObject=require("@mysten/sui/transactions"),external_bignumber_js_namespaceObject=require("bignumber.js");var external_bignumber_js_default=__webpack_require__.n(external_bignumber_js_namespaceObject);class _7k_SevenKAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{this._config.sevenKApiKey&&cjs_namespaceObject.Config.setApiKey(this._config.sevenKApiKey);let o=a?a.tradeFeePercent:this._config.defaultTradeFee.tradeFeePercent;return(0,cjs_namespaceObject.getQuote)({tokenIn:t,tokenOut:n,amountIn:e.toString(),commissionBps:1e4*o})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:a}){let o,i;a?(o=a.tradeFeePercent,i=a.tradeFeeRecipientAddress):(o=this._config.defaultTradeFee.tradeFeePercent,i=this._config.defaultTradeFee.tradeFeeRecipientAddress);let r=await (0,cjs_namespaceObject.buildTx)({quoteResponse:t,slippage:n,accountAddress:e,commission:{partner:i,commissionBps:1e4*o}});return r.tx instanceof cjs_namespaceObject.BluefinXTx?transactions_namespaceObject.Transaction.from(r.tx.txBytes).build({client:this._suiClient}):(r.tx.setSender(e),r.tx.build({client:this._suiClient}))}}(_7k_SevenKAggregator||(_7k_SevenKAggregator={})).toCommonTradeRoutes=function(e){let t=[];if(!e.routes||0===e.routes.length)return null;for(let n of e.routes){let e=[],a={};for(let t of n.hops){for(let e of t.pool.allTokens)a[e.address]=e.decimal;let n=a[t.tokenIn]??0,o=a[t.tokenOut]??0,i=BigInt(new(external_bignumber_js_default())(t.tokenInAmount).multipliedBy(10**n).toFixed(0,3)),r=BigInt(new(external_bignumber_js_default())(t.tokenOutAmount).multipliedBy(10**o).toFixed(0,3));e.push({poolAddress:t.poolId,coinIn:t.tokenIn,coinOut:t.tokenOut,amountIn:i,amountOut:r})}if(0===e.length)continue;let o=a[n.tokenIn]??0,i=a[n.tokenOut]??0,r=BigInt(new(external_bignumber_js_default())(n.tokenInAmount).multipliedBy(10**o).toFixed(0,3)),s=BigInt(new(external_bignumber_js_default())(n.tokenOutAmount).multipliedBy(10**i).toFixed(0,3));t.push({paths:e,coinIn:n.tokenIn,coinOut:n.tokenOut,amountIn:r,amountOut:s})}return 0===t.length?null:{coinIn:e.tokenIn,coinOut:e.tokenOut,amountIn:BigInt(e.swapAmountWithDecimal),amountOut:BigInt(e.returnAmountWithDecimal),routes:t}};const external_aftermath_ts_sdk_namespaceObject=require("aftermath-ts-sdk");class aftermath_AftermathAggregator{_config;_aftermathClient;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async aftermathClient(){if(this._aftermathClient)return this._aftermathClient;if(this._config.aftermathApiEndpoint?this._aftermathClient=new external_aftermath_ts_sdk_namespaceObject.Aftermath(this._config.aftermathApiEndpoint):this._aftermathClient=new external_aftermath_ts_sdk_namespaceObject.Aftermath("MAINNET"),await this._aftermathClient.init(),this._config.aftermathApiKey){let e=external_aftermath_ts_sdk_namespaceObject.Helpers.keypairFromPrivateKey(this._config.aftermathApiKey);await this._aftermathClient.Auth().init({async signMessageCallback({message:t}){let{signature:n}=await e.signPersonalMessage(t);return{signature:n}},walletAddress:e.toSuiAddress()})}return this._aftermathClient}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){let o;return o=a?{recipient:a.tradeFeeRecipientAddress,feePercentage:a.tradeFeePercent}:{recipient:this._config.defaultTradeFee.tradeFeeRecipientAddress,feePercentage:this._config.defaultTradeFee.tradeFeePercent},(await this.aftermathClient()).Router().getCompleteTradeRouteGivenAmountIn({coinInAmount:e,coinInType:t,coinOutType:n,externalFee:o})}async getTransaction({completeRoute:e,walletAddress:t,slippage:n}){let a=await this.aftermathClient(),o=await a.Router().getTransactionForCompleteTradeRoute({completeRoute:e,walletAddress:t,slippage:n,isSponsoredTx:!1});return o.setSender(t),o.build({client:this._suiClient})}}(aftermath_AftermathAggregator||(aftermath_AftermathAggregator={})).toCommonTradeRoutes=function(e){if(0===e.routes.length)return null;let t=[];for(let n of e.routes){let e=[];for(let t of n.paths)e.push({poolAddress:t.poolId,coinIn:t.coinIn.type,coinOut:t.coinOut.type,amountIn:BigInt(t.coinIn.amount),amountOut:BigInt(t.coinOut.amount)});0!==e.length&&t.push({paths:e,coinIn:n.coinIn.type,coinOut:n.coinOut.type,amountIn:n.coinIn.amount,amountOut:n.coinOut.amount})}return 0===t.length?null:{coinIn:e.coinIn.type,coinOut:e.coinOut.type,amountIn:e.coinIn.amount,amountOut:e.coinOut.amount,routes:t}};const astros_aggregator_sdk_namespaceObject=require("@naviprotocol/astros-aggregator-sdk");function isSuiCoin(e){return"0x2::sui::SUI"===e||"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"===e}class astros_AstrosAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){try{let o;return o=a?{fee:a.tradeFeePercent,receiverAddress:a.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress},(0,astros_aggregator_sdk_namespaceObject.getQuote)(t,n,e,this._config.astrosApiKey,{byAmountIn:!0,serviceFee:o})}catch(e){return null}}returnMergedCoins(e,t,n){if(t.length<2)return e.object(t[0].coinObjectId);let a=0,o=[];t.sort((e,t)=>Number(t.balance)-Number(e.balance)).slice(1).forEach(e=>{a>=n||(a+=Number(e.balance),o.push(e.coinObjectId))});let i=t[0].coinObjectId;return e.mergeCoins(i,o),e.object(i)}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:a}){let o,i;o=a?{fee:a.tradeFeePercent,receiverAddress:a.tradeFeeRecipientAddress}:{fee:this._config.defaultTradeFee.tradeFeePercent,receiverAddress:this._config.defaultTradeFee.tradeFeeRecipientAddress};let r=new(external_bignumber_js_default())(e.amount_out).multipliedBy(1-n-o.fee).toNumber(),s=new transactions_namespaceObject.Transaction;if(isSuiCoin(e.from))i=s.splitCoins(s.gas,[s.pure.u64(e.amount_in)]);else{let n=await (0,astros_aggregator_sdk_namespaceObject.getCoins)(this._suiClient,t,e.from),a=this.returnMergedCoins(s,n.data,Number.parseFloat(e.amount_in));i=s.splitCoins(a,[s.pure.u64(e.amount_in)])}let u=await (0,astros_aggregator_sdk_namespaceObject.buildSwapPTBFromQuote)(t,s,r,i,e,void 0,!1,this._config.astrosApiKey,{serviceFee:o});return s.transferObjects([u],t),s.setSender(t),s.build({client:this._suiClient})}}(astros_AstrosAggregator||(astros_AstrosAggregator={})).toCommonTradeRoutes=function(e,t,n){if(0===e.routes.length)return null;let a=[];for(let t of e.routes){let e=[];for(let n of t.path)e.push({poolAddress:n.id,coinIn:n.from,coinOut:n.target,amountIn:BigInt(n.amount_in),amountOut:BigInt(n.amount_out)});0!==e.length&&a.push({amountIn:BigInt(t.amount_in),amountOut:BigInt(t.amount_out),coinIn:e[0].coinIn,coinOut:e[e.length-1].coinOut,paths:e})}return 0===a.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amount_in),amountOut:BigInt(e.amount_out),routes:a}};const aggregator_sdk_namespaceObject=require("@cetusprotocol/aggregator-sdk"),external_bn_js_namespaceObject=require("bn.js");var external_bn_js_default=__webpack_require__.n(external_bn_js_namespaceObject);(types_TradeFeeOptions||(types_TradeFeeOptions={})).equals=function(e,t){return e.tradeFeePercent===t.tradeFeePercent&&e.tradeFeeRecipientAddress===t.tradeFeeRecipientAddress};class cetus_CetusAggregator{_config;_suiClient;_cetusClient;constructor(e,t){this._config=e,this._suiClient=t}cetusClient(e,t){return t&&!types_TradeFeeOptions.equals(t,this._config.defaultTradeFee)?new aggregator_sdk_namespaceObject.AggregatorClient({client:this._suiClient,overlayFeeReceiver:t.tradeFeeRecipientAddress,overlayFeeRate:t.tradeFeePercent,env:aggregator_sdk_namespaceObject.Env.Mainnet,signer:e,...this._config.cetusApiKey&&this._config.cetusApiEndpoint?{apiKey:this._config.cetusApiKey,endpoint:this._config.cetusApiEndpoint}:{},partner:this._config.cetusPartnerId}):(this._cetusClient||(this._cetusClient=new aggregator_sdk_namespaceObject.AggregatorClient({client:this._suiClient,overlayFeeReceiver:this._config.defaultTradeFee.tradeFeeRecipientAddress,overlayFeeRate:this._config.defaultTradeFee.tradeFeePercent,env:aggregator_sdk_namespaceObject.Env.Mainnet,signer:e,...this._config.cetusApiKey&&this._config.cetusApiEndpoint?{apiKey:this._config.cetusApiKey,endpoint:this._config.cetusApiEndpoint}:{},partner:this._config.cetusPartnerId})),this._cetusClient)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){return this.cetusClient(void 0,a).findRouters({from:t,target:n,amount:new(external_bn_js_default())(e.toString()),byAmountIn:!0})}async getTransaction({completeRoute:e,walletAddress:t,slippage:n,tradeFee:a}){let o=new transactions_namespaceObject.Transaction,i=this.cetusClient(t,a);return await i.fastRouterSwap({router:e,txb:o,slippage:n}),await i.devInspectTransactionBlock(o),o.setSender(t),o.build({client:this._suiClient})}}(cetus_CetusAggregator||(cetus_CetusAggregator={})).toCommonTradeRoutes=function(e,t,n){if(0===e.paths.length)return null;let a=[],o=[],i=[];for(let t=0;t<e.paths.length;t++){let n=e.paths[t],a={poolAddress:n.id,amountIn:BigInt(n.amountIn),amountOut:BigInt(n.amountOut),coinIn:n.from,coinOut:n.target};if(i.push(a),t===e.paths.length-1)o.push([...i]);else{let a=e.paths[t+1];n.target!==a.from&&(o.push([...i]),i=[])}}for(let e of o)0!==e.length&&a.push({amountIn:e[0].amountIn,amountOut:e[e.length-1].amountOut,coinIn:e[0].coinIn,coinOut:e[e.length-1].coinOut,paths:e});return 0===a.length?null:{coinIn:t,coinOut:n,amountIn:BigInt(e.amountIn.toString(10)),amountOut:BigInt(e.amountOut.toString(10)),routes:a}};var common_SupportedAggregator=function(e){return e.ASTROS="ASTROS",e.AFTERMATH="AFTERMATH",e.SEVENK="7K",e.CETUS="CETUS",e.FLOWX="FLOWX",e}({});const sdk_namespaceObject=require("@flowx-finance/sdk");function getInputPercent(e){return 1e6*e}class flowx_FlowXAggregator{_config;_suiClient;constructor(e,t){this._config=e,this._suiClient=t}getCommission(e,t){let n,a;return t?(n=t.tradeFeePercent,a=t.tradeFeeRecipientAddress):(n=this._config.defaultTradeFee.tradeFeePercent,a=this._config.defaultTradeFee.tradeFeeRecipientAddress),new sdk_namespaceObject.Commission(a,new sdk_namespaceObject.Coin(e),sdk_namespaceObject.CommissionType.PERCENTAGE,getInputPercent(n),!0)}async getTradeRoute({coinInAmount:e,coinInType:t,coinOutType:n,tradeFee:a}){let o=new sdk_namespaceObject.AggregatorQuoter("mainnet",this._config.flowxApiKey);try{return o.getRoutes({tokenIn:t,tokenOut:n,amountIn:e.toString(),commission:this.getCommission(t,a)})}catch(e){return null}}async getTransaction({walletAddress:e,completeRoute:t,slippage:n,tradeFee:a}){return new sdk_namespaceObject.TradeBuilder("mainnet",t.routes).sender(e).slippage(getInputPercent(n)).commission(this.getCommission(t.coinIn.coinType,a)).build().buildTransaction({client:this._suiClient}).then(t=>(t.setSender(e),t.build({client:this._suiClient})))}}(flowx_FlowXAggregator||(flowx_FlowXAggregator={})).toCommonTradeRoutes=function(e){if(0===e.routes.length)return null;let t=[];for(let n of e.routes){let e=[];for(let t of n.paths)e.push({amountIn:BigInt(t.amountIn.toString()),amountOut:BigInt(t.amountOut.toString()),coinIn:t.input.coinType,coinOut:t.output.coinType,poolAddress:t.pool.id});0!==e.length&&t.push({amountIn:BigInt(n.amountIn.toString()),amountOut:BigInt(n.amountOut.toString()),coinIn:n.input.coinType,coinOut:n.output.coinType,paths:e})}return 0===t.length?null:{coinIn:e.coinIn.coinType,coinOut:e.coinOut.coinType,amountIn:BigInt(e.amountIn.toString()),amountOut:BigInt(e.amountOut.toString()),routes:t}},function(e){e.PACKAGE_ID_V4="0x7e6aa6e179466ab2814425a780b122575296d011119fa69d27f289f5a28814bd",e.MEMEZ_AV_OBJECT_ID="0x2319e3e76dfad73d8f4684bdbf42be4f32d8ce4521dd61becc8261dc918d82c0"}(constants_BlastFunConstants||(constants_BlastFunConstants={}));const tiny_invariant_namespaceObject=require("@minswap/tiny-invariant");var tiny_invariant_default=__webpack_require__.n(tiny_invariant_namespaceObject);async function getMoveObjectContent(e,t){return(await getMoveObject(e,t)).fields}async function getMoveObject(e,t){let n=await e.getObject({id:t,options:{showContent:!0}}),a=n.data?.content;return tiny_invariant_default()(a,"Pool object not found or has no content"),tiny_invariant_default()("moveObject"===a.dataType,"Object is not a Move object"),a}const BASE_BPS=1e4;function getSplitCoinsAfterFee(e,t){let n=BigInt(e),a=BigInt(Number(t)*BASE_BPS);if(a===BigInt(0))return[n.toString()];let o=n*a/BigInt(BASE_BPS);return[(n-o).toString(),o.toString()]}function getAmountAfterFee(e,t){if(!t||0>=Number(t))return BigInt(e);let n=BigInt(e),a=BigInt(Number(t)*BASE_BPS);if(a===BigInt(0))return n;let o=n*a/BigInt(BASE_BPS);return n-o}async function getNeededGasFee(e,t,n,a){let{effects:{gasUsed:o,status:i}}=await e.devInspectTransactionBlock({sender:n,transactionBlock:t});if("success"!==i.status)throw Error(`Transaction failed during dev inspect: ${i.error??""}`);let r=BigInt(o.computationCost)+BigInt(o.storageCost)-BigInt(o.storageRebate),s=BigInt(Number(a)*BASE_BPS);return r*(BigInt(BASE_BPS)+s)/BigInt(BASE_BPS)}!function(e){(e.U64||(e.U64={})).mulDivUp=function(e,t,n){let a=BigInt(0);return e*t%n>BigInt(0)&&(a=BigInt(1)),e*t/n+a}}(package_MathUtils||(package_MathUtils={})),function(e){function t(e){return tiny_invariant_default()(BigInt(e)<=BigInt(1e4),"Bps overflow"),BigInt(e)}e.calcUp=function(e,t){let n,a=BigInt(e.pos0),o=BigInt(1e4);return n=a*t%o!==BigInt(0)?BigInt(1):BigInt(0),a*t/o+n},e.sub=function(e,t){return tiny_invariant_default()(BigInt(e.pos0)>=BigInt(t.pos0),"Bps underflow"),{pos0:(BigInt(e.pos0)-BigInt(t.pos0)).toString()}},e.value=function(e){return BigInt(e.pos0)},e.new_=function(e){return{pos0:t(e).toString()}},e.assertOverflow=t}(package_Bps||(package_Bps={})),function(e){var t,n;(e.MemezFun||(e.MemezFun={})).isSniperProtectedMemezFun=async function(e,t){return(await getMoveObjectContent(e,t)).public_key.length>0},(t=e.MemezFees||(e.MemezFees={})).takeWithDiscount=function(e,t,n){if("Value"===e.variant){let n=BigInt(e.fields.pos0);if(n===BigInt(0))return BigInt(0);if(t>=n)return n;throw Error(`Insufficient amount to cover fee. Required: ${n}, provided: ${t}`)}if("Percentage"===e.variant){let a=e.fields.pos0.fields;if(BigInt(a.pos0)===BigInt(0))return BigInt(0);let o=package_Bps.calcUp(package_Bps.sub(a,n),t);if(t>=o)return o;throw Error(`Insufficient amount to cover fee. Required: ${o}, provided: ${t}`)}throw Error("Unknown fee variant")},t.calculateWithDiscount=function(e,t,n){if("Value"===e.variant)return BigInt(e.fields.pos0);if("Percentage"===e.variant){let a=e.fields.pos0.fields;return package_Bps.calcUp(package_Bps.sub(a,t),n)}throw Error("Unknown fee variant")},(e.MemezBurner||(e.MemezBurner={})).calculate=function(e,t){if(package_Bps.value(e.fee.fields)===BigInt(0)||t===BigInt(0)||t>=BigInt(e.target_liquidity))return package_Bps.new_(0);let n=BigInt(1e4);return package_Bps.new_(package_MathUtils.U64.mulDivUp(package_Bps.value(e.fee.fields),package_MathUtils.U64.mulDivUp(t,n,BigInt(e.target_liquidity)),n))},(n=e.MemezPump||(e.MemezPump={})).getPumpState=async function(e,t){return await getMoveObjectContent(e,t.inner_state)},n.pump=function(t,n){let a=t.constant_product.fields,o=e.MemezFees.takeWithDiscount(a.quote_swap_fee,n,a.quote_referrer_fee.fields),i=n-o,r=BigInt(a.meme_balance),s=BigInt(a.quote_balance),u=r*i/(BigInt(a.virtual_liquidity)+s+i),c=e.MemezFees.takeWithDiscount(a.meme_swap_fee,u,a.meme_referrer_fee.fields);return u-c},n.dump=function(t,n){let a=t.constant_product.fields,o=e.MemezFees.takeWithDiscount(a.meme_swap_fee,n,a.meme_referrer_fee.fields),i=n-o,r=BigInt(a.meme_balance),s=BigInt(a.quote_balance),u=BigInt(a.virtual_liquidity),c=e.MemezBurner.calculate(a.burner.fields,s),_=package_Bps.calcUp(c,i),l=i-(package_Bps.value(c)!==BigInt(0)?_:BigInt(0)),p=(u+s)*l/(r+l);p>s&&(p=s);let g=e.MemezFees.takeWithDiscount(a.quote_swap_fee,p,a.quote_referrer_fee.fields);return p-g}}(package_BlastFunPackage||(package_BlastFunPackage={})),function(e){e.getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:a,frontendFee:o}=e,i=await getMoveObjectContent(t,a),r=await package_BlastFunPackage.MemezPump.getPumpState(t,i);return n=getAmountAfterFee(n,o),package_BlastFunPackage.MemezPump.pump(r,n)},e.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:a,frontendFee:o}=e,i=await getMoveObjectContent(t,a),r=await package_BlastFunPackage.MemezPump.getPumpState(t,i);return getAmountAfterFee(package_BlastFunPackage.MemezPump.dump(r,n),o)}}(custom_calculation_BlastFunCustomCalculation||(custom_calculation_BlastFunCustomCalculation={}));const SUI_TYPE="0x2::sui::SUI",SUI_FULL_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",USDC_TOKEN_TYPE="0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",NATIVE_USDC_TOKEN_TYPE="0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",SUI_METADATA_OBJECT_ID="0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",CLOCK_OBJECT_ID="0x0000000000000000000000000000000000000000000000000000000000000006",utils_namespaceObject=require("@mysten/sui/utils"),orderByKey=(e,t,n)=>{let a;if(e?.length){do{a=!1;for(let o=0;o<e.length-1;o++){let i=BigInt(e[o][t]),r=BigInt(e[o+1][t]);if("desc"===n?i<r:i>r){let t=e[o];e[o]=e[o+1],e[o+1]=t,a=!0}}}while(a);return e}},getCoinObjectIdsByAmount=async(e,t,n,a)=>{let o,i=[],r=!0;for(;r;)try{let n=await e.getCoins({owner:t,coinType:a,cursor:o});i=[...i,...n.data],r=n.hasNextPage,o=n.nextCursor}catch(e){console.error("Error fetching data:",e),r=!1}let s=orderByKey(i.map(e=>({...e,balance:e.balance})),"balance","desc")??[],u="0",c=[],_=[];for(let e of s)if(u=(BigInt(e.balance)+BigInt(u)).toString(10),c.push(e.coinObjectId),_.push(e),BigInt(u)>=BigInt(n))break;return{objectIds:c,balance:u,objectCoins:_}};async function getSplitCoinForTx(e,t){let{account:n,amount:a,splits:o,coinType:i,inheritTx:r,inspecTransaction:s,isSponsored:u=!1}=e,c=r??new transactions_namespaceObject.Transaction,{objectIds:_}=await getCoinObjectIdsByAmount(t,n,a,i),l=_[0];if((0,utils_namespaceObject.normalizeStructTag)(i)===(0,utils_namespaceObject.normalizeStructTag)(SUI_FULL_TYPE)&&!u){let e;return s?(_.length>1&&c.mergeCoins(c.object(l),_.slice(1).map(e=>c.object(e))),e=c.splitCoins(c.object(l),o)):e=c.splitCoins(c.gas,o),{tx:c,coinData:e}}_.length>1&&c.mergeCoins(c.object(l),_.slice(1).map(e=>c.object(e)));let p=c.splitCoins(c.object(l),o);return{tx:c,coinData:p}}const BLUEFIN_PACKAGE_ID="0x62412b7268c35f3808336aee57a52836501f40b8ba5d936f8ad275e672befd04";async function splitSuiCoinAfterFeeFromBuyTx(e,t){let n,a,{inputAmount:o,accountAddress:i,frontendFee:r,frontendFeeRecipient:s,extendTx:u,isSponsored:c}=e;tiny_invariant_default()(e.inCoinType===SUI_FULL_TYPE||e.inCoinType===SUI_TYPE,"Input must be SUI");let{tx:_,coinIn:l}=u||{},p=getSplitCoinsAfterFee(o,r||"0"),g=_||new transactions_namespaceObject.Transaction;if(l)n=g.splitCoins(l,p),bluefin_BluefinTx.transferOrDestroyZeroCoin(g,SUI_FULL_TYPE,l,i);else{let{coinData:e}=await getSplitCoinForTx({account:i,amount:o,splits:p,coinType:SUI_FULL_TYPE,inheritTx:g,isSponsored:c||!1},t);n=e}if(r&&s){let[e,t]=n;a=e,g.transferObjects([t],g.pure.address(s||i))}else[a]=n;return{tx:g,coinOut:a}}async function splitSuiCoinAfterFeeFromSellTx(e,t,n){if(tiny_invariant_default()(t.outCoinType===SUI_FULL_TYPE||t.outCoinType===SUI_TYPE,"Output must be SUI"),0>=Number(t.frontendFee||0))return{tx:e,coinOut:n};let a=e.moveCall({target:"0x2::coin::value",typeArguments:[t.outCoinType],arguments:[n]}),o=e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::math::mul_div_u64`,typeArguments:[],arguments:[a,e.pure.u64(BigInt(Number(t.frontendFee||"0")*BASE_BPS)),e.pure.u64(BigInt(BASE_BPS))]}),i=e.moveCall({target:"0x2::coin::split",typeArguments:[t.outCoinType],arguments:[n,o]});return e.transferObjects([i],e.pure.address(t.frontendFeeRecipient||t.accountAddress)),{tx:e,coinOut:n}}(bluefin_BluefinTx||(bluefin_BluefinTx={})).transferOrDestroyZeroCoin=function(e,t,n,a){e.moveCall({target:`${BLUEFIN_PACKAGE_ID}::utils::transfer_or_destroy`,typeArguments:[t],arguments:[n,e.pure.address(a)]})},function(e){async function t(e){let t=e||new transactions_namespaceObject.Transaction;return t.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_allowed_versions::get_allowed_versions`,arguments:[t.object(constants_BlastFunConstants.MEMEZ_AV_OBJECT_ID)],typeArguments:[]})}e.getAllowedVersions=t,e.buildBuyTx=async function(e,n){tiny_invariant_default()(!await package_BlastFunPackage.MemezFun.isSniperProtectedMemezFun(n,e.poolId),"This coin is a sniper protected coin, please use the Blast Fun website to trade it.");let{tx:a,coinOut:o}=await splitSuiCoinAfterFeeFromBuyTx(e,n);tiny_invariant_default()(o,"Coin out is required");let i=a.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::pump`,typeArguments:[e.outCoinType,SUI_FULL_TYPE],arguments:[a.object(e.poolId),o,a.pure.vector("address",[]),a.pure.vector("vector<u8>",[]),a.pure.u64(e.minAmountOut),await t(a)]});return{tx:a,coinOut:i}},e.buildSellTx=async function(e,n){tiny_invariant_default()(e.outCoinType===SUI_FULL_TYPE||e.outCoinType===SUI_TYPE,"Output must be SUI");let a=await getMoveObjectContent(n,e.poolId),{tx:o,coinData:i}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},n),[r]=i,[s]=o.moveCall({target:`${constants_BlastFunConstants.PACKAGE_ID_V4}::memez_pump::dump`,typeArguments:[e.inCoinType,e.outCoinType],arguments:[o.object(e.poolId),o.object(a.ipx_meme_coin_treasury),r,o.pure.vector("address",[]),o.pure.u64(e.minAmountOut),await t(o)]});return await splitSuiCoinAfterFeeFromSellTx(o,e,s)}}(custom_transaction_BlastFunCustomTransaction||(custom_transaction_BlastFunCustomTransaction={}));const memez_fun_sdk_namespaceObject=require("@interest-protocol/memez-fun-sdk"),sui_core_sdk_namespaceObject=require("@interest-protocol/sui-core-sdk"),client_namespaceObject=require("@mysten/sui/client"),payload={network:sui_core_sdk_namespaceObject.Network.MAINNET,fullNodeUrl:(0,client_namespaceObject.getFullnodeUrl)("mainnet")},memezPump=new memez_fun_sdk_namespaceObject.MemezPumpSDK(payload);function getMemezPumpSDK(){return memezPump}async function addGasFee(e,t){let{inheritTx:n,sender:a,feeAmount:o,suiInputAmount:i}=e,r=n||new transactions_namespaceObject.Transaction;r.setGasBudget(o);let{objectCoins:s}=await getCoinObjectIdsByAmount(t,a,(BigInt(i||"0")+o).toString(),SUI_FULL_TYPE);return r.setGasPayment(s.map(e=>({objectId:e.coinObjectId,version:e.version,digest:e.digest}))),r}!function(e){e.getCurveAmountAfterBuy=async function(e){let{suiAmount:t,poolId:n,frontendFee:a}=e;t=getAmountAfterFee(t,a);let{memeAmountOut:o}=await getMemezPumpSDK().quotePump({pool:n,amount:t});return o},e.getSuiAmountAfterSell=async function(e){let{curveAmount:t,poolId:n,frontendFee:a}=e,{quoteAmountOut:o}=await getMemezPumpSDK().quoteDump({pool:n,amount:t});return getAmountAfterFee(o,a)}}(sdk_calculation_BlastFunSDKCalculation||(sdk_calculation_BlastFunSDKCalculation={})),function(e){async function t(e,t){let{tx:n,coinOut:a}=await splitSuiCoinAfterFeeFromBuyTx(e,t);tiny_invariant_default()(a,"Coin out is required");let{memeCoin:o,tx:i}=await getMemezPumpSDK().pump({pool:e.poolId,quoteCoin:a,minAmountOut:e.minAmountOut,tx:n});return{tx:i,coinOut:o}}async function n(e,t){tiny_invariant_default()(e.outCoinType===SUI_FULL_TYPE||e.outCoinType===SUI_TYPE,"Output must be SUI");let{tx:n,coinData:a}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[o]=a,{quoteCoin:i,tx:r}=await getMemezPumpSDK().dump({pool:e.poolId,memeCoin:o,tx:n,minAmountOut:e.minAmountOut});return await splitSuiCoinAfterFeeFromSellTx(r,e,i)}e.buildBuyTx=t,e.buildSellTx=n,e.getBuyTransaction=async function({coinInAmount:e,coinInType:n,coinOutType:a,poolId:o,slippage:i,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(n===SUI_TYPE,"coinInType must be SUI for buy transaction"),tiny_invariant_default()(a!==n,"coinOutType must be different from coinInType"),tiny_invariant_default()(i>=0&&i<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await sdk_calculation_BlastFunSDKCalculation.getCurveAmountAfterBuy({poolId:o,suiAmount:e,frontendFee:s?s.tradeFeePercent:void 0}),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-i).toFixed(0,3)),{tx:l,coinOut:p}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:o,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(p,"Coin out is required"),l.transferObjects([p],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g,suiInputAmount:e},u)).build({client:u})},e.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:a,poolId:o,slippage:i,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(a===SUI_TYPE,"coinOutType must be SUI for sell transaction"),tiny_invariant_default()(a!==t,"coinOutType must be different from coinInType"),tiny_invariant_default()(i>=0&&i<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await sdk_calculation_BlastFunSDKCalculation.getSuiAmountAfterSell({poolId:o,curveAmount:e,frontendFee:s?s.tradeFeePercent:void 0}),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-i).toFixed(0,3)),{tx:l,coinOut:p}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:o,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(p,"Coin out is required"),l.transferObjects([p],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g},u)).build({client:u})}}(sdk_transaction_BlastFunSDKTransaction||(sdk_transaction_BlastFunSDKTransaction={}));var types_SupportedBondingCurve=function(e){return e.BLAST_FUN="BLAST_FUN",e.MOONBAGS="MOONBAGS",e}({});function adaptSuiClient(e){return e}function adaptTransaction(e){return e}function createCompatibleSuiClient(e){return new Proxy(e,{get(e,t){let n=e[t];return"function"==typeof n?n.bind(e):n}})}!function(e){e.PACKAGE_ID="0xb8df325010942634a4afb3db3901ee215546af43a4ec4af781e7213b0bba7290",e.CONFIG_OBJECT_ID="0x74aecf86067c6913960ba4925333aefd2b1f929cafca7e21fd55a8f244b70499",e.LOCK_CONFIG_OBJECT_ID="0xfb09822d9808980abd04c51321adb850701f5f55535c6206658ef4d910c3e9be",e.BURN_MANAGER_OBJECT_ID="0x1d94aa32518d0cb00f9de6ed60d450c9a2090761f326752ffad06b2e9404f845",e.POOLS_OBJECT_ID="0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",e.GLOBAL_CONFIG_OBJECT_ID="0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",e.FEE_DENOMINATOR=BigInt(1e4)}(constants_MoonbagsConstants||(constants_MoonbagsConstants={})),function(e){var t,n;(t=e.Curves||(e.Curves={})).calculateAddLiquidityCost=function(e,t,n){return e*t/(t-n)-e},t.calculateRemoveLiquidityReturn=function(e,t,n){return t-e*t/(e+n)},t.calculateTokenAmountReceived=function(e,t,n){return t-e*t/(e+n)},(n=e.Moonbags||(e.Moonbags={})).getDynamicVirtualTokenReserves=async function(e,t){let n=await e.getDynamicFieldObject({parentId:t,name:{type:"vector<u8>",value:"virtual_token_reserves"}});if(n.data)return BigInt(n.data.content.fields.value)},n.buyExactInReturnsWithLock=function(t){let{inputAmount:n,amountIn:a,pool:o,config:i,dynamicVirtualTokenReserves:r}=t,s=BigInt(o.virtual_sui_reserves),u=BigInt(o.virtual_token_reserves),c=BigInt(o.remain_token_reserves.fields.balance),_=e.Curves.calculateRemoveLiquidityReturn(s,u,a),l=u-(r||c),p=_,g=a;_>l&&(p=l,g=e.Curves.calculateAddLiquidityCost(s,u,l)+BigInt(1));let d=g*BigInt(i.platform_fee)/constants_MoonbagsConstants.FEE_DENOMINATOR;return tiny_invariant_default()(n>=g+d,"Input amount is less than used SUI + fee"),{receivedCurve:p,receivedSui:n-g-d}},n.sellReturns=function(t){let{amountIn:n,pool:a,config:o}=t,i=BigInt(a.virtual_sui_reserves),r=BigInt(a.virtual_token_reserves),s=BigInt(a.real_sui_reserves.fields.balance),u=e.Curves.calculateRemoveLiquidityReturn(r,i,n);u>s&&(u=s);let c=u*BigInt(o.platform_fee)/constants_MoonbagsConstants.FEE_DENOMINATOR,_=u-c;return{receivedCurve:BigInt(0),receivedSui:_}}}(package_MoonbagsPackage||(package_MoonbagsPackage={})),function(e){e.getCurveAmountAfterBuy=async function(e,t){let{suiAmount:n,poolId:a,frontendFee:o}=e,[i,r,s]=await Promise.all([getMoveObjectContent(t,a),getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID),package_MoonbagsPackage.Moonbags.getDynamicVirtualTokenReserves(t,a)]);void 0!==o&&(n=getAmountAfterFee(n,o));let u=n*constants_MoonbagsConstants.FEE_DENOMINATOR/(constants_MoonbagsConstants.FEE_DENOMINATOR+BigInt(r.platform_fee)),{receivedCurve:c}=package_MoonbagsPackage.Moonbags.buyExactInReturnsWithLock({inputAmount:n,amountIn:u,pool:i,config:r,dynamicVirtualTokenReserves:s});return c},e.getSuiAmountAfterSell=async function(e,t){let{curveAmount:n,poolId:a,frontendFee:o}=e,[i,r]=await Promise.all([getMoveObjectContent(t,a),getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID)]),{receivedSui:s}=package_MoonbagsPackage.Moonbags.sellReturns({amountIn:n,pool:i,config:r});return void 0!==o?getAmountAfterFee(s,o):s},e.getUsedSuiForTx=async function(e,t){let{suiAmount:n,frontendFee:a}=e,o=await getMoveObjectContent(t,constants_MoonbagsConstants.CONFIG_OBJECT_ID);return void 0!==a&&(n=getAmountAfterFee(n,a)),n*constants_MoonbagsConstants.FEE_DENOMINATOR/(constants_MoonbagsConstants.FEE_DENOMINATOR+BigInt(o.platform_fee))}}(calculation_MoonbagsCalculation||(calculation_MoonbagsCalculation={})),function(e){async function t(e,t){let{tx:n,coinOut:a}=await splitSuiCoinAfterFeeFromBuyTx(e,t);tiny_invariant_default()(a,"Coin out is required");let o=await calculation_MoonbagsCalculation.getUsedSuiForTx({suiAmount:BigInt(e.inputAmount),frontendFee:e.frontendFee},t),[i,r]=n.moveCall({target:`${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::buy_exact_in_returns_with_lock`,typeArguments:[e.outCoinType],arguments:[n.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),n.object(constants_MoonbagsConstants.LOCK_CONFIG_OBJECT_ID),a,n.pure.u64(o),n.pure.u64(e.minAmountOut),n.object(constants_MoonbagsConstants.BURN_MANAGER_OBJECT_ID),n.object(constants_MoonbagsConstants.POOLS_OBJECT_ID),n.object(constants_MoonbagsConstants.GLOBAL_CONFIG_OBJECT_ID),n.object(SUI_METADATA_OBJECT_ID),n.object(CLOCK_OBJECT_ID)]});return bluefin_BluefinTx.transferOrDestroyZeroCoin(n,SUI_FULL_TYPE,i,e.accountAddress),{tx:n,coinOut:r}}async function n(e,t){tiny_invariant_default()(e.outCoinType===SUI_FULL_TYPE||e.outCoinType===SUI_TYPE,"Output must be SUI");let{tx:n,coinData:a}=await getSplitCoinForTx({amount:e.inputAmount,coinType:e.inCoinType,inheritTx:e.extendTx?.tx,account:e.accountAddress,splits:[e.inputAmount]},t),[o]=a,[i,r]=n.moveCall({target:`${constants_MoonbagsConstants.PACKAGE_ID}::moonbags::sell_returns`,typeArguments:[e.inCoinType],arguments:[n.object(constants_MoonbagsConstants.CONFIG_OBJECT_ID),o,n.pure.u64(e.minAmountOut),n.object(CLOCK_OBJECT_ID)]});return bluefin_BluefinTx.transferOrDestroyZeroCoin(n,e.inCoinType,r,e.accountAddress),await splitSuiCoinAfterFeeFromSellTx(n,e,i)}e.buildBuyTx=t,e.buildSellTx=n,e.getBuyTransaction=async function({coinInAmount:e,coinInType:n,coinOutType:a,poolId:o,slippage:i,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(n===SUI_TYPE,"coinInType must be SUI for buy transaction"),tiny_invariant_default()(a!==n,"coinOutType must be different from coinInType"),tiny_invariant_default()(i>=0&&i<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await calculation_MoonbagsCalculation.getCurveAmountAfterBuy({poolId:o,suiAmount:e,frontendFee:s?s.tradeFeePercent:void 0},u),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-i).toFixed(0,3)),{tx:l,coinOut:p}=await t({accountAddress:r,inCoinType:n,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:o,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(p,"Coin out is required"),l.transferObjects([p],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g,suiInputAmount:e},u)).build({client:u})},e.getSellTransaction=async function({coinInAmount:e,coinInType:t,coinOutType:a,poolId:o,slippage:i,walletAddress:r,tradeFee:s},u){tiny_invariant_default()(a===SUI_TYPE,"coinOutType must be SUI for sell transaction"),tiny_invariant_default()(a!==t,"coinOutType must be different from coinInType"),tiny_invariant_default()(i>=0&&i<1,"slippage must be between 0 (inclusive) and 1 (exclusive)"),tiny_invariant_default()(e>0,"coinInAmount must be greater than 0");let c=await calculation_MoonbagsCalculation.getSuiAmountAfterSell({poolId:o,curveAmount:e,frontendFee:s?s.tradeFeePercent:void 0},u),_=BigInt(new(external_bignumber_js_default())(c.toString()).multipliedBy(1-i).toFixed(0,3)),{tx:l,coinOut:p}=await n({accountAddress:r,inCoinType:t,outCoinType:a,inputAmount:e.toString(),minAmountOut:_.toString(),poolId:o,frontendFee:s?s.tradeFeePercent:void 0,frontendFeeRecipient:s?s.tradeFeeRecipientAddress:void 0,extendTx:void 0,isSponsored:!1},u);tiny_invariant_default()(p,"Coin out is required"),l.transferObjects([p],l.pure.address(r)),l.setSender(r);let g=await getNeededGasFee(u,l,r,0);return(l=await addGasFee({inheritTx:l,sender:r,feeAmount:g},u)).build({client:u})}}(transaction_MoonbagsTransaction||(transaction_MoonbagsTransaction={}));const ed25519_namespaceObject=require("@mysten/sui/keypairs/ed25519"),CONSTANTS={GAS_FEE_BUFFER_PERCENTAGE:.1};class DraftTransferTx{suiClient;constructor(e){this.suiClient=e}validatePrivateKey(e,t){tiny_invariant_default()(e?.trim(),"Private key is required");let n=ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(e),a=n.getPublicKey().toSuiAddress();if(a!==t)throw Error(`Private key mismatch. Expected: ${t}, Got: ${a}`);return n}async createDraft(e,t,n){tiny_invariant_default()(e?.trim(),"Sender address is required"),tiny_invariant_default()(t?.trim(),"Recipient address is required"),tiny_invariant_default()(e!==t,"Sender and recipient cannot be the same"),tiny_invariant_default()(n>0n,"Transfer amount must be at least 1 MIST");try{let a=new transactions_namespaceObject.Transaction,[o]=a.splitCoins(a.gas,[n]);a.transferObjects([o],t),a.setSender(e);let i=await this.suiClient.getReferenceGasPrice();a.setGasPrice(i);let r=await getNeededGasFee(this.suiClient,a,e,CONSTANTS.GAS_FEE_BUFFER_PERCENTAGE);a=await addGasFee({inheritTx:a,sender:e,feeAmount:r,suiInputAmount:n},this.suiClient);let s=await a.build({client:this.suiClient}),u=Buffer.from(s).toString("base64"),c=await a.getDigest();return{sender:e,recipient:t,amountMIST:n,txDraftBase64:u,txDigest:c}}catch(e){throw Error(`Failed to create draft transaction: ${e instanceof Error?e.message:"Unknown error"}`)}}async execute(e,t){try{tiny_invariant_default()(e,"Draft transaction is required"),tiny_invariant_default()(e.txDraftBase64?.trim(),"Transaction data is required");let n=this.validatePrivateKey(t,e.sender),a=(0,utils_namespaceObject.fromBase64)(e.txDraftBase64),{signature:o}=await n.signTransaction(a),i=await this.suiClient.executeTransactionBlock({transactionBlock:a,signature:o});return{success:!0,txDigest:i.digest,effects:i.effects}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}}async getTransactionStatus(e){tiny_invariant_default()(e?.trim(),"Transaction digest is required");try{let t=await this.suiClient.getTransactionBlock({digest:e,options:{showEffects:!0}});if(!t?.effects?.status)return"pending";return"success"===t.effects.status.status?"success":"failure"}catch(e){if(e instanceof Error&&(e.message.includes("not found")||e.message.includes("Could not find")))return"pending";return"failure"}}}for(var __webpack_i__ in exports.AftermathAggregator=__webpack_exports__.AftermathAggregator,exports.AstrosAggregator=__webpack_exports__.AstrosAggregator,exports.BASE_BPS=__webpack_exports__.BASE_BPS,exports.BLUEFIN_PACKAGE_ID=__webpack_exports__.BLUEFIN_PACKAGE_ID,exports.BlastFunConstants=__webpack_exports__.BlastFunConstants,exports.BlastFunCustomCalculation=__webpack_exports__.BlastFunCustomCalculation,exports.BlastFunCustomTransaction=__webpack_exports__.BlastFunCustomTransaction,exports.BlastFunPackage=__webpack_exports__.BlastFunPackage,exports.BlastFunSDKCalculation=__webpack_exports__.BlastFunSDKCalculation,exports.BlastFunSDKTransaction=__webpack_exports__.BlastFunSDKTransaction,exports.BluefinTx=__webpack_exports__.BluefinTx,exports.Bps=__webpack_exports__.Bps,exports.CLOCK_OBJECT_ID=__webpack_exports__.CLOCK_OBJECT_ID,exports.CetusAggregator=__webpack_exports__.CetusAggregator,exports.DraftTransferTx=__webpack_exports__.DraftTransferTx,exports.FlowXAggregator=__webpack_exports__.FlowXAggregator,exports.MathUtils=__webpack_exports__.MathUtils,exports.MoonbagsCalculation=__webpack_exports__.MoonbagsCalculation,exports.MoonbagsConstants=__webpack_exports__.MoonbagsConstants,exports.MoonbagsPackage=__webpack_exports__.MoonbagsPackage,exports.MoonbagsTransaction=__webpack_exports__.MoonbagsTransaction,exports.NATIVE_USDC_TOKEN_TYPE=__webpack_exports__.NATIVE_USDC_TOKEN_TYPE,exports.SUI_FULL_TYPE=__webpack_exports__.SUI_FULL_TYPE,exports.SUI_METADATA_OBJECT_ID=__webpack_exports__.SUI_METADATA_OBJECT_ID,exports.SUI_TYPE=__webpack_exports__.SUI_TYPE,exports.SevenKAggregator=__webpack_exports__.SevenKAggregator,exports.SupportedAggregator=__webpack_exports__.SupportedAggregator,exports.SupportedBondingCurve=__webpack_exports__.SupportedBondingCurve,exports.TradeFeeOptions=__webpack_exports__.TradeFeeOptions,exports.USDC_TOKEN_TYPE=__webpack_exports__.USDC_TOKEN_TYPE,exports.adaptSuiClient=__webpack_exports__.adaptSuiClient,exports.adaptTransaction=__webpack_exports__.adaptTransaction,exports.addGasFee=__webpack_exports__.addGasFee,exports.createCompatibleSuiClient=__webpack_exports__.createCompatibleSuiClient,exports.getAmountAfterFee=__webpack_exports__.getAmountAfterFee,exports.getCoinObjectIdsByAmount=__webpack_exports__.getCoinObjectIdsByAmount,exports.getMemezPumpSDK=__webpack_exports__.getMemezPumpSDK,exports.getMoveObject=__webpack_exports__.getMoveObject,exports.getMoveObjectContent=__webpack_exports__.getMoveObjectContent,exports.getNeededGasFee=__webpack_exports__.getNeededGasFee,exports.getSplitCoinForTx=__webpack_exports__.getSplitCoinForTx,exports.getSplitCoinsAfterFee=__webpack_exports__.getSplitCoinsAfterFee,exports.splitSuiCoinAfterFeeFromBuyTx=__webpack_exports__.splitSuiCoinAfterFeeFromBuyTx,exports.splitSuiCoinAfterFeeFromSellTx=__webpack_exports__.splitSuiCoinAfterFeeFromSellTx,__webpack_exports__)-1===["AftermathAggregator","AstrosAggregator","BASE_BPS","BLUEFIN_PACKAGE_ID","BlastFunConstants","BlastFunCustomCalculation","BlastFunCustomTransaction","BlastFunPackage","BlastFunSDKCalculation","BlastFunSDKTransaction","BluefinTx","Bps","CLOCK_OBJECT_ID","CetusAggregator","DraftTransferTx","FlowXAggregator","MathUtils","MoonbagsCalculation","MoonbagsConstants","MoonbagsPackage","MoonbagsTransaction","NATIVE_USDC_TOKEN_TYPE","SUI_FULL_TYPE","SUI_METADATA_OBJECT_ID","SUI_TYPE","SevenKAggregator","SupportedAggregator","SupportedBondingCurve","TradeFeeOptions","USDC_TOKEN_TYPE","adaptSuiClient","adaptTransaction","addGasFee","createCompatibleSuiClient","getAmountAfterFee","getCoinObjectIdsByAmount","getMemezPumpSDK","getMoveObject","getMoveObjectContent","getNeededGasFee","getSplitCoinForTx","getSplitCoinsAfterFee","splitSuiCoinAfterFeeFromBuyTx","splitSuiCoinAfterFeeFromSellTx"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|