@cetusprotocol/aggregator-sdk 0.9.1 → 0.10.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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +119 -7
- package/dist/index.mjs +118 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -86,6 +86,7 @@ declare const OBRIC = "OBRIC";
|
|
|
86
86
|
declare const HAWAL = "HAWAL";
|
|
87
87
|
declare const STEAMM_OMM = "STEAMM_OMM";
|
|
88
88
|
declare const MOMENTUM = "MOMENTUM";
|
|
89
|
+
declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
|
|
89
90
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
90
91
|
type BuildRouterSwapParams = {
|
|
91
92
|
routers: Router[];
|
|
@@ -350,4 +351,4 @@ declare enum Env {
|
|
|
350
351
|
Testnet = 1
|
|
351
352
|
}
|
|
352
353
|
|
|
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 };
|
|
354
|
+
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, STEAMM_OMM_V2, 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
|
@@ -86,6 +86,7 @@ declare const OBRIC = "OBRIC";
|
|
|
86
86
|
declare const HAWAL = "HAWAL";
|
|
87
87
|
declare const STEAMM_OMM = "STEAMM_OMM";
|
|
88
88
|
declare const MOMENTUM = "MOMENTUM";
|
|
89
|
+
declare const STEAMM_OMM_V2 = "STEAMM_OMM_V2";
|
|
89
90
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
90
91
|
type BuildRouterSwapParams = {
|
|
91
92
|
routers: Router[];
|
|
@@ -350,4 +351,4 @@ declare enum Env {
|
|
|
350
351
|
Testnet = 1
|
|
351
352
|
}
|
|
352
353
|
|
|
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 };
|
|
354
|
+
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, STEAMM_OMM_V2, 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
|
@@ -6312,7 +6312,7 @@ var SteammCPMM = class {
|
|
|
6312
6312
|
var SteammOmm = class {
|
|
6313
6313
|
constructor(env, pythPriceIDs) {
|
|
6314
6314
|
if (env !== 0 /* Mainnet */) {
|
|
6315
|
-
throw new Error("Steamm only supported on mainnet");
|
|
6315
|
+
throw new Error("Steamm omm only supported on mainnet");
|
|
6316
6316
|
}
|
|
6317
6317
|
this.pythPriceIDs = pythPriceIDs;
|
|
6318
6318
|
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
@@ -6647,6 +6647,114 @@ var Momentum = class {
|
|
|
6647
6647
|
}
|
|
6648
6648
|
};
|
|
6649
6649
|
|
|
6650
|
+
// src/transaction/steamm_omm_v2.ts
|
|
6651
|
+
var SteammOmmV2 = class {
|
|
6652
|
+
constructor(env, pythPriceIDs) {
|
|
6653
|
+
if (env !== 0 /* Mainnet */) {
|
|
6654
|
+
throw new Error("Steamm omm v2 only supported on mainnet");
|
|
6655
|
+
}
|
|
6656
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6657
|
+
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
6658
|
+
}
|
|
6659
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6660
|
+
return __async(this, null, function* () {
|
|
6661
|
+
const { direction, from, target } = path;
|
|
6662
|
+
if (path.extendedDetails == null) {
|
|
6663
|
+
throw new Error("Extended details not supported");
|
|
6664
|
+
} else {
|
|
6665
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6666
|
+
throw new Error("Steamm bank a type not supported");
|
|
6667
|
+
}
|
|
6668
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6669
|
+
throw new Error("Steamm bank b type not supported");
|
|
6670
|
+
}
|
|
6671
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6672
|
+
throw new Error("Steamm lending market not supported");
|
|
6673
|
+
}
|
|
6674
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6675
|
+
throw new Error("Steamm lending market type not supported");
|
|
6676
|
+
}
|
|
6677
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6678
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6679
|
+
}
|
|
6680
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6681
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6682
|
+
}
|
|
6683
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6684
|
+
throw new Error("Steamm lp token not supported");
|
|
6685
|
+
}
|
|
6686
|
+
if (path.extendedDetails.steammOracleRegistryId == null) {
|
|
6687
|
+
throw new Error("Steamm oracle registry id not supported");
|
|
6688
|
+
}
|
|
6689
|
+
if (path.extendedDetails.steammOracleIndexA == null) {
|
|
6690
|
+
throw new Error("Steamm oracle index a not supported");
|
|
6691
|
+
}
|
|
6692
|
+
if (path.extendedDetails.steammOracleIndexB == null) {
|
|
6693
|
+
throw new Error("Steamm oracle index b not supported");
|
|
6694
|
+
}
|
|
6695
|
+
if (path.extendedDetails.steammOraclePythPriceSeedA == null) {
|
|
6696
|
+
throw new Error("Steamm oracle pyth price seed a not supported");
|
|
6697
|
+
}
|
|
6698
|
+
if (path.extendedDetails.steammOraclePythPriceSeedB == null) {
|
|
6699
|
+
throw new Error("Steamm oracle pyth price seed b not supported");
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6702
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6703
|
+
const priceSeedA = path.extendedDetails.steammOraclePythPriceSeedA;
|
|
6704
|
+
const priceSeedB = path.extendedDetails.steammOraclePythPriceSeedB;
|
|
6705
|
+
const priceInfoObjectIdA = this.pythPriceIDs.get(priceSeedA);
|
|
6706
|
+
const priceInfoObjectIdB = this.pythPriceIDs.get(priceSeedB);
|
|
6707
|
+
if (!priceInfoObjectIdA || !priceInfoObjectIdB) {
|
|
6708
|
+
throw new Error("Base price info object id or quote price info object id not found");
|
|
6709
|
+
}
|
|
6710
|
+
const oraclePriceUpdateA = txb.moveCall({
|
|
6711
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6712
|
+
typeArguments: [],
|
|
6713
|
+
arguments: [
|
|
6714
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6715
|
+
txb.object(priceInfoObjectIdA),
|
|
6716
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexA),
|
|
6717
|
+
txb.object(CLOCK_ADDRESS)
|
|
6718
|
+
]
|
|
6719
|
+
});
|
|
6720
|
+
const oraclePriceUpdateB = txb.moveCall({
|
|
6721
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6722
|
+
typeArguments: [],
|
|
6723
|
+
arguments: [
|
|
6724
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6725
|
+
txb.object(priceInfoObjectIdB),
|
|
6726
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexB),
|
|
6727
|
+
txb.object(CLOCK_ADDRESS)
|
|
6728
|
+
]
|
|
6729
|
+
});
|
|
6730
|
+
const args = [
|
|
6731
|
+
txb.object(path.id),
|
|
6732
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6733
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6734
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6735
|
+
oraclePriceUpdateA,
|
|
6736
|
+
oraclePriceUpdateB,
|
|
6737
|
+
inputCoin,
|
|
6738
|
+
txb.object(CLOCK_ADDRESS)
|
|
6739
|
+
];
|
|
6740
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6741
|
+
const res = txb.moveCall({
|
|
6742
|
+
target: `${publishedAt}::steamm_omm_v2::${func}`,
|
|
6743
|
+
typeArguments: [
|
|
6744
|
+
path.extendedDetails.steammLendingMarketType,
|
|
6745
|
+
coinAType,
|
|
6746
|
+
coinBType,
|
|
6747
|
+
path.extendedDetails.steammBCoinAType,
|
|
6748
|
+
path.extendedDetails.steammBCoinBType,
|
|
6749
|
+
path.extendedDetails.steammLPToken
|
|
6750
|
+
],
|
|
6751
|
+
arguments: args
|
|
6752
|
+
});
|
|
6753
|
+
return res;
|
|
6754
|
+
});
|
|
6755
|
+
}
|
|
6756
|
+
};
|
|
6757
|
+
|
|
6650
6758
|
// src/client.ts
|
|
6651
6759
|
var CETUS = "CETUS";
|
|
6652
6760
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6673,6 +6781,7 @@ var OBRIC = "OBRIC";
|
|
|
6673
6781
|
var HAWAL = "HAWAL";
|
|
6674
6782
|
var STEAMM_OMM = "STEAMM_OMM";
|
|
6675
6783
|
var MOMENTUM = "MOMENTUM";
|
|
6784
|
+
var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
|
|
6676
6785
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6677
6786
|
function isBuilderRouterSwapParams(params) {
|
|
6678
6787
|
return Array.isArray(params.routers);
|
|
@@ -7196,7 +7305,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7196
7305
|
}
|
|
7197
7306
|
publishedAtV2Extend2() {
|
|
7198
7307
|
if (this.env === 0 /* Mainnet */) {
|
|
7199
|
-
return "
|
|
7308
|
+
return "0xed2b71968fb6b74c2161bad4c98561c28c69ce82df2cb3707c3b8bc947f2162d";
|
|
7200
7309
|
} else {
|
|
7201
7310
|
return "0x0";
|
|
7202
7311
|
}
|
|
@@ -7303,6 +7412,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7303
7412
|
return new HaWAL(this.env);
|
|
7304
7413
|
case MOMENTUM:
|
|
7305
7414
|
return new Momentum(this.env);
|
|
7415
|
+
case STEAMM_OMM_V2:
|
|
7416
|
+
return new SteammOmmV2(this.env, pythPriceIDs);
|
|
7306
7417
|
default:
|
|
7307
7418
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7308
7419
|
}
|
|
@@ -7396,7 +7507,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7396
7507
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7397
7508
|
}
|
|
7398
7509
|
};
|
|
7399
|
-
var
|
|
7510
|
+
var AggregatorClient26 = _AggregatorClient;
|
|
7400
7511
|
function findPythPriceIDs(routes) {
|
|
7401
7512
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7402
7513
|
for (const route of routes) {
|
|
@@ -7423,7 +7534,7 @@ function findPythPriceIDs(routes) {
|
|
|
7423
7534
|
priceIDs.add(path.extendedDetails.obricCoinBPriceSeed);
|
|
7424
7535
|
}
|
|
7425
7536
|
}
|
|
7426
|
-
if (path.provider === STEAMM_OMM) {
|
|
7537
|
+
if (path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2) {
|
|
7427
7538
|
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedA) {
|
|
7428
7539
|
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedA);
|
|
7429
7540
|
}
|
|
@@ -7465,7 +7576,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7465
7576
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
7466
7577
|
}
|
|
7467
7578
|
let extendedDetails;
|
|
7468
|
-
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) {
|
|
7579
|
+
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 || path.provider === STEAMM_OMM_V2) {
|
|
7469
7580
|
extendedDetails = {
|
|
7470
7581
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
7471
7582
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -7593,7 +7704,7 @@ function processEndpoint(endpoint) {
|
|
|
7593
7704
|
|
|
7594
7705
|
// src/api.ts
|
|
7595
7706
|
var import_bn7 = __toESM(require_bn());
|
|
7596
|
-
var SDK_VERSION =
|
|
7707
|
+
var SDK_VERSION = 1001e3;
|
|
7597
7708
|
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7598
7709
|
return __async(this, null, function* () {
|
|
7599
7710
|
let response;
|
|
@@ -7803,7 +7914,7 @@ exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
|
7803
7914
|
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7804
7915
|
exports.AGGREGATOR_V2_EXTEND2 = AGGREGATOR_V2_EXTEND2;
|
|
7805
7916
|
exports.ALPHAFI = ALPHAFI;
|
|
7806
|
-
exports.AggregatorClient =
|
|
7917
|
+
exports.AggregatorClient = AggregatorClient26;
|
|
7807
7918
|
exports.BLUEFIN = BLUEFIN;
|
|
7808
7919
|
exports.BLUEMOVE = BLUEMOVE;
|
|
7809
7920
|
exports.CETUS = CETUS;
|
|
@@ -7827,6 +7938,7 @@ exports.SCALLOP = SCALLOP;
|
|
|
7827
7938
|
exports.SPRINGSUI = SPRINGSUI;
|
|
7828
7939
|
exports.STEAMM = STEAMM;
|
|
7829
7940
|
exports.STEAMM_OMM = STEAMM_OMM;
|
|
7941
|
+
exports.STEAMM_OMM_V2 = STEAMM_OMM_V2;
|
|
7830
7942
|
exports.SUILEND = SUILEND;
|
|
7831
7943
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
7832
7944
|
exports.TURBOS = TURBOS;
|
package/dist/index.mjs
CHANGED
|
@@ -6310,7 +6310,7 @@ var SteammCPMM = class {
|
|
|
6310
6310
|
var SteammOmm = class {
|
|
6311
6311
|
constructor(env, pythPriceIDs) {
|
|
6312
6312
|
if (env !== 0 /* Mainnet */) {
|
|
6313
|
-
throw new Error("Steamm only supported on mainnet");
|
|
6313
|
+
throw new Error("Steamm omm only supported on mainnet");
|
|
6314
6314
|
}
|
|
6315
6315
|
this.pythPriceIDs = pythPriceIDs;
|
|
6316
6316
|
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
@@ -6645,6 +6645,114 @@ var Momentum = class {
|
|
|
6645
6645
|
}
|
|
6646
6646
|
};
|
|
6647
6647
|
|
|
6648
|
+
// src/transaction/steamm_omm_v2.ts
|
|
6649
|
+
var SteammOmmV2 = class {
|
|
6650
|
+
constructor(env, pythPriceIDs) {
|
|
6651
|
+
if (env !== 0 /* Mainnet */) {
|
|
6652
|
+
throw new Error("Steamm omm v2 only supported on mainnet");
|
|
6653
|
+
}
|
|
6654
|
+
this.pythPriceIDs = pythPriceIDs;
|
|
6655
|
+
this.oraclePackageId = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b";
|
|
6656
|
+
}
|
|
6657
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6658
|
+
return __async(this, null, function* () {
|
|
6659
|
+
const { direction, from, target } = path;
|
|
6660
|
+
if (path.extendedDetails == null) {
|
|
6661
|
+
throw new Error("Extended details not supported");
|
|
6662
|
+
} else {
|
|
6663
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6664
|
+
throw new Error("Steamm bank a type not supported");
|
|
6665
|
+
}
|
|
6666
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6667
|
+
throw new Error("Steamm bank b type not supported");
|
|
6668
|
+
}
|
|
6669
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6670
|
+
throw new Error("Steamm lending market not supported");
|
|
6671
|
+
}
|
|
6672
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6673
|
+
throw new Error("Steamm lending market type not supported");
|
|
6674
|
+
}
|
|
6675
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6676
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6677
|
+
}
|
|
6678
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6679
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6680
|
+
}
|
|
6681
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6682
|
+
throw new Error("Steamm lp token not supported");
|
|
6683
|
+
}
|
|
6684
|
+
if (path.extendedDetails.steammOracleRegistryId == null) {
|
|
6685
|
+
throw new Error("Steamm oracle registry id not supported");
|
|
6686
|
+
}
|
|
6687
|
+
if (path.extendedDetails.steammOracleIndexA == null) {
|
|
6688
|
+
throw new Error("Steamm oracle index a not supported");
|
|
6689
|
+
}
|
|
6690
|
+
if (path.extendedDetails.steammOracleIndexB == null) {
|
|
6691
|
+
throw new Error("Steamm oracle index b not supported");
|
|
6692
|
+
}
|
|
6693
|
+
if (path.extendedDetails.steammOraclePythPriceSeedA == null) {
|
|
6694
|
+
throw new Error("Steamm oracle pyth price seed a not supported");
|
|
6695
|
+
}
|
|
6696
|
+
if (path.extendedDetails.steammOraclePythPriceSeedB == null) {
|
|
6697
|
+
throw new Error("Steamm oracle pyth price seed b not supported");
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6701
|
+
const priceSeedA = path.extendedDetails.steammOraclePythPriceSeedA;
|
|
6702
|
+
const priceSeedB = path.extendedDetails.steammOraclePythPriceSeedB;
|
|
6703
|
+
const priceInfoObjectIdA = this.pythPriceIDs.get(priceSeedA);
|
|
6704
|
+
const priceInfoObjectIdB = this.pythPriceIDs.get(priceSeedB);
|
|
6705
|
+
if (!priceInfoObjectIdA || !priceInfoObjectIdB) {
|
|
6706
|
+
throw new Error("Base price info object id or quote price info object id not found");
|
|
6707
|
+
}
|
|
6708
|
+
const oraclePriceUpdateA = txb.moveCall({
|
|
6709
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6710
|
+
typeArguments: [],
|
|
6711
|
+
arguments: [
|
|
6712
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6713
|
+
txb.object(priceInfoObjectIdA),
|
|
6714
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexA),
|
|
6715
|
+
txb.object(CLOCK_ADDRESS)
|
|
6716
|
+
]
|
|
6717
|
+
});
|
|
6718
|
+
const oraclePriceUpdateB = txb.moveCall({
|
|
6719
|
+
target: `${this.oraclePackageId}::oracles::get_pyth_price`,
|
|
6720
|
+
typeArguments: [],
|
|
6721
|
+
arguments: [
|
|
6722
|
+
txb.object(path.extendedDetails.steammOracleRegistryId),
|
|
6723
|
+
txb.object(priceInfoObjectIdB),
|
|
6724
|
+
txb.pure.u64(path.extendedDetails.steammOracleIndexB),
|
|
6725
|
+
txb.object(CLOCK_ADDRESS)
|
|
6726
|
+
]
|
|
6727
|
+
});
|
|
6728
|
+
const args = [
|
|
6729
|
+
txb.object(path.id),
|
|
6730
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6731
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6732
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6733
|
+
oraclePriceUpdateA,
|
|
6734
|
+
oraclePriceUpdateB,
|
|
6735
|
+
inputCoin,
|
|
6736
|
+
txb.object(CLOCK_ADDRESS)
|
|
6737
|
+
];
|
|
6738
|
+
const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages);
|
|
6739
|
+
const res = txb.moveCall({
|
|
6740
|
+
target: `${publishedAt}::steamm_omm_v2::${func}`,
|
|
6741
|
+
typeArguments: [
|
|
6742
|
+
path.extendedDetails.steammLendingMarketType,
|
|
6743
|
+
coinAType,
|
|
6744
|
+
coinBType,
|
|
6745
|
+
path.extendedDetails.steammBCoinAType,
|
|
6746
|
+
path.extendedDetails.steammBCoinBType,
|
|
6747
|
+
path.extendedDetails.steammLPToken
|
|
6748
|
+
],
|
|
6749
|
+
arguments: args
|
|
6750
|
+
});
|
|
6751
|
+
return res;
|
|
6752
|
+
});
|
|
6753
|
+
}
|
|
6754
|
+
};
|
|
6755
|
+
|
|
6648
6756
|
// src/client.ts
|
|
6649
6757
|
var CETUS = "CETUS";
|
|
6650
6758
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6671,6 +6779,7 @@ var OBRIC = "OBRIC";
|
|
|
6671
6779
|
var HAWAL = "HAWAL";
|
|
6672
6780
|
var STEAMM_OMM = "STEAMM_OMM";
|
|
6673
6781
|
var MOMENTUM = "MOMENTUM";
|
|
6782
|
+
var STEAMM_OMM_V2 = "STEAMM_OMM_V2";
|
|
6674
6783
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6675
6784
|
function isBuilderRouterSwapParams(params) {
|
|
6676
6785
|
return Array.isArray(params.routers);
|
|
@@ -7194,7 +7303,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7194
7303
|
}
|
|
7195
7304
|
publishedAtV2Extend2() {
|
|
7196
7305
|
if (this.env === 0 /* Mainnet */) {
|
|
7197
|
-
return "
|
|
7306
|
+
return "0xed2b71968fb6b74c2161bad4c98561c28c69ce82df2cb3707c3b8bc947f2162d";
|
|
7198
7307
|
} else {
|
|
7199
7308
|
return "0x0";
|
|
7200
7309
|
}
|
|
@@ -7301,6 +7410,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
7301
7410
|
return new HaWAL(this.env);
|
|
7302
7411
|
case MOMENTUM:
|
|
7303
7412
|
return new Momentum(this.env);
|
|
7413
|
+
case STEAMM_OMM_V2:
|
|
7414
|
+
return new SteammOmmV2(this.env, pythPriceIDs);
|
|
7304
7415
|
default:
|
|
7305
7416
|
throw new Error(`Unsupported dex ${provider}`);
|
|
7306
7417
|
}
|
|
@@ -7394,7 +7505,7 @@ _AggregatorClient.CONFIG = {
|
|
|
7394
7505
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
7395
7506
|
}
|
|
7396
7507
|
};
|
|
7397
|
-
var
|
|
7508
|
+
var AggregatorClient26 = _AggregatorClient;
|
|
7398
7509
|
function findPythPriceIDs(routes) {
|
|
7399
7510
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
7400
7511
|
for (const route of routes) {
|
|
@@ -7421,7 +7532,7 @@ function findPythPriceIDs(routes) {
|
|
|
7421
7532
|
priceIDs.add(path.extendedDetails.obricCoinBPriceSeed);
|
|
7422
7533
|
}
|
|
7423
7534
|
}
|
|
7424
|
-
if (path.provider === STEAMM_OMM) {
|
|
7535
|
+
if (path.provider === STEAMM_OMM || path.provider === STEAMM_OMM_V2) {
|
|
7425
7536
|
if (path.extendedDetails && path.extendedDetails.steammOraclePythPriceSeedA) {
|
|
7426
7537
|
priceIDs.add(path.extendedDetails.steammOraclePythPriceSeedA);
|
|
7427
7538
|
}
|
|
@@ -7463,7 +7574,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
7463
7574
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
7464
7575
|
}
|
|
7465
7576
|
let extendedDetails;
|
|
7466
|
-
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) {
|
|
7577
|
+
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 || path.provider === STEAMM_OMM_V2) {
|
|
7467
7578
|
extendedDetails = {
|
|
7468
7579
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
7469
7580
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -7591,7 +7702,7 @@ function processEndpoint(endpoint) {
|
|
|
7591
7702
|
|
|
7592
7703
|
// src/api.ts
|
|
7593
7704
|
var import_bn7 = __toESM(require_bn());
|
|
7594
|
-
var SDK_VERSION =
|
|
7705
|
+
var SDK_VERSION = 1001e3;
|
|
7595
7706
|
function getRouterResult(endpoint, apiKey, params, overlayFee, overlayFeeReceiver) {
|
|
7596
7707
|
return __async(this, null, function* () {
|
|
7597
7708
|
let response;
|
|
@@ -7795,4 +7906,4 @@ decimal.js/decimal.mjs:
|
|
|
7795
7906
|
*)
|
|
7796
7907
|
*/
|
|
7797
7908
|
|
|
7798
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALPHAFI,
|
|
7909
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, AGGREGATOR_V2_EXTEND2, ALPHAFI, AggregatorClient26 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, STEAMM_OMM_V2, 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 };
|