@cetusprotocol/aggregator-sdk 0.6.0 → 0.8.0
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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +198 -22
- package/dist/index.mjs +194 -22
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -84,6 +84,8 @@ declare const STEAMM = "STEAMM";
|
|
|
84
84
|
declare const METASTABLE = "METASTABLE";
|
|
85
85
|
declare const OBRIC = "OBRIC";
|
|
86
86
|
declare const HAWAL = "HAWAL";
|
|
87
|
+
declare const STEAMM_OMM = "STEAMM_OMM";
|
|
88
|
+
declare const MOMENTUM = "MOMENTUM";
|
|
87
89
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
88
90
|
type BuildRouterSwapParams = {
|
|
89
91
|
routers: Router[];
|
|
@@ -167,6 +169,7 @@ declare class AggregatorClient {
|
|
|
167
169
|
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
168
170
|
publishedAtV2(): string;
|
|
169
171
|
publishedAtV2Extend(): string;
|
|
172
|
+
publishedAtV2Extend2(): string;
|
|
170
173
|
deepbookv3DeepFeeType(): string;
|
|
171
174
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
172
175
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, expectedAmountOut: string, threshold: string, aggregatorV2ExtendPublishedAt: string): TransactionObjectArgument;
|
|
@@ -183,8 +186,10 @@ declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData
|
|
|
183
186
|
declare const CLOCK_ADDRESS: string;
|
|
184
187
|
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
185
188
|
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
189
|
+
declare const AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2";
|
|
186
190
|
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
187
191
|
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
192
|
+
declare function getAggregatorV2Extend2PublishedAt(aggregatorV2Extend2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
188
193
|
interface Dex {
|
|
189
194
|
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
190
195
|
}
|
|
@@ -265,6 +270,11 @@ type ExtendedDetails = {
|
|
|
265
270
|
steammBCoinAType?: string;
|
|
266
271
|
steammBCoinBType?: string;
|
|
267
272
|
steammLPToken?: string;
|
|
273
|
+
steammOracleRegistryId?: string;
|
|
274
|
+
steammOraclePythPriceSeedA?: string;
|
|
275
|
+
steammOraclePythPriceSeedB?: string;
|
|
276
|
+
steammOracleIndexA?: number;
|
|
277
|
+
steammOracleIndexB?: number;
|
|
268
278
|
metastablePriceSeed?: string;
|
|
269
279
|
metastableETHPriceSeed?: string;
|
|
270
280
|
metastableWhitelistedAppId?: string;
|
|
@@ -340,4 +350,4 @@ declare enum Env {
|
|
|
340
350
|
Testnet = 1
|
|
341
351
|
}
|
|
342
352
|
|
|
343
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, METASTABLE, OBRIC, 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 };
|
|
353
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ declare const STEAMM = "STEAMM";
|
|
|
84
84
|
declare const METASTABLE = "METASTABLE";
|
|
85
85
|
declare const OBRIC = "OBRIC";
|
|
86
86
|
declare const HAWAL = "HAWAL";
|
|
87
|
+
declare const STEAMM_OMM = "STEAMM_OMM";
|
|
88
|
+
declare const MOMENTUM = "MOMENTUM";
|
|
87
89
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
88
90
|
type BuildRouterSwapParams = {
|
|
89
91
|
routers: Router[];
|
|
@@ -167,6 +169,7 @@ declare class AggregatorClient {
|
|
|
167
169
|
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
168
170
|
publishedAtV2(): string;
|
|
169
171
|
publishedAtV2Extend(): string;
|
|
172
|
+
publishedAtV2Extend2(): string;
|
|
170
173
|
deepbookv3DeepFeeType(): string;
|
|
171
174
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
172
175
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, expectedAmountOut: string, threshold: string, aggregatorV2ExtendPublishedAt: string): TransactionObjectArgument;
|
|
@@ -183,8 +186,10 @@ declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData
|
|
|
183
186
|
declare const CLOCK_ADDRESS: string;
|
|
184
187
|
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
185
188
|
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
189
|
+
declare const AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2";
|
|
186
190
|
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
187
191
|
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
192
|
+
declare function getAggregatorV2Extend2PublishedAt(aggregatorV2Extend2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
188
193
|
interface Dex {
|
|
189
194
|
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
190
195
|
}
|
|
@@ -265,6 +270,11 @@ type ExtendedDetails = {
|
|
|
265
270
|
steammBCoinAType?: string;
|
|
266
271
|
steammBCoinBType?: string;
|
|
267
272
|
steammLPToken?: string;
|
|
273
|
+
steammOracleRegistryId?: string;
|
|
274
|
+
steammOraclePythPriceSeedA?: string;
|
|
275
|
+
steammOraclePythPriceSeedB?: string;
|
|
276
|
+
steammOracleIndexA?: number;
|
|
277
|
+
steammOracleIndexB?: number;
|
|
268
278
|
metastablePriceSeed?: string;
|
|
269
279
|
metastableETHPriceSeed?: string;
|
|
270
280
|
metastableWhitelistedAppId?: string;
|
|
@@ -340,4 +350,4 @@ declare enum Env {
|
|
|
340
350
|
Testnet = 1
|
|
341
351
|
}
|
|
342
352
|
|
|
343
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, METASTABLE, OBRIC, 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 };
|
|
353
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALPHAFI, AggregatorClient, type AggregatorClientParams, 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, HAWAL, KRIYA, KRIYAV3, METASTABLE, MOMENTUM, OBRIC, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.js
CHANGED
|
@@ -6249,8 +6249,8 @@ var Alphafi = class {
|
|
|
6249
6249
|
}
|
|
6250
6250
|
};
|
|
6251
6251
|
|
|
6252
|
-
// src/transaction/
|
|
6253
|
-
var
|
|
6252
|
+
// src/transaction/steamm_cpmm.ts
|
|
6253
|
+
var SteammCPMM = class {
|
|
6254
6254
|
constructor(env) {
|
|
6255
6255
|
if (env !== 0 /* Mainnet */) {
|
|
6256
6256
|
throw new Error("Steamm only supported on mainnet");
|
|
@@ -6259,7 +6259,7 @@ var Steamm = class {
|
|
|
6259
6259
|
swap(client, txb, path, inputCoin, packages) {
|
|
6260
6260
|
return __async(this, null, function* () {
|
|
6261
6261
|
const { direction, from, target } = path;
|
|
6262
|
-
const [func, coinAType, coinBType] = direction ? ["
|
|
6262
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6263
6263
|
if (path.extendedDetails == null) {
|
|
6264
6264
|
throw new Error("Extended details not supported");
|
|
6265
6265
|
} else {
|
|
@@ -6293,9 +6293,117 @@ var Steamm = class {
|
|
|
6293
6293
|
inputCoin,
|
|
6294
6294
|
txb.object(CLOCK_ADDRESS)
|
|
6295
6295
|
];
|
|
6296
|
-
const publishedAt =
|
|
6296
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6297
|
+
const res = txb.moveCall({
|
|
6298
|
+
target: `${publishedAt}::steamm_cpmm::${func}`,
|
|
6299
|
+
typeArguments: [
|
|
6300
|
+
path.extendedDetails.steammLendingMarketType,
|
|
6301
|
+
coinAType,
|
|
6302
|
+
coinBType,
|
|
6303
|
+
path.extendedDetails.steammBCoinAType,
|
|
6304
|
+
path.extendedDetails.steammBCoinBType,
|
|
6305
|
+
path.extendedDetails.steammLPToken
|
|
6306
|
+
],
|
|
6307
|
+
arguments: args
|
|
6308
|
+
});
|
|
6309
|
+
return res;
|
|
6310
|
+
});
|
|
6311
|
+
}
|
|
6312
|
+
};
|
|
6313
|
+
|
|
6314
|
+
// src/transaction/steamm_omm.ts
|
|
6315
|
+
var SteammOmm = class {
|
|
6316
|
+
constructor(env, pythPriceIDs) {
|
|
6317
|
+
if (env !== 0 /* Mainnet */) {
|
|
6318
|
+
throw new Error("Steamm only supported on mainnet");
|
|
6319
|
+
}
|
|
6320
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6321
|
+
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
6322
|
+
}
|
|
6323
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6324
|
+
return __async(this, null, function* () {
|
|
6325
|
+
const { direction, from, target } = path;
|
|
6326
|
+
if (path.extendedDetails == null) {
|
|
6327
|
+
throw new Error("Extended details not supported");
|
|
6328
|
+
} else {
|
|
6329
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6330
|
+
throw new Error("Steamm bank a type not supported");
|
|
6331
|
+
}
|
|
6332
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6333
|
+
throw new Error("Steamm bank b type not supported");
|
|
6334
|
+
}
|
|
6335
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6336
|
+
throw new Error("Steamm lending market not supported");
|
|
6337
|
+
}
|
|
6338
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6339
|
+
throw new Error("Steamm lending market type not supported");
|
|
6340
|
+
}
|
|
6341
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6342
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6343
|
+
}
|
|
6344
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6345
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6346
|
+
}
|
|
6347
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6348
|
+
throw new Error("Steamm lp token not supported");
|
|
6349
|
+
}
|
|
6350
|
+
if (path.extendedDetails.steammOracleRegistryId == null) {
|
|
6351
|
+
throw new Error("Steamm oracle registry id not supported");
|
|
6352
|
+
}
|
|
6353
|
+
if (path.extendedDetails.steammOracleIndexA == null) {
|
|
6354
|
+
throw new Error("Steamm oracle index a not supported");
|
|
6355
|
+
}
|
|
6356
|
+
if (path.extendedDetails.steammOracleIndexB == null) {
|
|
6357
|
+
throw new Error("Steamm oracle index b not supported");
|
|
6358
|
+
}
|
|
6359
|
+
if (path.extendedDetails.steammOraclePythPriceSeedA == null) {
|
|
6360
|
+
throw new Error("Steamm oracle pyth price seed a not supported");
|
|
6361
|
+
}
|
|
6362
|
+
if (path.extendedDetails.steammOraclePythPriceSeedB == null) {
|
|
6363
|
+
throw new Error("Steamm oracle pyth price seed b not supported");
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6367
|
+
const priceSeedA = path.extendedDetails.steammOraclePythPriceSeedA;
|
|
6368
|
+
const priceSeedB = path.extendedDetails.steammOraclePythPriceSeedB;
|
|
6369
|
+
const priceInfoObjectIdA = this.pythPriceIDs.get(priceSeedA);
|
|
6370
|
+
const priceInfoObjectIdB = this.pythPriceIDs.get(priceSeedB);
|
|
6371
|
+
if (!priceInfoObjectIdA || !priceInfoObjectIdB) {
|
|
6372
|
+
throw new Error("Base price info object id or quote price info object id not found");
|
|
6373
|
+
}
|
|
6374
|
+
const oraclePriceUpdateA = txb.moveCall({
|
|
6375
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6376
|
+
typeArguments: [],
|
|
6377
|
+
arguments: [
|
|
6378
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6379
|
+
txb.object(priceInfoObjectIdA),
|
|
6380
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexA),
|
|
6381
|
+
txb.object(CLOCK_ADDRESS)
|
|
6382
|
+
]
|
|
6383
|
+
});
|
|
6384
|
+
const oraclePriceUpdateB = txb.moveCall({
|
|
6385
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6386
|
+
typeArguments: [],
|
|
6387
|
+
arguments: [
|
|
6388
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6389
|
+
txb.object(priceInfoObjectIdB),
|
|
6390
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexB),
|
|
6391
|
+
txb.object(CLOCK_ADDRESS)
|
|
6392
|
+
]
|
|
6393
|
+
});
|
|
6394
|
+
const args = [
|
|
6395
|
+
txb.object(path.id),
|
|
6396
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6397
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6398
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6399
|
+
oraclePriceUpdateA,
|
|
6400
|
+
oraclePriceUpdateB,
|
|
6401
|
+
inputCoin,
|
|
6402
|
+
txb.object(CLOCK_ADDRESS)
|
|
6403
|
+
];
|
|
6404
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6297
6405
|
const res = txb.moveCall({
|
|
6298
|
-
target: `${publishedAt}::
|
|
6406
|
+
target: `${publishedAt}::steamm_omm::${func}`,
|
|
6299
6407
|
typeArguments: [
|
|
6300
6408
|
path.extendedDetails.steammLendingMarketType,
|
|
6301
6409
|
coinAType,
|
|
@@ -6513,6 +6621,35 @@ var HaWAL = class {
|
|
|
6513
6621
|
}
|
|
6514
6622
|
};
|
|
6515
6623
|
|
|
6624
|
+
// src/transaction/momentum.ts
|
|
6625
|
+
var Momentum = class {
|
|
6626
|
+
constructor(env) {
|
|
6627
|
+
if (env !== 0 /* Mainnet */) {
|
|
6628
|
+
throw new Error("Momentum only supported on mainnet");
|
|
6629
|
+
}
|
|
6630
|
+
this.version = "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a";
|
|
6631
|
+
}
|
|
6632
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6633
|
+
return __async(this, null, function* () {
|
|
6634
|
+
const { direction, from, target } = path;
|
|
6635
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6636
|
+
const args = [
|
|
6637
|
+
txb.object(path.id),
|
|
6638
|
+
inputCoin,
|
|
6639
|
+
txb.object(this.version),
|
|
6640
|
+
txb.object(CLOCK_ADDRESS)
|
|
6641
|
+
];
|
|
6642
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6643
|
+
const res = txb.moveCall({
|
|
6644
|
+
target: `${publishedAt}::momentum::${func}`,
|
|
6645
|
+
typeArguments: [coinAType, coinBType],
|
|
6646
|
+
arguments: args
|
|
6647
|
+
});
|
|
6648
|
+
return res;
|
|
6649
|
+
});
|
|
6650
|
+
}
|
|
6651
|
+
};
|
|
6652
|
+
|
|
6516
6653
|
// src/client.ts
|
|
6517
6654
|
var CETUS = "CETUS";
|
|
6518
6655
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6537,6 +6674,8 @@ var STEAMM = "STEAMM";
|
|
|
6537
6674
|
var METASTABLE = "METASTABLE";
|
|
6538
6675
|
var OBRIC = "OBRIC";
|
|
6539
6676
|
var HAWAL = "HAWAL";
|
|
6677
|
+
var STEAMM_OMM = "STEAMM_OMM";
|
|
6678
|
+
var MOMENTUM = "MOMENTUM";
|
|
6540
6679
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6541
6680
|
function isBuilderRouterSwapParams(params) {
|
|
6542
6681
|
return Array.isArray(params.routers);
|
|
@@ -7058,6 +7197,13 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7058
7197
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
7059
7198
|
}
|
|
7060
7199
|
}
|
|
7200
|
+
publishedAtV2Extend2() {
|
|
7201
|
+
if (this.env === 0 /* Mainnet */) {
|
|
7202
|
+
return "0x0018f7bbbece22f4272ed2281b290f745e5aa69d870f599810a30b4eeffc1a5e";
|
|
7203
|
+
} else {
|
|
7204
|
+
return "0x0";
|
|
7205
|
+
}
|
|
7206
|
+
}
|
|
7061
7207
|
deepbookv3DeepFeeType() {
|
|
7062
7208
|
if (this.env === 0 /* Mainnet */) {
|
|
7063
7209
|
return "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP";
|
|
@@ -7149,13 +7295,17 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7149
7295
|
case ALPHAFI:
|
|
7150
7296
|
return new Alphafi(this.env);
|
|
7151
7297
|
case STEAMM:
|
|
7152
|
-
return new
|
|
7298
|
+
return new SteammCPMM(this.env);
|
|
7299
|
+
case STEAMM_OMM:
|
|
7300
|
+
return new SteammOmm(this.env, pythPriceIDs);
|
|
7153
7301
|
case METASTABLE:
|
|
7154
7302
|
return new Metastable(this.env, pythPriceIDs);
|
|
7155
7303
|
case OBRIC:
|
|
7156
7304
|
return new Obric(this.env, pythPriceIDs);
|
|
7157
7305
|
case HAWAL:
|
|
7158
7306
|
return new HaWAL(this.env);
|
|
7307
|
+
case MOMENTUM:
|
|
7308
|
+
return new Momentum(this.env);
|
|
7159
7309
|
default:
|
|
7160
7310
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7161
7311
|
}
|
|
@@ -7249,7 +7399,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7249
7399
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7250
7400
|
}
|
|
7251
7401
|
};
|
|
7252
|
-
var
|
|
7402
|
+
var AggregatorClient25 = _AggregatorClient;
|
|
7253
7403
|
function findPythPriceIDs(routes) {
|
|
7254
7404
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7255
7405
|
for (const route of routes) {
|
|
@@ -7276,6 +7426,14 @@ function findPythPriceIDs(routes) {
|
|
|
7276
7426
|
priceIDs.add(path.extendedDetails.obricCoinBPriceSeed);
|
|
7277
7427
|
}
|
|
7278
7428
|
}
|
|
7429
|
+
if (path.provider === STEAMM_OMM) {
|
|
7430
|
+
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedA) {
|
|
7431
|
+
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedA);
|
|
7432
|
+
}
|
|
7433
|
+
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedB) {
|
|
7434
|
+
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
|
|
7435
|
+
}
|
|
7436
|
+
}
|
|
7279
7437
|
}
|
|
7280
7438
|
}
|
|
7281
7439
|
return Array.from(priceIDs);
|
|
@@ -7304,13 +7462,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7304
7462
|
routes: data.routes.map((route) => {
|
|
7305
7463
|
return {
|
|
7306
7464
|
path: route.path.map((path) => {
|
|
7307
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
7465
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
7308
7466
|
let version;
|
|
7309
7467
|
if (path.provider === AFTERMATH) {
|
|
7310
7468
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
7311
7469
|
}
|
|
7312
7470
|
let extendedDetails;
|
|
7313
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider ===
|
|
7471
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM) {
|
|
7314
7472
|
extendedDetails = {
|
|
7315
7473
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
7316
7474
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -7326,17 +7484,22 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7326
7484
|
steammBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steamm_btoken_a_type,
|
|
7327
7485
|
steammBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steamm_btoken_b_type,
|
|
7328
7486
|
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type,
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7487
|
+
steammOracleRegistryId: (_o = path.extended_details) == null ? void 0 : _o.steamm_oracle_registry_id,
|
|
7488
|
+
steammOracleIndexA: (_p = path.extended_details) == null ? void 0 : _p.steamm_oracle_index_a,
|
|
7489
|
+
steammOracleIndexB: (_q = path.extended_details) == null ? void 0 : _q.steamm_oracle_index_b,
|
|
7490
|
+
steammOraclePythPriceSeedA: (_r = path.extended_details) == null ? void 0 : _r.steamm_oracle_pyth_price_seed_a,
|
|
7491
|
+
steammOraclePythPriceSeedB: (_s = path.extended_details) == null ? void 0 : _s.steamm_oracle_pyth_price_seed_b,
|
|
7492
|
+
metastablePriceSeed: (_t = path.extended_details) == null ? void 0 : _t.metastable_price_seed,
|
|
7493
|
+
metastableETHPriceSeed: (_u = path.extended_details) == null ? void 0 : _u.metastable_eth_price_seed,
|
|
7494
|
+
metastableWhitelistedAppId: (_v = path.extended_details) == null ? void 0 : _v.metastable_whitelisted_app_id,
|
|
7495
|
+
metastableCreateCapPkgId: (_w = path.extended_details) == null ? void 0 : _w.metastable_create_cap_pkg_id,
|
|
7496
|
+
metastableCreateCapModule: (_x = path.extended_details) == null ? void 0 : _x.metastable_create_cap_module,
|
|
7497
|
+
metastableCreateCapAllTypeParams: (_y = path.extended_details) == null ? void 0 : _y.metastable_create_cap_all_type_params,
|
|
7498
|
+
metastableRegistryId: (_z = path.extended_details) == null ? void 0 : _z.metastable_registry_id,
|
|
7499
|
+
obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
|
|
7500
|
+
obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
|
|
7501
|
+
obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
|
|
7502
|
+
obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
|
|
7340
7503
|
};
|
|
7341
7504
|
}
|
|
7342
7505
|
return {
|
|
@@ -7365,6 +7528,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7365
7528
|
var CLOCK_ADDRESS = utils.SUI_CLOCK_OBJECT_ID;
|
|
7366
7529
|
var AGGREGATOR_V2 = "aggregator_v2";
|
|
7367
7530
|
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
7531
|
+
var AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2";
|
|
7368
7532
|
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
7369
7533
|
var _a;
|
|
7370
7534
|
if (packages instanceof Map) {
|
|
@@ -7379,6 +7543,13 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
|
|
|
7379
7543
|
}
|
|
7380
7544
|
return aggregatorV2ExtendPublishedAt;
|
|
7381
7545
|
}
|
|
7546
|
+
function getAggregatorV2Extend2PublishedAt(aggregatorV2Extend2PublishedAt, packages) {
|
|
7547
|
+
var _a;
|
|
7548
|
+
if (packages instanceof Map) {
|
|
7549
|
+
return (_a = packages.get(AGGREGATOR_V2_EXTEND2)) != null ? _a : aggregatorV2Extend2PublishedAt;
|
|
7550
|
+
}
|
|
7551
|
+
return aggregatorV2Extend2PublishedAt;
|
|
7552
|
+
}
|
|
7382
7553
|
|
|
7383
7554
|
// src/utils/msafe.ts
|
|
7384
7555
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -7425,7 +7596,7 @@ function processEndpoint(endpoint) {
|
|
|
7425
7596
|
|
|
7426
7597
|
// src/api.ts
|
|
7427
7598
|
var import_bn7 = __toESM(require_bn());
|
|
7428
|
-
var SDK_VERSION =
|
|
7599
|
+
var SDK_VERSION = 1000800;
|
|
7429
7600
|
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7430
7601
|
return __async(this, null, function* () {
|
|
7431
7602
|
let response;
|
|
@@ -7472,6 +7643,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
|
|
|
7472
7643
|
};
|
|
7473
7644
|
}
|
|
7474
7645
|
if (data.data != null) {
|
|
7646
|
+
console.log("data: ", JSON.stringify(data.data, null, 2));
|
|
7475
7647
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7476
7648
|
if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
|
|
7477
7649
|
if (params.byAmountIn) {
|
|
@@ -7633,8 +7805,9 @@ exports.AFSUI = AFSUI;
|
|
|
7633
7805
|
exports.AFTERMATH = AFTERMATH;
|
|
7634
7806
|
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7635
7807
|
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7808
|
+
exports.AGGREGATOR_V2_EXTEND2 = AGGREGATOR_V2_EXTEND2;
|
|
7636
7809
|
exports.ALPHAFI = ALPHAFI;
|
|
7637
|
-
exports.AggregatorClient =
|
|
7810
|
+
exports.AggregatorClient = AggregatorClient25;
|
|
7638
7811
|
exports.BLUEFIN = BLUEFIN;
|
|
7639
7812
|
exports.BLUEMOVE = BLUEMOVE;
|
|
7640
7813
|
exports.CETUS = CETUS;
|
|
@@ -7651,11 +7824,13 @@ exports.HAWAL = HAWAL;
|
|
|
7651
7824
|
exports.KRIYA = KRIYA;
|
|
7652
7825
|
exports.KRIYAV3 = KRIYAV3;
|
|
7653
7826
|
exports.METASTABLE = METASTABLE;
|
|
7827
|
+
exports.MOMENTUM = MOMENTUM;
|
|
7654
7828
|
exports.OBRIC = OBRIC;
|
|
7655
7829
|
exports.ONE = ONE;
|
|
7656
7830
|
exports.SCALLOP = SCALLOP;
|
|
7657
7831
|
exports.SPRINGSUI = SPRINGSUI;
|
|
7658
7832
|
exports.STEAMM = STEAMM;
|
|
7833
|
+
exports.STEAMM_OMM = STEAMM_OMM;
|
|
7659
7834
|
exports.SUILEND = SUILEND;
|
|
7660
7835
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
7661
7836
|
exports.TURBOS = TURBOS;
|
|
@@ -7676,6 +7851,7 @@ exports.extractAddressFromType = extractAddressFromType;
|
|
|
7676
7851
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
7677
7852
|
exports.findPythPriceIDs = findPythPriceIDs;
|
|
7678
7853
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
7854
|
+
exports.getAggregatorV2Extend2PublishedAt = getAggregatorV2Extend2PublishedAt;
|
|
7679
7855
|
exports.getAggregatorV2ExtendPublishedAt = getAggregatorV2ExtendPublishedAt;
|
|
7680
7856
|
exports.getAggregatorV2PublishedAt = getAggregatorV2PublishedAt;
|
|
7681
7857
|
exports.getDeepbookV3Config = getDeepbookV3Config;
|
package/dist/index.mjs
CHANGED
|
@@ -6247,8 +6247,8 @@ var Alphafi = class {
|
|
|
6247
6247
|
}
|
|
6248
6248
|
};
|
|
6249
6249
|
|
|
6250
|
-
// src/transaction/
|
|
6251
|
-
var
|
|
6250
|
+
// src/transaction/steamm_cpmm.ts
|
|
6251
|
+
var SteammCPMM = class {
|
|
6252
6252
|
constructor(env) {
|
|
6253
6253
|
if (env !== 0 /* Mainnet */) {
|
|
6254
6254
|
throw new Error("Steamm only supported on mainnet");
|
|
@@ -6257,7 +6257,7 @@ var Steamm = class {
|
|
|
6257
6257
|
swap(client, txb, path, inputCoin, packages) {
|
|
6258
6258
|
return __async(this, null, function* () {
|
|
6259
6259
|
const { direction, from, target } = path;
|
|
6260
|
-
const [func, coinAType, coinBType] = direction ? ["
|
|
6260
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6261
6261
|
if (path.extendedDetails == null) {
|
|
6262
6262
|
throw new Error("Extended details not supported");
|
|
6263
6263
|
} else {
|
|
@@ -6291,9 +6291,117 @@ var Steamm = class {
|
|
|
6291
6291
|
inputCoin,
|
|
6292
6292
|
txb.object(CLOCK_ADDRESS)
|
|
6293
6293
|
];
|
|
6294
|
-
const publishedAt =
|
|
6294
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6295
|
+
const res = txb.moveCall({
|
|
6296
|
+
target: `${publishedAt}::steamm_cpmm::${func}`,
|
|
6297
|
+
typeArguments: [
|
|
6298
|
+
path.extendedDetails.steammLendingMarketType,
|
|
6299
|
+
coinAType,
|
|
6300
|
+
coinBType,
|
|
6301
|
+
path.extendedDetails.steammBCoinAType,
|
|
6302
|
+
path.extendedDetails.steammBCoinBType,
|
|
6303
|
+
path.extendedDetails.steammLPToken
|
|
6304
|
+
],
|
|
6305
|
+
arguments: args
|
|
6306
|
+
});
|
|
6307
|
+
return res;
|
|
6308
|
+
});
|
|
6309
|
+
}
|
|
6310
|
+
};
|
|
6311
|
+
|
|
6312
|
+
// src/transaction/steamm_omm.ts
|
|
6313
|
+
var SteammOmm = class {
|
|
6314
|
+
constructor(env, pythPriceIDs) {
|
|
6315
|
+
if (env !== 0 /* Mainnet */) {
|
|
6316
|
+
throw new Error("Steamm only supported on mainnet");
|
|
6317
|
+
}
|
|
6318
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6319
|
+
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
6320
|
+
}
|
|
6321
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6322
|
+
return __async(this, null, function* () {
|
|
6323
|
+
const { direction, from, target } = path;
|
|
6324
|
+
if (path.extendedDetails == null) {
|
|
6325
|
+
throw new Error("Extended details not supported");
|
|
6326
|
+
} else {
|
|
6327
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6328
|
+
throw new Error("Steamm bank a type not supported");
|
|
6329
|
+
}
|
|
6330
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6331
|
+
throw new Error("Steamm bank b type not supported");
|
|
6332
|
+
}
|
|
6333
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6334
|
+
throw new Error("Steamm lending market not supported");
|
|
6335
|
+
}
|
|
6336
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6337
|
+
throw new Error("Steamm lending market type not supported");
|
|
6338
|
+
}
|
|
6339
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6340
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6341
|
+
}
|
|
6342
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6343
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6344
|
+
}
|
|
6345
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6346
|
+
throw new Error("Steamm lp token not supported");
|
|
6347
|
+
}
|
|
6348
|
+
if (path.extendedDetails.steammOracleRegistryId == null) {
|
|
6349
|
+
throw new Error("Steamm oracle registry id not supported");
|
|
6350
|
+
}
|
|
6351
|
+
if (path.extendedDetails.steammOracleIndexA == null) {
|
|
6352
|
+
throw new Error("Steamm oracle index a not supported");
|
|
6353
|
+
}
|
|
6354
|
+
if (path.extendedDetails.steammOracleIndexB == null) {
|
|
6355
|
+
throw new Error("Steamm oracle index b not supported");
|
|
6356
|
+
}
|
|
6357
|
+
if (path.extendedDetails.steammOraclePythPriceSeedA == null) {
|
|
6358
|
+
throw new Error("Steamm oracle pyth price seed a not supported");
|
|
6359
|
+
}
|
|
6360
|
+
if (path.extendedDetails.steammOraclePythPriceSeedB == null) {
|
|
6361
|
+
throw new Error("Steamm oracle pyth price seed b not supported");
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6364
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b_v2", from, target] : ["swap_b2a_v2", target, from];
|
|
6365
|
+
const priceSeedA = path.extendedDetails.steammOraclePythPriceSeedA;
|
|
6366
|
+
const priceSeedB = path.extendedDetails.steammOraclePythPriceSeedB;
|
|
6367
|
+
const priceInfoObjectIdA = this.pythPriceIDs.get(priceSeedA);
|
|
6368
|
+
const priceInfoObjectIdB = this.pythPriceIDs.get(priceSeedB);
|
|
6369
|
+
if (!priceInfoObjectIdA || !priceInfoObjectIdB) {
|
|
6370
|
+
throw new Error("Base price info object id or quote price info object id not found");
|
|
6371
|
+
}
|
|
6372
|
+
const oraclePriceUpdateA = txb.moveCall({
|
|
6373
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6374
|
+
typeArguments: [],
|
|
6375
|
+
arguments: [
|
|
6376
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6377
|
+
txb.object(priceInfoObjectIdA),
|
|
6378
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexA),
|
|
6379
|
+
txb.object(CLOCK_ADDRESS)
|
|
6380
|
+
]
|
|
6381
|
+
});
|
|
6382
|
+
const oraclePriceUpdateB = txb.moveCall({
|
|
6383
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6384
|
+
typeArguments: [],
|
|
6385
|
+
arguments: [
|
|
6386
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6387
|
+
txb.object(priceInfoObjectIdB),
|
|
6388
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexB),
|
|
6389
|
+
txb.object(CLOCK_ADDRESS)
|
|
6390
|
+
]
|
|
6391
|
+
});
|
|
6392
|
+
const args = [
|
|
6393
|
+
txb.object(path.id),
|
|
6394
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6395
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6396
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6397
|
+
oraclePriceUpdateA,
|
|
6398
|
+
oraclePriceUpdateB,
|
|
6399
|
+
inputCoin,
|
|
6400
|
+
txb.object(CLOCK_ADDRESS)
|
|
6401
|
+
];
|
|
6402
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6295
6403
|
const res = txb.moveCall({
|
|
6296
|
-
target: `${publishedAt}::
|
|
6404
|
+
target: `${publishedAt}::steamm_omm::${func}`,
|
|
6297
6405
|
typeArguments: [
|
|
6298
6406
|
path.extendedDetails.steammLendingMarketType,
|
|
6299
6407
|
coinAType,
|
|
@@ -6511,6 +6619,35 @@ var HaWAL = class {
|
|
|
6511
6619
|
}
|
|
6512
6620
|
};
|
|
6513
6621
|
|
|
6622
|
+
// src/transaction/momentum.ts
|
|
6623
|
+
var Momentum = class {
|
|
6624
|
+
constructor(env) {
|
|
6625
|
+
if (env !== 0 /* Mainnet */) {
|
|
6626
|
+
throw new Error("Momentum only supported on mainnet");
|
|
6627
|
+
}
|
|
6628
|
+
this.version = "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a";
|
|
6629
|
+
}
|
|
6630
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6631
|
+
return __async(this, null, function* () {
|
|
6632
|
+
const { direction, from, target } = path;
|
|
6633
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6634
|
+
const args = [
|
|
6635
|
+
txb.object(path.id),
|
|
6636
|
+
inputCoin,
|
|
6637
|
+
txb.object(this.version),
|
|
6638
|
+
txb.object(CLOCK_ADDRESS)
|
|
6639
|
+
];
|
|
6640
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6641
|
+
const res = txb.moveCall({
|
|
6642
|
+
target: `${publishedAt}::momentum::${func}`,
|
|
6643
|
+
typeArguments: [coinAType, coinBType],
|
|
6644
|
+
arguments: args
|
|
6645
|
+
});
|
|
6646
|
+
return res;
|
|
6647
|
+
});
|
|
6648
|
+
}
|
|
6649
|
+
};
|
|
6650
|
+
|
|
6514
6651
|
// src/client.ts
|
|
6515
6652
|
var CETUS = "CETUS";
|
|
6516
6653
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6535,6 +6672,8 @@ var STEAMM = "STEAMM";
|
|
|
6535
6672
|
var METASTABLE = "METASTABLE";
|
|
6536
6673
|
var OBRIC = "OBRIC";
|
|
6537
6674
|
var HAWAL = "HAWAL";
|
|
6675
|
+
var STEAMM_OMM = "STEAMM_OMM";
|
|
6676
|
+
var MOMENTUM = "MOMENTUM";
|
|
6538
6677
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6539
6678
|
function isBuilderRouterSwapParams(params) {
|
|
6540
6679
|
return Array.isArray(params.routers);
|
|
@@ -7056,6 +7195,13 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7056
7195
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
7057
7196
|
}
|
|
7058
7197
|
}
|
|
7198
|
+
publishedAtV2Extend2() {
|
|
7199
|
+
if (this.env === 0 /* Mainnet */) {
|
|
7200
|
+
return "0x0018f7bbbece22f4272ed2281b290f745e5aa69d870f599810a30b4eeffc1a5e";
|
|
7201
|
+
} else {
|
|
7202
|
+
return "0x0";
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7059
7205
|
deepbookv3DeepFeeType() {
|
|
7060
7206
|
if (this.env === 0 /* Mainnet */) {
|
|
7061
7207
|
return "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP";
|
|
@@ -7147,13 +7293,17 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7147
7293
|
case ALPHAFI:
|
|
7148
7294
|
return new Alphafi(this.env);
|
|
7149
7295
|
case STEAMM:
|
|
7150
|
-
return new
|
|
7296
|
+
return new SteammCPMM(this.env);
|
|
7297
|
+
case STEAMM_OMM:
|
|
7298
|
+
return new SteammOmm(this.env, pythPriceIDs);
|
|
7151
7299
|
case METASTABLE:
|
|
7152
7300
|
return new Metastable(this.env, pythPriceIDs);
|
|
7153
7301
|
case OBRIC:
|
|
7154
7302
|
return new Obric(this.env, pythPriceIDs);
|
|
7155
7303
|
case HAWAL:
|
|
7156
7304
|
return new HaWAL(this.env);
|
|
7305
|
+
case MOMENTUM:
|
|
7306
|
+
return new Momentum(this.env);
|
|
7157
7307
|
default:
|
|
7158
7308
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7159
7309
|
}
|
|
@@ -7247,7 +7397,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7247
7397
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7248
7398
|
}
|
|
7249
7399
|
};
|
|
7250
|
-
var
|
|
7400
|
+
var AggregatorClient25 = _AggregatorClient;
|
|
7251
7401
|
function findPythPriceIDs(routes) {
|
|
7252
7402
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7253
7403
|
for (const route of routes) {
|
|
@@ -7274,6 +7424,14 @@ function findPythPriceIDs(routes) {
|
|
|
7274
7424
|
priceIDs.add(path.extendedDetails.obricCoinBPriceSeed);
|
|
7275
7425
|
}
|
|
7276
7426
|
}
|
|
7427
|
+
if (path.provider === STEAMM_OMM) {
|
|
7428
|
+
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedA) {
|
|
7429
|
+
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedA);
|
|
7430
|
+
}
|
|
7431
|
+
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedB) {
|
|
7432
|
+
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedB);
|
|
7433
|
+
}
|
|
7434
|
+
}
|
|
7277
7435
|
}
|
|
7278
7436
|
}
|
|
7279
7437
|
return Array.from(priceIDs);
|
|
@@ -7302,13 +7460,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7302
7460
|
routes: data.routes.map((route) => {
|
|
7303
7461
|
return {
|
|
7304
7462
|
path: route.path.map((path) => {
|
|
7305
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
7463
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
7306
7464
|
let version;
|
|
7307
7465
|
if (path.provider === AFTERMATH) {
|
|
7308
7466
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
7309
7467
|
}
|
|
7310
7468
|
let extendedDetails;
|
|
7311
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider ===
|
|
7469
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === METASTABLE || path.provider === OBRIC || path.provider === STEAMM || path.provider === STEAMM_OMM) {
|
|
7312
7470
|
extendedDetails = {
|
|
7313
7471
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
7314
7472
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -7324,17 +7482,22 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7324
7482
|
steammBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steamm_btoken_a_type,
|
|
7325
7483
|
steammBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steamm_btoken_b_type,
|
|
7326
7484
|
steammLPToken: (_n = path.extended_details) == null ? void 0 : _n.steamm_lp_token_type,
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7485
|
+
steammOracleRegistryId: (_o = path.extended_details) == null ? void 0 : _o.steamm_oracle_registry_id,
|
|
7486
|
+
steammOracleIndexA: (_p = path.extended_details) == null ? void 0 : _p.steamm_oracle_index_a,
|
|
7487
|
+
steammOracleIndexB: (_q = path.extended_details) == null ? void 0 : _q.steamm_oracle_index_b,
|
|
7488
|
+
steammOraclePythPriceSeedA: (_r = path.extended_details) == null ? void 0 : _r.steamm_oracle_pyth_price_seed_a,
|
|
7489
|
+
steammOraclePythPriceSeedB: (_s = path.extended_details) == null ? void 0 : _s.steamm_oracle_pyth_price_seed_b,
|
|
7490
|
+
metastablePriceSeed: (_t = path.extended_details) == null ? void 0 : _t.metastable_price_seed,
|
|
7491
|
+
metastableETHPriceSeed: (_u = path.extended_details) == null ? void 0 : _u.metastable_eth_price_seed,
|
|
7492
|
+
metastableWhitelistedAppId: (_v = path.extended_details) == null ? void 0 : _v.metastable_whitelisted_app_id,
|
|
7493
|
+
metastableCreateCapPkgId: (_w = path.extended_details) == null ? void 0 : _w.metastable_create_cap_pkg_id,
|
|
7494
|
+
metastableCreateCapModule: (_x = path.extended_details) == null ? void 0 : _x.metastable_create_cap_module,
|
|
7495
|
+
metastableCreateCapAllTypeParams: (_y = path.extended_details) == null ? void 0 : _y.metastable_create_cap_all_type_params,
|
|
7496
|
+
metastableRegistryId: (_z = path.extended_details) == null ? void 0 : _z.metastable_registry_id,
|
|
7497
|
+
obricCoinAPriceSeed: (_A = path.extended_details) == null ? void 0 : _A.obric_coin_a_price_seed,
|
|
7498
|
+
obricCoinBPriceSeed: (_B = path.extended_details) == null ? void 0 : _B.obric_coin_b_price_seed,
|
|
7499
|
+
obricCoinAPriceId: (_C = path.extended_details) == null ? void 0 : _C.obric_coin_a_price_id,
|
|
7500
|
+
obricCoinBPriceId: (_D = path.extended_details) == null ? void 0 : _D.obric_coin_b_price_id
|
|
7338
7501
|
};
|
|
7339
7502
|
}
|
|
7340
7503
|
return {
|
|
@@ -7363,6 +7526,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7363
7526
|
var CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID;
|
|
7364
7527
|
var AGGREGATOR_V2 = "aggregator_v2";
|
|
7365
7528
|
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
7529
|
+
var AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2";
|
|
7366
7530
|
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
7367
7531
|
var _a;
|
|
7368
7532
|
if (packages instanceof Map) {
|
|
@@ -7377,6 +7541,13 @@ function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt, package
|
|
|
7377
7541
|
}
|
|
7378
7542
|
return aggregatorV2ExtendPublishedAt;
|
|
7379
7543
|
}
|
|
7544
|
+
function getAggregatorV2Extend2PublishedAt(aggregatorV2Extend2PublishedAt, packages) {
|
|
7545
|
+
var _a;
|
|
7546
|
+
if (packages instanceof Map) {
|
|
7547
|
+
return (_a = packages.get(AGGREGATOR_V2_EXTEND2)) != null ? _a : aggregatorV2Extend2PublishedAt;
|
|
7548
|
+
}
|
|
7549
|
+
return aggregatorV2Extend2PublishedAt;
|
|
7550
|
+
}
|
|
7380
7551
|
|
|
7381
7552
|
// src/utils/msafe.ts
|
|
7382
7553
|
var import_bn6 = __toESM(require_bn());
|
|
@@ -7423,7 +7594,7 @@ function processEndpoint(endpoint) {
|
|
|
7423
7594
|
|
|
7424
7595
|
// src/api.ts
|
|
7425
7596
|
var import_bn7 = __toESM(require_bn());
|
|
7426
|
-
var SDK_VERSION =
|
|
7597
|
+
var SDK_VERSION = 1000800;
|
|
7427
7598
|
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7428
7599
|
return __async(this, null, function* () {
|
|
7429
7600
|
let response;
|
|
@@ -7470,6 +7641,7 @@ function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceive
|
|
|
7470
7641
|
};
|
|
7471
7642
|
}
|
|
7472
7643
|
if (data.data != null) {
|
|
7644
|
+
console.log("data: ", JSON.stringify(data.data, null, 2));
|
|
7473
7645
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
7474
7646
|
if (overlayFee > 0 && overlayFeeReceiver !== "0x0") {
|
|
7475
7647
|
if (params.byAmountIn) {
|
|
@@ -7627,4 +7799,4 @@ decimal.js/decimal.mjs:
|
|
|
7627
7799
|
*)
|
|
7628
7800
|
*/
|
|
7629
7801
|
|
|
7630
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI,
|
|
7802
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALPHAFI, AggregatorClient25 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, HAWAL, KRIYA, KRIYAV3, METASTABLE, MOMENTUM, OBRIC, ONE, SCALLOP, SPRINGSUI, STEAMM, STEAMM_OMM, 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, getAggregatorV2Extend2PublishedAt, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|