@cetusprotocol/aggregator-sdk 0.3.28 → 0.3.30
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.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +157 -23
- package/dist/index.mjs +156 -23
- package/dist/src/api.d.ts +7 -0
- package/dist/src/client.d.ts +1 -0
- package/dist/src/transaction/metastable.d.ts +8 -0
- package/dist/tests/router/metastable.test.d.ts +2 -0
- package/package.json +1 -1
- package/src/api.ts +8 -2
- package/src/client.ts +44 -18
- package/src/transaction/metastable.ts +141 -0
- package/tests/router/metastable.test.ts +377 -0
- package/tests/router.test.ts +2 -4
package/dist/index.d.mts
CHANGED
|
@@ -80,6 +80,7 @@ declare const HAEDALPMM = "HAEDALPMM";
|
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
81
|
declare const SPRINGSUI = "SPRINGSUI";
|
|
82
82
|
declare const STEAMM = "STEAMM";
|
|
83
|
+
declare const METASTABLE = "METASTABLE";
|
|
83
84
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
84
85
|
type BuildRouterSwapParams = {
|
|
85
86
|
routers: Router[];
|
|
@@ -243,6 +244,13 @@ type ExtendedDetails = {
|
|
|
243
244
|
steammBCoinAType?: string;
|
|
244
245
|
steammBCoinBType?: string;
|
|
245
246
|
steammLPToken?: string;
|
|
247
|
+
metastablePriceSeed?: string;
|
|
248
|
+
metastableETHPriceSeed?: string;
|
|
249
|
+
metastableWhitelistedAppId?: string;
|
|
250
|
+
metastableCreateCapPkgId?: string;
|
|
251
|
+
metastableCreateCapModule?: string;
|
|
252
|
+
metastableCreateCapAllTypeParams?: boolean;
|
|
253
|
+
metastableRegistryId?: string;
|
|
246
254
|
};
|
|
247
255
|
type Path = {
|
|
248
256
|
id: string;
|
|
@@ -306,4 +314,4 @@ declare enum Env {
|
|
|
306
314
|
Testnet = 1
|
|
307
315
|
}
|
|
308
316
|
|
|
309
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
317
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, METASTABLE, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ declare const HAEDALPMM = "HAEDALPMM";
|
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
81
|
declare const SPRINGSUI = "SPRINGSUI";
|
|
82
82
|
declare const STEAMM = "STEAMM";
|
|
83
|
+
declare const METASTABLE = "METASTABLE";
|
|
83
84
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
84
85
|
type BuildRouterSwapParams = {
|
|
85
86
|
routers: Router[];
|
|
@@ -243,6 +244,13 @@ type ExtendedDetails = {
|
|
|
243
244
|
steammBCoinAType?: string;
|
|
244
245
|
steammBCoinBType?: string;
|
|
245
246
|
steammLPToken?: string;
|
|
247
|
+
metastablePriceSeed?: string;
|
|
248
|
+
metastableETHPriceSeed?: string;
|
|
249
|
+
metastableWhitelistedAppId?: string;
|
|
250
|
+
metastableCreateCapPkgId?: string;
|
|
251
|
+
metastableCreateCapModule?: string;
|
|
252
|
+
metastableCreateCapAllTypeParams?: boolean;
|
|
253
|
+
metastableRegistryId?: string;
|
|
246
254
|
};
|
|
247
255
|
type Path = {
|
|
248
256
|
id: string;
|
|
@@ -306,4 +314,4 @@ declare enum Env {
|
|
|
306
314
|
Testnet = 1
|
|
307
315
|
}
|
|
308
316
|
|
|
309
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
|
317
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, METASTABLE, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, SUILEND, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.js
CHANGED
|
@@ -6309,6 +6309,117 @@ var Steamm = class {
|
|
|
6309
6309
|
}
|
|
6310
6310
|
};
|
|
6311
6311
|
|
|
6312
|
+
// src/transaction/metastable.ts
|
|
6313
|
+
var SUPER_SUI_TYPE = "0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI";
|
|
6314
|
+
var MUSD_TYPE = "0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD";
|
|
6315
|
+
var METH_TYPE = "0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH";
|
|
6316
|
+
var Metastable = class {
|
|
6317
|
+
constructor(env, pythPriceIDs) {
|
|
6318
|
+
if (env !== 0 /* Mainnet */) {
|
|
6319
|
+
throw new Error("Metastable only supported on mainnet");
|
|
6320
|
+
}
|
|
6321
|
+
this.versionID = "0x4696559327b35ff2ab26904e7426a1646312e9c836d5c6cff6709a5ccc30915c";
|
|
6322
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6323
|
+
}
|
|
6324
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6325
|
+
return __async(this, null, function* () {
|
|
6326
|
+
const { direction, from, target } = path;
|
|
6327
|
+
const [func, createCapFunc, coinType, metaCoinType] = direction ? ["swap_a2b", "create_deposit_cap", from, target] : ["swap_b2a", "create_withdraw_cap", target, from];
|
|
6328
|
+
let createExchangePkgId = "";
|
|
6329
|
+
let createDepositModule = "pyth";
|
|
6330
|
+
let metaSingletonId = "";
|
|
6331
|
+
if (path.extendedDetails == null) {
|
|
6332
|
+
throw new Error("Extended details not supported metastable");
|
|
6333
|
+
} else {
|
|
6334
|
+
if (!path.extendedDetails.metastableCreateCapPkgId || !path.extendedDetails.metastableCreateCapModule || !path.extendedDetails.metastableRegistryId || !path.extendedDetails.metastableWhitelistedAppId) {
|
|
6335
|
+
throw new Error("CreateCapPkgId or CreateCapModule or RegistryId or WhitelistedAppId or CreateCapAllTypeParams not supported");
|
|
6336
|
+
}
|
|
6337
|
+
createExchangePkgId = path.extendedDetails.metastableCreateCapPkgId;
|
|
6338
|
+
createDepositModule = path.extendedDetails.metastableCreateCapModule;
|
|
6339
|
+
metaSingletonId = path.extendedDetails.metastableWhitelistedAppId;
|
|
6340
|
+
}
|
|
6341
|
+
const createDepositCapTypeArgs = [
|
|
6342
|
+
metaCoinType
|
|
6343
|
+
];
|
|
6344
|
+
if (path.extendedDetails.metastableCreateCapAllTypeParams) {
|
|
6345
|
+
createDepositCapTypeArgs.push(coinType);
|
|
6346
|
+
}
|
|
6347
|
+
const depositArgs = [
|
|
6348
|
+
txb.object(metaSingletonId),
|
|
6349
|
+
txb.object(path.id)
|
|
6350
|
+
];
|
|
6351
|
+
switch (metaCoinType) {
|
|
6352
|
+
case SUPER_SUI_TYPE: {
|
|
6353
|
+
if (!path.extendedDetails.metastableRegistryId) {
|
|
6354
|
+
throw new Error("Not found registry id for super sui");
|
|
6355
|
+
}
|
|
6356
|
+
depositArgs.push(txb.object(path.extendedDetails.metastableRegistryId));
|
|
6357
|
+
break;
|
|
6358
|
+
}
|
|
6359
|
+
case MUSD_TYPE: {
|
|
6360
|
+
if (path.extendedDetails.metastablePriceSeed != null) {
|
|
6361
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastablePriceSeed);
|
|
6362
|
+
if (priceId == null) {
|
|
6363
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastablePriceSeed);
|
|
6364
|
+
}
|
|
6365
|
+
depositArgs.push(txb.object(priceId));
|
|
6366
|
+
}
|
|
6367
|
+
if (path.extendedDetails.metastableETHPriceSeed != null) {
|
|
6368
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastableETHPriceSeed);
|
|
6369
|
+
if (priceId == null) {
|
|
6370
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastableETHPriceSeed);
|
|
6371
|
+
}
|
|
6372
|
+
depositArgs.push(txb.object(priceId));
|
|
6373
|
+
}
|
|
6374
|
+
depositArgs.push(txb.object(CLOCK_ADDRESS));
|
|
6375
|
+
break;
|
|
6376
|
+
}
|
|
6377
|
+
case METH_TYPE: {
|
|
6378
|
+
if (path.extendedDetails.metastablePriceSeed != null) {
|
|
6379
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastablePriceSeed);
|
|
6380
|
+
if (priceId == null) {
|
|
6381
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastablePriceSeed);
|
|
6382
|
+
}
|
|
6383
|
+
depositArgs.push(txb.object(priceId));
|
|
6384
|
+
}
|
|
6385
|
+
if (path.extendedDetails.metastableETHPriceSeed != null) {
|
|
6386
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastableETHPriceSeed);
|
|
6387
|
+
if (priceId == null) {
|
|
6388
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastableETHPriceSeed);
|
|
6389
|
+
}
|
|
6390
|
+
depositArgs.push(txb.object(priceId));
|
|
6391
|
+
}
|
|
6392
|
+
depositArgs.push(txb.object(CLOCK_ADDRESS));
|
|
6393
|
+
break;
|
|
6394
|
+
}
|
|
6395
|
+
default:
|
|
6396
|
+
throw new Error("Invalid Metacoin: " + metaCoinType);
|
|
6397
|
+
}
|
|
6398
|
+
const depositResult = txb.moveCall({
|
|
6399
|
+
target: `${createExchangePkgId}::${createDepositModule}::${createCapFunc}`,
|
|
6400
|
+
typeArguments: createDepositCapTypeArgs,
|
|
6401
|
+
arguments: depositArgs
|
|
6402
|
+
});
|
|
6403
|
+
const swapArgs = [
|
|
6404
|
+
txb.object(path.id),
|
|
6405
|
+
txb.object(this.versionID),
|
|
6406
|
+
depositResult,
|
|
6407
|
+
inputCoin
|
|
6408
|
+
];
|
|
6409
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6410
|
+
const res = txb.moveCall({
|
|
6411
|
+
target: `${publishedAt}::metastable::${func}`,
|
|
6412
|
+
typeArguments: [
|
|
6413
|
+
coinType,
|
|
6414
|
+
metaCoinType
|
|
6415
|
+
],
|
|
6416
|
+
arguments: swapArgs
|
|
6417
|
+
});
|
|
6418
|
+
return res;
|
|
6419
|
+
});
|
|
6420
|
+
}
|
|
6421
|
+
};
|
|
6422
|
+
|
|
6312
6423
|
// src/client.ts
|
|
6313
6424
|
var CETUS = "CETUS";
|
|
6314
6425
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6330,6 +6441,7 @@ var HAEDALPMM = "HAEDALPMM";
|
|
|
6330
6441
|
var ALPHAFI = "ALPHAFI";
|
|
6331
6442
|
var SPRINGSUI = "SPRINGSUI";
|
|
6332
6443
|
var STEAMM = "STEAMM";
|
|
6444
|
+
var METASTABLE = "METASTABLE";
|
|
6333
6445
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6334
6446
|
function isBuilderRouterSwapParams(params) {
|
|
6335
6447
|
return Array.isArray(params.routers);
|
|
@@ -6367,23 +6479,28 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6367
6479
|
}
|
|
6368
6480
|
const allCoins = [];
|
|
6369
6481
|
while (true) {
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
for (const coin of gotCoins.data) {
|
|
6377
|
-
allCoins.push({
|
|
6378
|
-
coinAddress: extractStructTagFromType(coin.coinType).source_address,
|
|
6379
|
-
coinObjectId: coin.coinObjectId,
|
|
6380
|
-
balance: BigInt(coin.balance)
|
|
6482
|
+
try {
|
|
6483
|
+
const gotCoins = yield this.client.getCoins({
|
|
6484
|
+
owner: this.signer,
|
|
6485
|
+
coinType,
|
|
6486
|
+
cursor,
|
|
6487
|
+
limit
|
|
6381
6488
|
});
|
|
6382
|
-
|
|
6383
|
-
|
|
6489
|
+
for (const coin of gotCoins.data) {
|
|
6490
|
+
allCoins.push({
|
|
6491
|
+
coinAddress: extractStructTagFromType(coin.coinType).source_address,
|
|
6492
|
+
coinObjectId: coin.coinObjectId,
|
|
6493
|
+
balance: BigInt(coin.balance)
|
|
6494
|
+
});
|
|
6495
|
+
}
|
|
6496
|
+
if (gotCoins.data.length < limit) {
|
|
6497
|
+
break;
|
|
6498
|
+
}
|
|
6499
|
+
cursor = gotCoins.data[limit - 1].coinObjectId;
|
|
6500
|
+
} catch (e) {
|
|
6501
|
+
console.error("getCoins error:", e);
|
|
6384
6502
|
break;
|
|
6385
6503
|
}
|
|
6386
|
-
cursor = gotCoins.data[limit - 1].coinObjectId;
|
|
6387
6504
|
}
|
|
6388
6505
|
this.allCoins.set(coinType, allCoins);
|
|
6389
6506
|
return allCoins;
|
|
@@ -6667,7 +6784,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6667
6784
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6668
6785
|
publishedAtV2() {
|
|
6669
6786
|
if (this.env === 0 /* Mainnet */) {
|
|
6670
|
-
return "
|
|
6787
|
+
return "0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032";
|
|
6671
6788
|
} else {
|
|
6672
6789
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6673
6790
|
}
|
|
@@ -6754,6 +6871,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6754
6871
|
return new Alphafi(this.env);
|
|
6755
6872
|
case STEAMM:
|
|
6756
6873
|
return new Steamm(this.env);
|
|
6874
|
+
case METASTABLE:
|
|
6875
|
+
return new Metastable(this.env, pythPriceIDs);
|
|
6757
6876
|
default:
|
|
6758
6877
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6759
6878
|
}
|
|
@@ -6848,7 +6967,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6848
6967
|
[0 /* Mainnet */]: {
|
|
6849
6968
|
connections: [
|
|
6850
6969
|
new pythSuiJs.SuiPriceServiceConnection(
|
|
6851
|
-
"https://cetus.
|
|
6970
|
+
"https://cetus-pythnet-a648.mainnet.pythnet.rpcpool.com/219cf7a8-6d75-432d-a648-d487a6dd5dc3/hermes",
|
|
6852
6971
|
{
|
|
6853
6972
|
timeout: 3e3
|
|
6854
6973
|
}
|
|
@@ -6861,7 +6980,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6861
6980
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
6862
6981
|
}
|
|
6863
6982
|
};
|
|
6864
|
-
var
|
|
6983
|
+
var AggregatorClient21 = _AggregatorClient;
|
|
6865
6984
|
function findPythPriceIDs(routes) {
|
|
6866
6985
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
6867
6986
|
for (const route of routes) {
|
|
@@ -6872,6 +6991,14 @@ function findPythPriceIDs(routes) {
|
|
|
6872
6991
|
priceIDs.add(path.extendedDetails.haedalPmmQuotePriceSeed);
|
|
6873
6992
|
}
|
|
6874
6993
|
}
|
|
6994
|
+
if (path.provider === METASTABLE) {
|
|
6995
|
+
if (path.extendedDetails && path.extendedDetails.metastablePriceSeed) {
|
|
6996
|
+
priceIDs.add(path.extendedDetails.metastablePriceSeed);
|
|
6997
|
+
}
|
|
6998
|
+
if (path.extendedDetails && path.extendedDetails.metastableETHPriceSeed) {
|
|
6999
|
+
priceIDs.add(path.extendedDetails.metastableETHPriceSeed);
|
|
7000
|
+
}
|
|
7001
|
+
}
|
|
6875
7002
|
}
|
|
6876
7003
|
}
|
|
6877
7004
|
return Array.from(priceIDs);
|
|
@@ -6900,13 +7027,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6900
7027
|
routes: data.routes.map((route) => {
|
|
6901
7028
|
return {
|
|
6902
7029
|
path: route.path.map((path) => {
|
|
6903
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
7030
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
6904
7031
|
let version;
|
|
6905
7032
|
if (path.provider === AFTERMATH) {
|
|
6906
7033
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6907
7034
|
}
|
|
6908
7035
|
let extendedDetails;
|
|
6909
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
|
|
7036
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM || path.provider === METASTABLE) {
|
|
6910
7037
|
extendedDetails = {
|
|
6911
7038
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6912
7039
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -6921,7 +7048,14 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6921
7048
|
steammLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steamm_lending_market_type,
|
|
6922
7049
|
steammBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steamm_btoken_a_type,
|
|
6923
7050
|
steammBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steamm_btoken_b_type,
|
|
6924
|
-
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type
|
|
7051
|
+
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type,
|
|
7052
|
+
metastablePriceSeed: (_o = path.extended_details) == null ? void 0 : _o.metastable_price_seed,
|
|
7053
|
+
metastableETHPriceSeed: (_p = path.extended_details) == null ? void 0 : _p.metastable_eth_price_seed,
|
|
7054
|
+
metastableWhitelistedAppId: (_q = path.extended_details) == null ? void 0 : _q.metastable_whitelisted_app_id,
|
|
7055
|
+
metastableCreateCapPkgId: (_r = path.extended_details) == null ? void 0 : _r.metastable_create_cap_pkg_id,
|
|
7056
|
+
metastableCreateCapModule: (_s = path.extended_details) == null ? void 0 : _s.metastable_create_cap_module,
|
|
7057
|
+
metastableCreateCapAllTypeParams: (_t = path.extended_details) == null ? void 0 : _t.metastable_create_cap_all_type_params,
|
|
7058
|
+
metastableRegistryId: (_u = path.extended_details) == null ? void 0 : _u.metastable_registry_id
|
|
6925
7059
|
};
|
|
6926
7060
|
}
|
|
6927
7061
|
return {
|
|
@@ -7009,7 +7143,7 @@ function processEndpoint(endpoint) {
|
|
|
7009
7143
|
}
|
|
7010
7144
|
|
|
7011
7145
|
// src/api.ts
|
|
7012
|
-
var SDK_VERSION =
|
|
7146
|
+
var SDK_VERSION = 1000330;
|
|
7013
7147
|
function getRouterResult(endpoint, params) {
|
|
7014
7148
|
return __async(this, null, function* () {
|
|
7015
7149
|
let response;
|
|
@@ -7054,7 +7188,6 @@ function getRouterResult(endpoint, params) {
|
|
|
7054
7188
|
};
|
|
7055
7189
|
}
|
|
7056
7190
|
if (data.data != null) {
|
|
7057
|
-
console.log("data.data", JSON.stringify(data.data, null, 2));
|
|
7058
7191
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7059
7192
|
return res;
|
|
7060
7193
|
}
|
|
@@ -7203,7 +7336,7 @@ exports.AFTERMATH = AFTERMATH;
|
|
|
7203
7336
|
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7204
7337
|
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7205
7338
|
exports.ALPHAFI = ALPHAFI;
|
|
7206
|
-
exports.AggregatorClient =
|
|
7339
|
+
exports.AggregatorClient = AggregatorClient21;
|
|
7207
7340
|
exports.BLUEFIN = BLUEFIN;
|
|
7208
7341
|
exports.BLUEMOVE = BLUEMOVE;
|
|
7209
7342
|
exports.CETUS = CETUS;
|
|
@@ -7218,6 +7351,7 @@ exports.HAEDAL = HAEDAL;
|
|
|
7218
7351
|
exports.HAEDALPMM = HAEDALPMM;
|
|
7219
7352
|
exports.KRIYA = KRIYA;
|
|
7220
7353
|
exports.KRIYAV3 = KRIYAV3;
|
|
7354
|
+
exports.METASTABLE = METASTABLE;
|
|
7221
7355
|
exports.ONE = ONE;
|
|
7222
7356
|
exports.SCALLOP = SCALLOP;
|
|
7223
7357
|
exports.SPRINGSUI = SPRINGSUI;
|
package/dist/index.mjs
CHANGED
|
@@ -6307,6 +6307,117 @@ var Steamm = class {
|
|
|
6307
6307
|
}
|
|
6308
6308
|
};
|
|
6309
6309
|
|
|
6310
|
+
// src/transaction/metastable.ts
|
|
6311
|
+
var SUPER_SUI_TYPE = "0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI";
|
|
6312
|
+
var MUSD_TYPE = "0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD";
|
|
6313
|
+
var METH_TYPE = "0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH";
|
|
6314
|
+
var Metastable = class {
|
|
6315
|
+
constructor(env, pythPriceIDs) {
|
|
6316
|
+
if (env !== 0 /* Mainnet */) {
|
|
6317
|
+
throw new Error("Metastable only supported on mainnet");
|
|
6318
|
+
}
|
|
6319
|
+
this.versionID = "0x4696559327b35ff2ab26904e7426a1646312e9c836d5c6cff6709a5ccc30915c";
|
|
6320
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6321
|
+
}
|
|
6322
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6323
|
+
return __async(this, null, function* () {
|
|
6324
|
+
const { direction, from, target } = path;
|
|
6325
|
+
const [func, createCapFunc, coinType, metaCoinType] = direction ? ["swap_a2b", "create_deposit_cap", from, target] : ["swap_b2a", "create_withdraw_cap", target, from];
|
|
6326
|
+
let createExchangePkgId = "";
|
|
6327
|
+
let createDepositModule = "pyth";
|
|
6328
|
+
let metaSingletonId = "";
|
|
6329
|
+
if (path.extendedDetails == null) {
|
|
6330
|
+
throw new Error("Extended details not supported metastable");
|
|
6331
|
+
} else {
|
|
6332
|
+
if (!path.extendedDetails.metastableCreateCapPkgId || !path.extendedDetails.metastableCreateCapModule || !path.extendedDetails.metastableRegistryId || !path.extendedDetails.metastableWhitelistedAppId) {
|
|
6333
|
+
throw new Error("CreateCapPkgId or CreateCapModule or RegistryId or WhitelistedAppId or CreateCapAllTypeParams not supported");
|
|
6334
|
+
}
|
|
6335
|
+
createExchangePkgId = path.extendedDetails.metastableCreateCapPkgId;
|
|
6336
|
+
createDepositModule = path.extendedDetails.metastableCreateCapModule;
|
|
6337
|
+
metaSingletonId = path.extendedDetails.metastableWhitelistedAppId;
|
|
6338
|
+
}
|
|
6339
|
+
const createDepositCapTypeArgs = [
|
|
6340
|
+
metaCoinType
|
|
6341
|
+
];
|
|
6342
|
+
if (path.extendedDetails.metastableCreateCapAllTypeParams) {
|
|
6343
|
+
createDepositCapTypeArgs.push(coinType);
|
|
6344
|
+
}
|
|
6345
|
+
const depositArgs = [
|
|
6346
|
+
txb.object(metaSingletonId),
|
|
6347
|
+
txb.object(path.id)
|
|
6348
|
+
];
|
|
6349
|
+
switch (metaCoinType) {
|
|
6350
|
+
case SUPER_SUI_TYPE: {
|
|
6351
|
+
if (!path.extendedDetails.metastableRegistryId) {
|
|
6352
|
+
throw new Error("Not found registry id for super sui");
|
|
6353
|
+
}
|
|
6354
|
+
depositArgs.push(txb.object(path.extendedDetails.metastableRegistryId));
|
|
6355
|
+
break;
|
|
6356
|
+
}
|
|
6357
|
+
case MUSD_TYPE: {
|
|
6358
|
+
if (path.extendedDetails.metastablePriceSeed != null) {
|
|
6359
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastablePriceSeed);
|
|
6360
|
+
if (priceId == null) {
|
|
6361
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastablePriceSeed);
|
|
6362
|
+
}
|
|
6363
|
+
depositArgs.push(txb.object(priceId));
|
|
6364
|
+
}
|
|
6365
|
+
if (path.extendedDetails.metastableETHPriceSeed != null) {
|
|
6366
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastableETHPriceSeed);
|
|
6367
|
+
if (priceId == null) {
|
|
6368
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastableETHPriceSeed);
|
|
6369
|
+
}
|
|
6370
|
+
depositArgs.push(txb.object(priceId));
|
|
6371
|
+
}
|
|
6372
|
+
depositArgs.push(txb.object(CLOCK_ADDRESS));
|
|
6373
|
+
break;
|
|
6374
|
+
}
|
|
6375
|
+
case METH_TYPE: {
|
|
6376
|
+
if (path.extendedDetails.metastablePriceSeed != null) {
|
|
6377
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastablePriceSeed);
|
|
6378
|
+
if (priceId == null) {
|
|
6379
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastablePriceSeed);
|
|
6380
|
+
}
|
|
6381
|
+
depositArgs.push(txb.object(priceId));
|
|
6382
|
+
}
|
|
6383
|
+
if (path.extendedDetails.metastableETHPriceSeed != null) {
|
|
6384
|
+
const priceId = this.pythPriceIDs.get(path.extendedDetails.metastableETHPriceSeed);
|
|
6385
|
+
if (priceId == null) {
|
|
6386
|
+
throw new Error("Invalid Pyth price feed: " + path.extendedDetails.metastableETHPriceSeed);
|
|
6387
|
+
}
|
|
6388
|
+
depositArgs.push(txb.object(priceId));
|
|
6389
|
+
}
|
|
6390
|
+
depositArgs.push(txb.object(CLOCK_ADDRESS));
|
|
6391
|
+
break;
|
|
6392
|
+
}
|
|
6393
|
+
default:
|
|
6394
|
+
throw new Error("Invalid Metacoin: " + metaCoinType);
|
|
6395
|
+
}
|
|
6396
|
+
const depositResult = txb.moveCall({
|
|
6397
|
+
target: `${createExchangePkgId}::${createDepositModule}::${createCapFunc}`,
|
|
6398
|
+
typeArguments: createDepositCapTypeArgs,
|
|
6399
|
+
arguments: depositArgs
|
|
6400
|
+
});
|
|
6401
|
+
const swapArgs = [
|
|
6402
|
+
txb.object(path.id),
|
|
6403
|
+
txb.object(this.versionID),
|
|
6404
|
+
depositResult,
|
|
6405
|
+
inputCoin
|
|
6406
|
+
];
|
|
6407
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6408
|
+
const res = txb.moveCall({
|
|
6409
|
+
target: `${publishedAt}::metastable::${func}`,
|
|
6410
|
+
typeArguments: [
|
|
6411
|
+
coinType,
|
|
6412
|
+
metaCoinType
|
|
6413
|
+
],
|
|
6414
|
+
arguments: swapArgs
|
|
6415
|
+
});
|
|
6416
|
+
return res;
|
|
6417
|
+
});
|
|
6418
|
+
}
|
|
6419
|
+
};
|
|
6420
|
+
|
|
6310
6421
|
// src/client.ts
|
|
6311
6422
|
var CETUS = "CETUS";
|
|
6312
6423
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6328,6 +6439,7 @@ var HAEDALPMM = "HAEDALPMM";
|
|
|
6328
6439
|
var ALPHAFI = "ALPHAFI";
|
|
6329
6440
|
var SPRINGSUI = "SPRINGSUI";
|
|
6330
6441
|
var STEAMM = "STEAMM";
|
|
6442
|
+
var METASTABLE = "METASTABLE";
|
|
6331
6443
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6332
6444
|
function isBuilderRouterSwapParams(params) {
|
|
6333
6445
|
return Array.isArray(params.routers);
|
|
@@ -6365,23 +6477,28 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6365
6477
|
}
|
|
6366
6478
|
const allCoins = [];
|
|
6367
6479
|
while (true) {
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
for (const coin of gotCoins.data) {
|
|
6375
|
-
allCoins.push({
|
|
6376
|
-
coinAddress: extractStructTagFromType(coin.coinType).source_address,
|
|
6377
|
-
coinObjectId: coin.coinObjectId,
|
|
6378
|
-
balance: BigInt(coin.balance)
|
|
6480
|
+
try {
|
|
6481
|
+
const gotCoins = yield this.client.getCoins({
|
|
6482
|
+
owner: this.signer,
|
|
6483
|
+
coinType,
|
|
6484
|
+
cursor,
|
|
6485
|
+
limit
|
|
6379
6486
|
});
|
|
6380
|
-
|
|
6381
|
-
|
|
6487
|
+
for (const coin of gotCoins.data) {
|
|
6488
|
+
allCoins.push({
|
|
6489
|
+
coinAddress: extractStructTagFromType(coin.coinType).source_address,
|
|
6490
|
+
coinObjectId: coin.coinObjectId,
|
|
6491
|
+
balance: BigInt(coin.balance)
|
|
6492
|
+
});
|
|
6493
|
+
}
|
|
6494
|
+
if (gotCoins.data.length < limit) {
|
|
6495
|
+
break;
|
|
6496
|
+
}
|
|
6497
|
+
cursor = gotCoins.data[limit - 1].coinObjectId;
|
|
6498
|
+
} catch (e) {
|
|
6499
|
+
console.error("getCoins error:", e);
|
|
6382
6500
|
break;
|
|
6383
6501
|
}
|
|
6384
|
-
cursor = gotCoins.data[limit - 1].coinObjectId;
|
|
6385
6502
|
}
|
|
6386
6503
|
this.allCoins.set(coinType, allCoins);
|
|
6387
6504
|
return allCoins;
|
|
@@ -6665,7 +6782,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6665
6782
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6666
6783
|
publishedAtV2() {
|
|
6667
6784
|
if (this.env === 0 /* Mainnet */) {
|
|
6668
|
-
return "
|
|
6785
|
+
return "0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032";
|
|
6669
6786
|
} else {
|
|
6670
6787
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6671
6788
|
}
|
|
@@ -6752,6 +6869,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6752
6869
|
return new Alphafi(this.env);
|
|
6753
6870
|
case STEAMM:
|
|
6754
6871
|
return new Steamm(this.env);
|
|
6872
|
+
case METASTABLE:
|
|
6873
|
+
return new Metastable(this.env, pythPriceIDs);
|
|
6755
6874
|
default:
|
|
6756
6875
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6757
6876
|
}
|
|
@@ -6846,7 +6965,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6846
6965
|
[0 /* Mainnet */]: {
|
|
6847
6966
|
connections: [
|
|
6848
6967
|
new SuiPriceServiceConnection(
|
|
6849
|
-
"https://cetus.
|
|
6968
|
+
"https://cetus-pythnet-a648.mainnet.pythnet.rpcpool.com/219cf7a8-6d75-432d-a648-d487a6dd5dc3/hermes",
|
|
6850
6969
|
{
|
|
6851
6970
|
timeout: 3e3
|
|
6852
6971
|
}
|
|
@@ -6859,7 +6978,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6859
6978
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
6860
6979
|
}
|
|
6861
6980
|
};
|
|
6862
|
-
var
|
|
6981
|
+
var AggregatorClient21 = _AggregatorClient;
|
|
6863
6982
|
function findPythPriceIDs(routes) {
|
|
6864
6983
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
6865
6984
|
for (const route of routes) {
|
|
@@ -6870,6 +6989,14 @@ function findPythPriceIDs(routes) {
|
|
|
6870
6989
|
priceIDs.add(path.extendedDetails.haedalPmmQuotePriceSeed);
|
|
6871
6990
|
}
|
|
6872
6991
|
}
|
|
6992
|
+
if (path.provider === METASTABLE) {
|
|
6993
|
+
if (path.extendedDetails && path.extendedDetails.metastablePriceSeed) {
|
|
6994
|
+
priceIDs.add(path.extendedDetails.metastablePriceSeed);
|
|
6995
|
+
}
|
|
6996
|
+
if (path.extendedDetails && path.extendedDetails.metastableETHPriceSeed) {
|
|
6997
|
+
priceIDs.add(path.extendedDetails.metastableETHPriceSeed);
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
6873
7000
|
}
|
|
6874
7001
|
}
|
|
6875
7002
|
return Array.from(priceIDs);
|
|
@@ -6898,13 +7025,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6898
7025
|
routes: data.routes.map((route) => {
|
|
6899
7026
|
return {
|
|
6900
7027
|
path: route.path.map((path) => {
|
|
6901
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
7028
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
6902
7029
|
let version;
|
|
6903
7030
|
if (path.provider === AFTERMATH) {
|
|
6904
7031
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6905
7032
|
}
|
|
6906
7033
|
let extendedDetails;
|
|
6907
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
|
|
7034
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM || path.provider === METASTABLE) {
|
|
6908
7035
|
extendedDetails = {
|
|
6909
7036
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6910
7037
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -6919,7 +7046,14 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6919
7046
|
steammLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steamm_lending_market_type,
|
|
6920
7047
|
steammBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steamm_btoken_a_type,
|
|
6921
7048
|
steammBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steamm_btoken_b_type,
|
|
6922
|
-
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type
|
|
7049
|
+
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type,
|
|
7050
|
+
metastablePriceSeed: (_o = path.extended_details) == null ? void 0 : _o.metastable_price_seed,
|
|
7051
|
+
metastableETHPriceSeed: (_p = path.extended_details) == null ? void 0 : _p.metastable_eth_price_seed,
|
|
7052
|
+
metastableWhitelistedAppId: (_q = path.extended_details) == null ? void 0 : _q.metastable_whitelisted_app_id,
|
|
7053
|
+
metastableCreateCapPkgId: (_r = path.extended_details) == null ? void 0 : _r.metastable_create_cap_pkg_id,
|
|
7054
|
+
metastableCreateCapModule: (_s = path.extended_details) == null ? void 0 : _s.metastable_create_cap_module,
|
|
7055
|
+
metastableCreateCapAllTypeParams: (_t = path.extended_details) == null ? void 0 : _t.metastable_create_cap_all_type_params,
|
|
7056
|
+
metastableRegistryId: (_u = path.extended_details) == null ? void 0 : _u.metastable_registry_id
|
|
6923
7057
|
};
|
|
6924
7058
|
}
|
|
6925
7059
|
return {
|
|
@@ -7007,7 +7141,7 @@ function processEndpoint(endpoint) {
|
|
|
7007
7141
|
}
|
|
7008
7142
|
|
|
7009
7143
|
// src/api.ts
|
|
7010
|
-
var SDK_VERSION =
|
|
7144
|
+
var SDK_VERSION = 1000330;
|
|
7011
7145
|
function getRouterResult(endpoint, params) {
|
|
7012
7146
|
return __async(this, null, function* () {
|
|
7013
7147
|
let response;
|
|
@@ -7052,7 +7186,6 @@ function getRouterResult(endpoint, params) {
|
|
|
7052
7186
|
};
|
|
7053
7187
|
}
|
|
7054
7188
|
if (data.data != null) {
|
|
7055
|
-
console.log("data.data", JSON.stringify(data.data, null, 2));
|
|
7056
7189
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7057
7190
|
return res;
|
|
7058
7191
|
}
|
|
@@ -7196,4 +7329,4 @@ decimal.js/decimal.mjs:
|
|
|
7196
7329
|
*)
|
|
7197
7330
|
*/
|
|
7198
7331
|
|
|
7199
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI,
|
|
7332
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient21 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, METASTABLE, ONE, SCALLOP, SPRINGSUI, STEAMM, SUILEND, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, findPythPriceIDs, fixSuiObjectId, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/src/api.d.ts
CHANGED
|
@@ -34,6 +34,13 @@ export type ExtendedDetails = {
|
|
|
34
34
|
steammBCoinAType?: string;
|
|
35
35
|
steammBCoinBType?: string;
|
|
36
36
|
steammLPToken?: string;
|
|
37
|
+
metastablePriceSeed?: string;
|
|
38
|
+
metastableETHPriceSeed?: string;
|
|
39
|
+
metastableWhitelistedAppId?: string;
|
|
40
|
+
metastableCreateCapPkgId?: string;
|
|
41
|
+
metastableCreateCapModule?: string;
|
|
42
|
+
metastableCreateCapAllTypeParams?: boolean;
|
|
43
|
+
metastableRegistryId?: string;
|
|
37
44
|
};
|
|
38
45
|
export type Path = {
|
|
39
46
|
id: string;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const HAEDALPMM = "HAEDALPMM";
|
|
|
24
24
|
export declare const ALPHAFI = "ALPHAFI";
|
|
25
25
|
export declare const SPRINGSUI = "SPRINGSUI";
|
|
26
26
|
export declare const STEAMM = "STEAMM";
|
|
27
|
+
export declare const METASTABLE = "METASTABLE";
|
|
27
28
|
export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
28
29
|
export type BuildRouterSwapParams = {
|
|
29
30
|
routers: Router[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { AggregatorClient, Dex, Env, Path } from "..";
|
|
3
|
+
export declare class Metastable implements Dex {
|
|
4
|
+
private pythPriceIDs;
|
|
5
|
+
private versionID;
|
|
6
|
+
constructor(env: Env, pythPriceIDs: Map<string, string>);
|
|
7
|
+
swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
8
|
+
}
|