@cetusprotocol/aggregator-sdk 0.3.22 → 0.3.24
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 +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +86 -16
- package/dist/index.mjs +86 -17
- package/dist/src/api.d.ts +7 -0
- package/dist/src/client.d.ts +1 -0
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/transaction/steamm.d.ts +6 -0
- package/dist/tests/router/steammfe.test.d.ts +2 -0
- package/package.json +1 -1
- package/src/api.ts +16 -1
- package/src/client.ts +17 -6
- package/src/transaction/flowx_v2.ts +0 -1
- package/src/transaction/index.ts +2 -2
- package/src/transaction/steamm.ts +77 -0
- package/src/transaction/swap.ts +2 -7
- package/tests/router/steammfe.test.ts +124 -0
package/dist/index.d.mts
CHANGED
|
@@ -79,6 +79,7 @@ declare const BLUEFIN = "BLUEFIN";
|
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
81
|
declare const SPRINGSUI = "SPRINGSUI";
|
|
82
|
+
declare const STEAMM = "STEAMM";
|
|
82
83
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
83
84
|
type BuildRouterSwapParams = {
|
|
84
85
|
routers: Router[];
|
|
@@ -157,7 +158,7 @@ declare class AggregatorClient {
|
|
|
157
158
|
declare function findPythPriceIDs(routes: Router[]): string[];
|
|
158
159
|
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
159
160
|
|
|
160
|
-
declare const CLOCK_ADDRESS
|
|
161
|
+
declare const CLOCK_ADDRESS: string;
|
|
161
162
|
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
162
163
|
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
163
164
|
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
@@ -235,6 +236,13 @@ type ExtendedDetails = {
|
|
|
235
236
|
scallopScoinTreasury?: string;
|
|
236
237
|
haedalPmmBasePriceSeed?: string;
|
|
237
238
|
haedalPmmQuotePriceSeed?: string;
|
|
239
|
+
steammBankA?: string;
|
|
240
|
+
steammBankB?: string;
|
|
241
|
+
steammLendingMarket?: string;
|
|
242
|
+
steammLendingMarketType?: string;
|
|
243
|
+
steammBCoinAType?: string;
|
|
244
|
+
steammBCoinBType?: string;
|
|
245
|
+
steammLPToken?: string;
|
|
238
246
|
};
|
|
239
247
|
type Path = {
|
|
240
248
|
id: string;
|
|
@@ -298,4 +306,4 @@ declare enum Env {
|
|
|
298
306
|
Testnet = 1
|
|
299
307
|
}
|
|
300
308
|
|
|
301
|
-
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, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ declare const BLUEFIN = "BLUEFIN";
|
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
80
|
declare const ALPHAFI = "ALPHAFI";
|
|
81
81
|
declare const SPRINGSUI = "SPRINGSUI";
|
|
82
|
+
declare const STEAMM = "STEAMM";
|
|
82
83
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
83
84
|
type BuildRouterSwapParams = {
|
|
84
85
|
routers: Router[];
|
|
@@ -157,7 +158,7 @@ declare class AggregatorClient {
|
|
|
157
158
|
declare function findPythPriceIDs(routes: Router[]): string[];
|
|
158
159
|
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
159
160
|
|
|
160
|
-
declare const CLOCK_ADDRESS
|
|
161
|
+
declare const CLOCK_ADDRESS: string;
|
|
161
162
|
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
162
163
|
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
163
164
|
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
@@ -235,6 +236,13 @@ type ExtendedDetails = {
|
|
|
235
236
|
scallopScoinTreasury?: string;
|
|
236
237
|
haedalPmmBasePriceSeed?: string;
|
|
237
238
|
haedalPmmQuotePriceSeed?: string;
|
|
239
|
+
steammBankA?: string;
|
|
240
|
+
steammBankB?: string;
|
|
241
|
+
steammLendingMarket?: string;
|
|
242
|
+
steammLendingMarketType?: string;
|
|
243
|
+
steammBCoinAType?: string;
|
|
244
|
+
steammBCoinBType?: string;
|
|
245
|
+
steammLPToken?: string;
|
|
238
246
|
};
|
|
239
247
|
type Path = {
|
|
240
248
|
id: string;
|
|
@@ -298,4 +306,4 @@ declare enum Env {
|
|
|
298
306
|
Testnet = 1
|
|
299
307
|
}
|
|
300
308
|
|
|
301
|
-
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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5803,11 +5803,10 @@ function swapInPools(client, params, sender, env) {
|
|
|
5803
5803
|
const targetCoin = completionCoin(target);
|
|
5804
5804
|
const tx = new transactions.Transaction();
|
|
5805
5805
|
const direction = compareCoins(fromCoin, targetCoin);
|
|
5806
|
-
const integratePublishedAt = env === 0 /* Mainnet */ ? "
|
|
5806
|
+
const integratePublishedAt = env === 0 /* Mainnet */ ? "0x2d8c2e0fc6dd25b0214b3fa747e0fd27fd54608142cd2e4f64c1cd350cc4add4" : "0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6";
|
|
5807
5807
|
const coinA = direction ? fromCoin : targetCoin;
|
|
5808
5808
|
const coinB = direction ? targetCoin : fromCoin;
|
|
5809
5809
|
const typeArguments = [coinA, coinB];
|
|
5810
|
-
console.log("typeArguments", typeArguments, integratePublishedAt);
|
|
5811
5810
|
for (let i = 0; i < pools.length; i++) {
|
|
5812
5811
|
const args = [
|
|
5813
5812
|
tx.object(pools[i]),
|
|
@@ -5827,7 +5826,6 @@ function swapInPools(client, params, sender, env) {
|
|
|
5827
5826
|
"InvalidWallet" /* InvalidWallet */
|
|
5828
5827
|
);
|
|
5829
5828
|
}
|
|
5830
|
-
printTransaction(tx);
|
|
5831
5829
|
const simulateRes = yield client.devInspectTransactionBlock({
|
|
5832
5830
|
transactionBlock: tx,
|
|
5833
5831
|
sender
|
|
@@ -5869,7 +5867,6 @@ function swapInPools(client, params, sender, env) {
|
|
|
5869
5867
|
}
|
|
5870
5868
|
}
|
|
5871
5869
|
const event = valueData[tempIndex].parsedJson.data;
|
|
5872
|
-
console.log("event", JSON.stringify(event, null, 2));
|
|
5873
5870
|
const currentSqrtPrice = event.step_results[0].current_sqrt_price;
|
|
5874
5871
|
const [decimalA, decimalB] = yield Promise.all([
|
|
5875
5872
|
client.getCoinMetadata({ coinType: coinA }).then((metadata) => metadata == null ? void 0 : metadata.decimals),
|
|
@@ -6249,6 +6246,70 @@ var Alphafi = class {
|
|
|
6249
6246
|
});
|
|
6250
6247
|
}
|
|
6251
6248
|
};
|
|
6249
|
+
|
|
6250
|
+
// src/transaction/steamm.ts
|
|
6251
|
+
var Steamm = class {
|
|
6252
|
+
constructor(env) {
|
|
6253
|
+
if (env !== 0 /* Mainnet */) {
|
|
6254
|
+
throw new Error("Steamm only supported on mainnet");
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6257
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6258
|
+
return __async(this, null, function* () {
|
|
6259
|
+
const { direction, from, target } = path;
|
|
6260
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6261
|
+
if (path.extendedDetails == null) {
|
|
6262
|
+
throw new Error("Extended details not supported");
|
|
6263
|
+
} else {
|
|
6264
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6265
|
+
throw new Error("Steamm bank a type not supported");
|
|
6266
|
+
}
|
|
6267
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6268
|
+
throw new Error("Steamm bank b type not supported");
|
|
6269
|
+
}
|
|
6270
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6271
|
+
throw new Error("Steamm lending market not supported");
|
|
6272
|
+
}
|
|
6273
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6274
|
+
throw new Error("Steamm lending market type not supported");
|
|
6275
|
+
}
|
|
6276
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6277
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6278
|
+
}
|
|
6279
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6280
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6281
|
+
}
|
|
6282
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6283
|
+
throw new Error("Steamm lp token not supported");
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6286
|
+
const args = [
|
|
6287
|
+
txb.object(path.id),
|
|
6288
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6289
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6290
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6291
|
+
inputCoin,
|
|
6292
|
+
txb.object(CLOCK_ADDRESS)
|
|
6293
|
+
];
|
|
6294
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6295
|
+
const res = txb.moveCall({
|
|
6296
|
+
target: `${publishedAt}::steamm::${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/client.ts
|
|
6252
6313
|
var CETUS = "CETUS";
|
|
6253
6314
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
6254
6315
|
var KRIYA = "KRIYA";
|
|
@@ -6268,6 +6329,7 @@ var BLUEFIN = "BLUEFIN";
|
|
|
6268
6329
|
var HAEDALPMM = "HAEDALPMM";
|
|
6269
6330
|
var ALPHAFI = "ALPHAFI";
|
|
6270
6331
|
var SPRINGSUI = "SPRINGSUI";
|
|
6332
|
+
var STEAMM = "STEAMM";
|
|
6271
6333
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6272
6334
|
function isBuilderRouterSwapParams(params) {
|
|
6273
6335
|
return Array.isArray(params.routers);
|
|
@@ -6473,7 +6535,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6473
6535
|
slippage
|
|
6474
6536
|
);
|
|
6475
6537
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6476
|
-
console.log("packages11", packages);
|
|
6477
6538
|
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6478
6539
|
this.publishedAtV2(),
|
|
6479
6540
|
packages
|
|
@@ -6606,7 +6667,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6606
6667
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6607
6668
|
publishedAtV2() {
|
|
6608
6669
|
if (this.env === 0 /* Mainnet */) {
|
|
6609
|
-
return "
|
|
6670
|
+
return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce";
|
|
6610
6671
|
} else {
|
|
6611
6672
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6612
6673
|
}
|
|
@@ -6614,7 +6675,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6614
6675
|
// Include deepbookv3, scallop, bluefin
|
|
6615
6676
|
publishedAtV2Extend() {
|
|
6616
6677
|
if (this.env === 0 /* Mainnet */) {
|
|
6617
|
-
return "
|
|
6678
|
+
return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed";
|
|
6618
6679
|
} else {
|
|
6619
6680
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6620
6681
|
}
|
|
@@ -6691,6 +6752,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6691
6752
|
return new HaedalPmm(this.env, pythPriceIDs);
|
|
6692
6753
|
case ALPHAFI:
|
|
6693
6754
|
return new Alphafi(this.env);
|
|
6755
|
+
case STEAMM:
|
|
6756
|
+
return new Steamm(this.env);
|
|
6694
6757
|
default:
|
|
6695
6758
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6696
6759
|
}
|
|
@@ -6798,7 +6861,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6798
6861
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
6799
6862
|
}
|
|
6800
6863
|
};
|
|
6801
|
-
var
|
|
6864
|
+
var AggregatorClient20 = _AggregatorClient;
|
|
6802
6865
|
function findPythPriceIDs(routes) {
|
|
6803
6866
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
6804
6867
|
for (const route of routes) {
|
|
@@ -6837,13 +6900,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6837
6900
|
routes: data.routes.map((route) => {
|
|
6838
6901
|
return {
|
|
6839
6902
|
path: route.path.map((path) => {
|
|
6840
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
6903
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
6841
6904
|
let version;
|
|
6842
6905
|
if (path.provider === AFTERMATH) {
|
|
6843
6906
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6844
6907
|
}
|
|
6845
6908
|
let extendedDetails;
|
|
6846
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM) {
|
|
6909
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
|
|
6847
6910
|
extendedDetails = {
|
|
6848
6911
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6849
6912
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -6851,7 +6914,14 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6851
6914
|
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
|
|
6852
6915
|
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
|
|
6853
6916
|
haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
|
|
6854
|
-
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
|
|
6917
|
+
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed,
|
|
6918
|
+
steammfeBankA: (_h = path.extended_details) == null ? void 0 : _h.steammfe_bank_a,
|
|
6919
|
+
steammfeBankB: (_i = path.extended_details) == null ? void 0 : _i.steammfe_bank_b,
|
|
6920
|
+
steammfeLendingMarket: (_j = path.extended_details) == null ? void 0 : _j.steammfe_lending_market,
|
|
6921
|
+
steammfeLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steammfe_lending_market_type,
|
|
6922
|
+
steammfeBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steammfe_btoken_a_type,
|
|
6923
|
+
steammfeBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steammfe_btoken_b_type,
|
|
6924
|
+
steammfeLPToken: (_n = path.extended_details) == null ? void 0 : _n.steammfe_lp_token_type
|
|
6855
6925
|
};
|
|
6856
6926
|
}
|
|
6857
6927
|
return {
|
|
@@ -6877,9 +6947,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6877
6947
|
};
|
|
6878
6948
|
return routerData;
|
|
6879
6949
|
}
|
|
6880
|
-
|
|
6881
|
-
// src/transaction/index.ts
|
|
6882
|
-
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6950
|
+
var CLOCK_ADDRESS = utils.SUI_CLOCK_OBJECT_ID;
|
|
6883
6951
|
var AGGREGATOR_V2 = "aggregator_v2";
|
|
6884
6952
|
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6885
6953
|
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
@@ -6985,6 +7053,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6985
7053
|
};
|
|
6986
7054
|
}
|
|
6987
7055
|
if (data.data != null) {
|
|
7056
|
+
console.log("data.data", JSON.stringify(data.data, null, 2));
|
|
6988
7057
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6989
7058
|
return res;
|
|
6990
7059
|
}
|
|
@@ -7037,7 +7106,7 @@ function getRouter(endpoint, params) {
|
|
|
7037
7106
|
url += `&providers=${providers.join(",")}`;
|
|
7038
7107
|
}
|
|
7039
7108
|
}
|
|
7040
|
-
url += "&v=
|
|
7109
|
+
url += "&v=1000324";
|
|
7041
7110
|
const response = yield fetch(url);
|
|
7042
7111
|
return response;
|
|
7043
7112
|
} catch (error) {
|
|
@@ -7132,7 +7201,7 @@ exports.AFTERMATH = AFTERMATH;
|
|
|
7132
7201
|
exports.AGGREGATOR_V2 = AGGREGATOR_V2;
|
|
7133
7202
|
exports.AGGREGATOR_V2_EXTEND = AGGREGATOR_V2_EXTEND;
|
|
7134
7203
|
exports.ALPHAFI = ALPHAFI;
|
|
7135
|
-
exports.AggregatorClient =
|
|
7204
|
+
exports.AggregatorClient = AggregatorClient20;
|
|
7136
7205
|
exports.BLUEFIN = BLUEFIN;
|
|
7137
7206
|
exports.BLUEMOVE = BLUEMOVE;
|
|
7138
7207
|
exports.CETUS = CETUS;
|
|
@@ -7150,6 +7219,7 @@ exports.KRIYAV3 = KRIYAV3;
|
|
|
7150
7219
|
exports.ONE = ONE;
|
|
7151
7220
|
exports.SCALLOP = SCALLOP;
|
|
7152
7221
|
exports.SPRINGSUI = SPRINGSUI;
|
|
7222
|
+
exports.STEAMM = STEAMM;
|
|
7153
7223
|
exports.SUILEND = SUILEND;
|
|
7154
7224
|
exports.TEN_POW_NINE = TEN_POW_NINE;
|
|
7155
7225
|
exports.TURBOS = TURBOS;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
2
|
-
import { normalizeSuiObjectId, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
|
|
2
|
+
import { normalizeSuiObjectId, SUI_CLOCK_OBJECT_ID, SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
|
|
3
3
|
import { Transaction } from '@mysten/sui/transactions';
|
|
4
4
|
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
|
|
5
5
|
|
|
@@ -5801,11 +5801,10 @@ function swapInPools(client, params, sender, env) {
|
|
|
5801
5801
|
const targetCoin = completionCoin(target);
|
|
5802
5802
|
const tx = new Transaction();
|
|
5803
5803
|
const direction = compareCoins(fromCoin, targetCoin);
|
|
5804
|
-
const integratePublishedAt = env === 0 /* Mainnet */ ? "
|
|
5804
|
+
const integratePublishedAt = env === 0 /* Mainnet */ ? "0x2d8c2e0fc6dd25b0214b3fa747e0fd27fd54608142cd2e4f64c1cd350cc4add4" : "0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6";
|
|
5805
5805
|
const coinA = direction ? fromCoin : targetCoin;
|
|
5806
5806
|
const coinB = direction ? targetCoin : fromCoin;
|
|
5807
5807
|
const typeArguments = [coinA, coinB];
|
|
5808
|
-
console.log("typeArguments", typeArguments, integratePublishedAt);
|
|
5809
5808
|
for (let i = 0; i < pools.length; i++) {
|
|
5810
5809
|
const args = [
|
|
5811
5810
|
tx.object(pools[i]),
|
|
@@ -5825,7 +5824,6 @@ function swapInPools(client, params, sender, env) {
|
|
|
5825
5824
|
"InvalidWallet" /* InvalidWallet */
|
|
5826
5825
|
);
|
|
5827
5826
|
}
|
|
5828
|
-
printTransaction(tx);
|
|
5829
5827
|
const simulateRes = yield client.devInspectTransactionBlock({
|
|
5830
5828
|
transactionBlock: tx,
|
|
5831
5829
|
sender
|
|
@@ -5867,7 +5865,6 @@ function swapInPools(client, params, sender, env) {
|
|
|
5867
5865
|
}
|
|
5868
5866
|
}
|
|
5869
5867
|
const event = valueData[tempIndex].parsedJson.data;
|
|
5870
|
-
console.log("event", JSON.stringify(event, null, 2));
|
|
5871
5868
|
const currentSqrtPrice = event.step_results[0].current_sqrt_price;
|
|
5872
5869
|
const [decimalA, decimalB] = yield Promise.all([
|
|
5873
5870
|
client.getCoinMetadata({ coinType: coinA }).then((metadata) => metadata == null ? void 0 : metadata.decimals),
|
|
@@ -6247,6 +6244,70 @@ var Alphafi = class {
|
|
|
6247
6244
|
});
|
|
6248
6245
|
}
|
|
6249
6246
|
};
|
|
6247
|
+
|
|
6248
|
+
// src/transaction/steamm.ts
|
|
6249
|
+
var Steamm = class {
|
|
6250
|
+
constructor(env) {
|
|
6251
|
+
if (env !== 0 /* Mainnet */) {
|
|
6252
|
+
throw new Error("Steamm only supported on mainnet");
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
swap(client, txb, path, inputCoin, packages) {
|
|
6256
|
+
return __async(this, null, function* () {
|
|
6257
|
+
const { direction, from, target } = path;
|
|
6258
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6259
|
+
if (path.extendedDetails == null) {
|
|
6260
|
+
throw new Error("Extended details not supported");
|
|
6261
|
+
} else {
|
|
6262
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
6263
|
+
throw new Error("Steamm bank a type not supported");
|
|
6264
|
+
}
|
|
6265
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
6266
|
+
throw new Error("Steamm bank b type not supported");
|
|
6267
|
+
}
|
|
6268
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
6269
|
+
throw new Error("Steamm lending market not supported");
|
|
6270
|
+
}
|
|
6271
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
6272
|
+
throw new Error("Steamm lending market type not supported");
|
|
6273
|
+
}
|
|
6274
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
6275
|
+
throw new Error("Steamm b coin a type not supported");
|
|
6276
|
+
}
|
|
6277
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
6278
|
+
throw new Error("Steamm b coin b type not supported");
|
|
6279
|
+
}
|
|
6280
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
6281
|
+
throw new Error("Steamm lp token not supported");
|
|
6282
|
+
}
|
|
6283
|
+
}
|
|
6284
|
+
const args = [
|
|
6285
|
+
txb.object(path.id),
|
|
6286
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
6287
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
6288
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
6289
|
+
inputCoin,
|
|
6290
|
+
txb.object(CLOCK_ADDRESS)
|
|
6291
|
+
];
|
|
6292
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages);
|
|
6293
|
+
const res = txb.moveCall({
|
|
6294
|
+
target: `${publishedAt}::steamm::${func}`,
|
|
6295
|
+
typeArguments: [
|
|
6296
|
+
path.extendedDetails.steammLendingMarketType,
|
|
6297
|
+
coinAType,
|
|
6298
|
+
coinBType,
|
|
6299
|
+
path.extendedDetails.steammBCoinAType,
|
|
6300
|
+
path.extendedDetails.steammBCoinBType,
|
|
6301
|
+
path.extendedDetails.steammLPToken
|
|
6302
|
+
],
|
|
6303
|
+
arguments: args
|
|
6304
|
+
});
|
|
6305
|
+
return res;
|
|
6306
|
+
});
|
|
6307
|
+
}
|
|
6308
|
+
};
|
|
6309
|
+
|
|
6310
|
+
// src/client.ts
|
|
6250
6311
|
var CETUS = "CETUS";
|
|
6251
6312
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
6252
6313
|
var KRIYA = "KRIYA";
|
|
@@ -6266,6 +6327,7 @@ var BLUEFIN = "BLUEFIN";
|
|
|
6266
6327
|
var HAEDALPMM = "HAEDALPMM";
|
|
6267
6328
|
var ALPHAFI = "ALPHAFI";
|
|
6268
6329
|
var SPRINGSUI = "SPRINGSUI";
|
|
6330
|
+
var STEAMM = "STEAMM";
|
|
6269
6331
|
var DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
6270
6332
|
function isBuilderRouterSwapParams(params) {
|
|
6271
6333
|
return Array.isArray(params.routers);
|
|
@@ -6471,7 +6533,6 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6471
6533
|
slippage
|
|
6472
6534
|
);
|
|
6473
6535
|
const packages = isBuilderRouterSwapParams(params) ? void 0 : params.routers.packages;
|
|
6474
|
-
console.log("packages11", packages);
|
|
6475
6536
|
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
6476
6537
|
this.publishedAtV2(),
|
|
6477
6538
|
packages
|
|
@@ -6604,7 +6665,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6604
6665
|
// Include cetus、deepbookv2、flowxv2 & v3、kriyav2 & v3、turbos、aftermath、haedal、afsui、volo、bluemove
|
|
6605
6666
|
publishedAtV2() {
|
|
6606
6667
|
if (this.env === 0 /* Mainnet */) {
|
|
6607
|
-
return "
|
|
6668
|
+
return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce";
|
|
6608
6669
|
} else {
|
|
6609
6670
|
return "0x52eae33adeb44de55cfb3f281d4cc9e02d976181c0952f5323648b5717b33934";
|
|
6610
6671
|
}
|
|
@@ -6612,7 +6673,7 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6612
6673
|
// Include deepbookv3, scallop, bluefin
|
|
6613
6674
|
publishedAtV2Extend() {
|
|
6614
6675
|
if (this.env === 0 /* Mainnet */) {
|
|
6615
|
-
return "
|
|
6676
|
+
return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed";
|
|
6616
6677
|
} else {
|
|
6617
6678
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78";
|
|
6618
6679
|
}
|
|
@@ -6689,6 +6750,8 @@ var _AggregatorClient = class _AggregatorClient {
|
|
|
6689
6750
|
return new HaedalPmm(this.env, pythPriceIDs);
|
|
6690
6751
|
case ALPHAFI:
|
|
6691
6752
|
return new Alphafi(this.env);
|
|
6753
|
+
case STEAMM:
|
|
6754
|
+
return new Steamm(this.env);
|
|
6692
6755
|
default:
|
|
6693
6756
|
throw new Error(`Unsupported dex ${provider}`);
|
|
6694
6757
|
}
|
|
@@ -6796,7 +6859,7 @@ _AggregatorClient.CONFIG = {
|
|
|
6796
6859
|
pythStateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"
|
|
6797
6860
|
}
|
|
6798
6861
|
};
|
|
6799
|
-
var
|
|
6862
|
+
var AggregatorClient20 = _AggregatorClient;
|
|
6800
6863
|
function findPythPriceIDs(routes) {
|
|
6801
6864
|
const priceIDs = /* @__PURE__ */ new Set();
|
|
6802
6865
|
for (const route of routes) {
|
|
@@ -6835,13 +6898,13 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6835
6898
|
routes: data.routes.map((route) => {
|
|
6836
6899
|
return {
|
|
6837
6900
|
path: route.path.map((path) => {
|
|
6838
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
6901
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
6839
6902
|
let version;
|
|
6840
6903
|
if (path.provider === AFTERMATH) {
|
|
6841
6904
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6842
6905
|
}
|
|
6843
6906
|
let extendedDetails;
|
|
6844
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM) {
|
|
6907
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3 || path.provider === SCALLOP || path.provider === HAEDALPMM || path.provider === STEAMM) {
|
|
6845
6908
|
extendedDetails = {
|
|
6846
6909
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6847
6910
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
@@ -6849,7 +6912,14 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6849
6912
|
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee,
|
|
6850
6913
|
scallopScoinTreasury: (_e = path.extended_details) == null ? void 0 : _e.scallop_scoin_treasury,
|
|
6851
6914
|
haedalPmmBasePriceSeed: (_f = path.extended_details) == null ? void 0 : _f.haedal_pmm_base_price_seed,
|
|
6852
|
-
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed
|
|
6915
|
+
haedalPmmQuotePriceSeed: (_g = path.extended_details) == null ? void 0 : _g.haedal_pmm_quote_price_seed,
|
|
6916
|
+
steammfeBankA: (_h = path.extended_details) == null ? void 0 : _h.steammfe_bank_a,
|
|
6917
|
+
steammfeBankB: (_i = path.extended_details) == null ? void 0 : _i.steammfe_bank_b,
|
|
6918
|
+
steammfeLendingMarket: (_j = path.extended_details) == null ? void 0 : _j.steammfe_lending_market,
|
|
6919
|
+
steammfeLendingMarketType: (_k = path.extended_details) == null ? void 0 : _k.steammfe_lending_market_type,
|
|
6920
|
+
steammfeBCoinAType: (_l = path.extended_details) == null ? void 0 : _l.steammfe_btoken_a_type,
|
|
6921
|
+
steammfeBCoinBType: (_m = path.extended_details) == null ? void 0 : _m.steammfe_btoken_b_type,
|
|
6922
|
+
steammfeLPToken: (_n = path.extended_details) == null ? void 0 : _n.steammfe_lp_token_type
|
|
6853
6923
|
};
|
|
6854
6924
|
}
|
|
6855
6925
|
return {
|
|
@@ -6875,9 +6945,7 @@ function parseRouterResponse(data, byAmountIn) {
|
|
|
6875
6945
|
};
|
|
6876
6946
|
return routerData;
|
|
6877
6947
|
}
|
|
6878
|
-
|
|
6879
|
-
// src/transaction/index.ts
|
|
6880
|
-
var CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
6948
|
+
var CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID;
|
|
6881
6949
|
var AGGREGATOR_V2 = "aggregator_v2";
|
|
6882
6950
|
var AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6883
6951
|
function getAggregatorV2PublishedAt(aggregatorV2PublishedAt, packages) {
|
|
@@ -6983,6 +7051,7 @@ function getRouterResult(endpoint, params) {
|
|
|
6983
7051
|
};
|
|
6984
7052
|
}
|
|
6985
7053
|
if (data.data != null) {
|
|
7054
|
+
console.log("data.data", JSON.stringify(data.data, null, 2));
|
|
6986
7055
|
const res = parseRouterResponse(data.data, params.byAmountIn);
|
|
6987
7056
|
return res;
|
|
6988
7057
|
}
|
|
@@ -7035,7 +7104,7 @@ function getRouter(endpoint, params) {
|
|
|
7035
7104
|
url += `&providers=${providers.join(",")}`;
|
|
7036
7105
|
}
|
|
7037
7106
|
}
|
|
7038
|
-
url += "&v=
|
|
7107
|
+
url += "&v=1000324";
|
|
7039
7108
|
const response = yield fetch(url);
|
|
7040
7109
|
return response;
|
|
7041
7110
|
} catch (error) {
|
|
@@ -7125,4 +7194,4 @@ decimal.js/decimal.mjs:
|
|
|
7125
7194
|
*)
|
|
7126
7195
|
*/
|
|
7127
7196
|
|
|
7128
|
-
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI,
|
|
7197
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient20 as AggregatorClient, BLUEFIN, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, Env, FLOWXV2, FLOWXV3, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, 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
|
@@ -27,6 +27,13 @@ export type ExtendedDetails = {
|
|
|
27
27
|
scallopScoinTreasury?: string;
|
|
28
28
|
haedalPmmBasePriceSeed?: string;
|
|
29
29
|
haedalPmmQuotePriceSeed?: string;
|
|
30
|
+
steammBankA?: string;
|
|
31
|
+
steammBankB?: string;
|
|
32
|
+
steammLendingMarket?: string;
|
|
33
|
+
steammLendingMarketType?: string;
|
|
34
|
+
steammBCoinAType?: string;
|
|
35
|
+
steammBCoinBType?: string;
|
|
36
|
+
steammLPToken?: string;
|
|
30
37
|
};
|
|
31
38
|
export type Path = {
|
|
32
39
|
id: string;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const BLUEFIN = "BLUEFIN";
|
|
|
23
23
|
export declare const HAEDALPMM = "HAEDALPMM";
|
|
24
24
|
export declare const ALPHAFI = "ALPHAFI";
|
|
25
25
|
export declare const SPRINGSUI = "SPRINGSUI";
|
|
26
|
+
export declare const STEAMM = "STEAMM";
|
|
26
27
|
export declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
27
28
|
export type BuildRouterSwapParams = {
|
|
28
29
|
routers: Router[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
2
|
import { AggregatorClient, Path } from "..";
|
|
3
|
-
export declare const CLOCK_ADDRESS
|
|
3
|
+
export declare const CLOCK_ADDRESS: string;
|
|
4
4
|
export declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
5
5
|
export declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
6
6
|
export declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { AggregatorClient, Dex, Env, Path } from "..";
|
|
3
|
+
export declare class Steamm implements Dex {
|
|
4
|
+
constructor(env: Env);
|
|
5
|
+
swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
6
|
+
}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -29,14 +29,28 @@ export interface PreSwapLpChangeParams {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export type ExtendedDetails = {
|
|
32
|
+
// aftermath
|
|
32
33
|
aftermathPoolFlatness?: number
|
|
33
34
|
aftermathLpSupplyType?: string
|
|
35
|
+
// turbos
|
|
34
36
|
turbosFeeType?: string
|
|
37
|
+
// cetus
|
|
35
38
|
afterSqrtPrice?: string
|
|
39
|
+
// deepbookv3
|
|
36
40
|
deepbookv3DeepFee?: number
|
|
41
|
+
// scallop
|
|
37
42
|
scallopScoinTreasury?: string
|
|
43
|
+
// haedal
|
|
38
44
|
haedalPmmBasePriceSeed?: string
|
|
39
45
|
haedalPmmQuotePriceSeed?: string
|
|
46
|
+
// steamm
|
|
47
|
+
steammBankA?: string
|
|
48
|
+
steammBankB?: string
|
|
49
|
+
steammLendingMarket?: string
|
|
50
|
+
steammLendingMarketType?: string
|
|
51
|
+
steammBCoinAType?: string
|
|
52
|
+
steammBCoinBType?: string
|
|
53
|
+
steammLPToken?: string
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
export type Path = {
|
|
@@ -130,6 +144,7 @@ export async function getRouterResult(
|
|
|
130
144
|
}
|
|
131
145
|
}
|
|
132
146
|
if (data.data != null) {
|
|
147
|
+
console.log("data.data", JSON.stringify(data.data, null, 2))
|
|
133
148
|
const res = parseRouterResponse(data.data, params.byAmountIn)
|
|
134
149
|
return res
|
|
135
150
|
}
|
|
@@ -190,7 +205,7 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
|
|
|
190
205
|
}
|
|
191
206
|
|
|
192
207
|
// set newest sdk version
|
|
193
|
-
url += "&v=
|
|
208
|
+
url += "&v=1000324"
|
|
194
209
|
|
|
195
210
|
const response = await fetch(url)
|
|
196
211
|
return response
|
package/src/client.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
SuiPriceServiceConnection,
|
|
48
48
|
SuiPythClient,
|
|
49
49
|
} from "@pythnetwork/pyth-sui-js"
|
|
50
|
+
import { Steamm } from "./transaction/steamm"
|
|
50
51
|
|
|
51
52
|
export const CETUS = "CETUS"
|
|
52
53
|
export const DEEPBOOKV2 = "DEEPBOOK"
|
|
@@ -67,6 +68,7 @@ export const BLUEFIN = "BLUEFIN"
|
|
|
67
68
|
export const HAEDALPMM = "HAEDALPMM"
|
|
68
69
|
export const ALPHAFI = "ALPHAFI"
|
|
69
70
|
export const SPRINGSUI = "SPRINGSUI"
|
|
71
|
+
export const STEAMM = "STEAMM"
|
|
70
72
|
export const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2"
|
|
71
73
|
|
|
72
74
|
export type BuildRouterSwapParams = {
|
|
@@ -422,8 +424,6 @@ export class AggregatorClient {
|
|
|
422
424
|
? undefined
|
|
423
425
|
: params.routers.packages
|
|
424
426
|
|
|
425
|
-
console.log("packages11", packages)
|
|
426
|
-
|
|
427
427
|
const aggregatorV2PublishedAt = getAggregatorV2PublishedAt(
|
|
428
428
|
this.publishedAtV2(),
|
|
429
429
|
packages
|
|
@@ -582,8 +582,8 @@ export class AggregatorClient {
|
|
|
582
582
|
publishedAtV2(): string {
|
|
583
583
|
if (this.env === Env.Mainnet) {
|
|
584
584
|
// return "0x3fb42ddf908af45f9fc3c59eab227888ff24ba2e137b3b55bf80920fd47e11af" // version 6
|
|
585
|
-
// return "
|
|
586
|
-
return "
|
|
585
|
+
// return "0xf9c6f78322ed667909e05f6b42b2f5a67af6297503c905335e02a15148e9440d" // version 7
|
|
586
|
+
return "0x2485feb9d42c7c3bcb8ecde555ad40f1b073d9fb4faf354fa2d30a0b183a23ce" // version 8
|
|
587
587
|
// return "0x803db8dfcc86fc1afbc7d2212bd14ec9690978ddebea0d590e01147d6b17aa06" // pre
|
|
588
588
|
} else {
|
|
589
589
|
// return "0x0ed287d6c3fe4962d0994ffddc1d19a15fba6a81533f3f0dcc2bbcedebce0637" // version 2
|
|
@@ -600,7 +600,8 @@ export class AggregatorClient {
|
|
|
600
600
|
// return "0x3b6d71bdeb8ce5b06febfd3cfc29ecd60d50da729477c8b8038ecdae34541b91" // version 5, add bluefin
|
|
601
601
|
// return "0x81ade554cb24a7564ca43a4bfb7381b08d9e5c5f375162c95215b696ab903502" // version 6, force upgrade scallop
|
|
602
602
|
// return "0x347dd58bbd11cd82c8b386b344729717c04a998da73386e82a239cc196d5706b" // version 7
|
|
603
|
-
return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613" // version 8
|
|
603
|
+
// return "0xf2fcea41dc217385019828375764fa06d9bd25e8e4726ba1962680849fb8d613" // version 8
|
|
604
|
+
return "0xa2d8a4279d69d8fec04b2fea8852d0d467d3cc0d39c5890180d439ae7a9953ed" // version 9
|
|
604
605
|
} else {
|
|
605
606
|
return "0xabb6a81c8a216828e317719e06125de5bb2cb0fe8f9916ff8c023ca5be224c78"
|
|
606
607
|
}
|
|
@@ -697,6 +698,8 @@ export class AggregatorClient {
|
|
|
697
698
|
return new HaedalPmm(this.env, pythPriceIDs)
|
|
698
699
|
case ALPHAFI:
|
|
699
700
|
return new Alphafi(this.env)
|
|
701
|
+
case STEAMM:
|
|
702
|
+
return new Steamm(this.env)
|
|
700
703
|
default:
|
|
701
704
|
throw new Error(`Unsupported dex ${provider}`)
|
|
702
705
|
}
|
|
@@ -846,7 +849,8 @@ export function parseRouterResponse(
|
|
|
846
849
|
path.provider === CETUS ||
|
|
847
850
|
path.provider === DEEPBOOKV3 ||
|
|
848
851
|
path.provider === SCALLOP ||
|
|
849
|
-
path.provider === HAEDALPMM
|
|
852
|
+
path.provider === HAEDALPMM ||
|
|
853
|
+
path.provider === STEAMM
|
|
850
854
|
) {
|
|
851
855
|
extendedDetails = {
|
|
852
856
|
aftermathLpSupplyType:
|
|
@@ -860,6 +864,13 @@ export function parseRouterResponse(
|
|
|
860
864
|
path.extended_details?.haedal_pmm_base_price_seed,
|
|
861
865
|
haedalPmmQuotePriceSeed:
|
|
862
866
|
path.extended_details?.haedal_pmm_quote_price_seed,
|
|
867
|
+
steammfeBankA: path.extended_details?.steammfe_bank_a,
|
|
868
|
+
steammfeBankB: path.extended_details?.steammfe_bank_b,
|
|
869
|
+
steammfeLendingMarket: path.extended_details?.steammfe_lending_market,
|
|
870
|
+
steammfeLendingMarketType: path.extended_details?.steammfe_lending_market_type,
|
|
871
|
+
steammfeBCoinAType: path.extended_details?.steammfe_btoken_a_type,
|
|
872
|
+
steammfeBCoinBType: path.extended_details?.steammfe_btoken_b_type,
|
|
873
|
+
steammfeLPToken: path.extended_details?.steammfe_lp_token_type,
|
|
863
874
|
}
|
|
864
875
|
}
|
|
865
876
|
|
package/src/transaction/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
TransactionObjectArgument,
|
|
4
4
|
} from "@mysten/sui/transactions"
|
|
5
5
|
import { AggregatorClient, Path } from ".."
|
|
6
|
+
import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils"
|
|
6
7
|
|
|
7
|
-
export const CLOCK_ADDRESS =
|
|
8
|
-
"0x0000000000000000000000000000000000000000000000000000000000000006"
|
|
8
|
+
export const CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID
|
|
9
9
|
|
|
10
10
|
export const AGGREGATOR_V2 = "aggregator_v2"
|
|
11
11
|
export const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Transaction,
|
|
3
|
+
TransactionObjectArgument,
|
|
4
|
+
} from "@mysten/sui/transactions"
|
|
5
|
+
import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
|
|
6
|
+
|
|
7
|
+
export class Steamm implements Dex {
|
|
8
|
+
constructor(env: Env) {
|
|
9
|
+
if (env !== Env.Mainnet) {
|
|
10
|
+
throw new Error("Steamm only supported on mainnet")
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async swap(
|
|
15
|
+
client: AggregatorClient,
|
|
16
|
+
txb: Transaction,
|
|
17
|
+
path: Path,
|
|
18
|
+
inputCoin: TransactionObjectArgument,
|
|
19
|
+
packages?: Map<string, string>
|
|
20
|
+
): Promise<TransactionObjectArgument> {
|
|
21
|
+
const { direction, from, target } = path
|
|
22
|
+
|
|
23
|
+
const [func, coinAType, coinBType] = direction
|
|
24
|
+
? ["swap_a2b", from, target]
|
|
25
|
+
: ["swap_b2a", target, from]
|
|
26
|
+
|
|
27
|
+
if (path.extendedDetails == null) {
|
|
28
|
+
throw new Error("Extended details not supported")
|
|
29
|
+
} else {
|
|
30
|
+
if (path.extendedDetails.steammBankA == null) {
|
|
31
|
+
throw new Error("Steamm bank a type not supported")
|
|
32
|
+
}
|
|
33
|
+
if (path.extendedDetails.steammBankB == null) {
|
|
34
|
+
throw new Error("Steamm bank b type not supported")
|
|
35
|
+
}
|
|
36
|
+
if (path.extendedDetails.steammLendingMarket == null) {
|
|
37
|
+
throw new Error("Steamm lending market not supported")
|
|
38
|
+
}
|
|
39
|
+
if (path.extendedDetails.steammLendingMarketType == null) {
|
|
40
|
+
throw new Error("Steamm lending market type not supported")
|
|
41
|
+
}
|
|
42
|
+
if (path.extendedDetails.steammBCoinAType == null) {
|
|
43
|
+
throw new Error("Steamm b coin a type not supported")
|
|
44
|
+
}
|
|
45
|
+
if (path.extendedDetails.steammBCoinBType == null) {
|
|
46
|
+
throw new Error("Steamm b coin b type not supported")
|
|
47
|
+
}
|
|
48
|
+
if (path.extendedDetails.steammLPToken == null) {
|
|
49
|
+
throw new Error("Steamm lp token not supported")
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const args = [
|
|
54
|
+
txb.object(path.id),
|
|
55
|
+
txb.object(path.extendedDetails.steammBankA),
|
|
56
|
+
txb.object(path.extendedDetails.steammBankB),
|
|
57
|
+
txb.object(path.extendedDetails.steammLendingMarket),
|
|
58
|
+
inputCoin,
|
|
59
|
+
txb.object(CLOCK_ADDRESS),
|
|
60
|
+
]
|
|
61
|
+
const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
|
|
62
|
+
const res = txb.moveCall({
|
|
63
|
+
target: `${publishedAt}::steamm::${func}`,
|
|
64
|
+
typeArguments: [
|
|
65
|
+
path.extendedDetails.steammLendingMarketType,
|
|
66
|
+
coinAType,
|
|
67
|
+
coinBType,
|
|
68
|
+
path.extendedDetails.steammBCoinAType,
|
|
69
|
+
path.extendedDetails.steammBCoinBType,
|
|
70
|
+
path.extendedDetails.steammLPToken,
|
|
71
|
+
],
|
|
72
|
+
arguments: args,
|
|
73
|
+
}) as TransactionObjectArgument
|
|
74
|
+
|
|
75
|
+
return res
|
|
76
|
+
}
|
|
77
|
+
}
|
package/src/transaction/swap.ts
CHANGED
|
@@ -21,13 +21,12 @@ export async function swapInPools(
|
|
|
21
21
|
const tx = new Transaction()
|
|
22
22
|
const direction = compareCoins(fromCoin, targetCoin)
|
|
23
23
|
const integratePublishedAt = env === Env.Mainnet ?
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"0x2d8c2e0fc6dd25b0214b3fa747e0fd27fd54608142cd2e4f64c1cd350cc4add4" :
|
|
25
|
+
"0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6"
|
|
26
26
|
const coinA = direction ? fromCoin : targetCoin
|
|
27
27
|
const coinB = direction ? targetCoin : fromCoin
|
|
28
28
|
|
|
29
29
|
const typeArguments = [coinA, coinB]
|
|
30
|
-
console.log("typeArguments", typeArguments, integratePublishedAt)
|
|
31
30
|
|
|
32
31
|
for (let i = 0; i < pools.length; i++) {
|
|
33
32
|
const args = [
|
|
@@ -50,8 +49,6 @@ export async function swapInPools(
|
|
|
50
49
|
)
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
printTransaction(tx)
|
|
54
|
-
|
|
55
52
|
const simulateRes = await client.devInspectTransactionBlock({
|
|
56
53
|
transactionBlock: tx,
|
|
57
54
|
sender,
|
|
@@ -99,8 +96,6 @@ export async function swapInPools(
|
|
|
99
96
|
|
|
100
97
|
const event = valueData[tempIndex].parsedJson.data
|
|
101
98
|
|
|
102
|
-
console.log("event", JSON.stringify(event, null, 2))
|
|
103
|
-
|
|
104
99
|
const currentSqrtPrice = event.step_results[0].current_sqrt_price
|
|
105
100
|
|
|
106
101
|
const [decimalA, decimalB] = await Promise.all([
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, test } from "@jest/globals"
|
|
2
|
+
import dotenv from "dotenv"
|
|
3
|
+
import { AggregatorClient } from "~/client"
|
|
4
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
|
|
5
|
+
import { printTransaction } from "~/utils/transaction"
|
|
6
|
+
import BN from "bn.js"
|
|
7
|
+
import { fromB64 } from "@mysten/sui/utils"
|
|
8
|
+
import { SuiClient } from "@mysten/sui/client"
|
|
9
|
+
import { Env } from "~/index"
|
|
10
|
+
import { Transaction } from "@mysten/sui/transactions"
|
|
11
|
+
|
|
12
|
+
dotenv.config()
|
|
13
|
+
|
|
14
|
+
export function buildTestAccount(): Ed25519Keypair {
|
|
15
|
+
const mnemonics = process.env.SUI_WALLET_MNEMONICS || ""
|
|
16
|
+
const testAccountObject = Ed25519Keypair.deriveKeypair(mnemonics)
|
|
17
|
+
return testAccountObject
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("Test steammfe module", () => {
|
|
21
|
+
let client: AggregatorClient
|
|
22
|
+
let keypair: Ed25519Keypair
|
|
23
|
+
|
|
24
|
+
const T_SUI = "0x2e868e44010e06c0fc925d29f35029b6ef75a50e03d997585980fb2acea45ec6::sui::SUI"
|
|
25
|
+
const T_USDC = "0x2e868e44010e06c0fc925d29f35029b6ef75a50e03d997585980fb2acea45ec6::usdc::USDC"
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
const fullNodeURL = process.env.SUI_RPC!
|
|
29
|
+
const aggregatorURL = process.env.CETUS_AGGREGATOR!
|
|
30
|
+
const secret = process.env.SUI_WALLET_SECRET!
|
|
31
|
+
|
|
32
|
+
if (secret) {
|
|
33
|
+
keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
|
|
34
|
+
} else {
|
|
35
|
+
keypair = buildTestAccount()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// const wallet = keypair.getPublicKey().toSuiAddress()
|
|
39
|
+
const wallet =
|
|
40
|
+
"0xb0deeb083fb5738e2d76820a3e59a284adbd56ab1b1d71d606cda8ea71cffe90"
|
|
41
|
+
|
|
42
|
+
console.log("wallet: ", wallet)
|
|
43
|
+
|
|
44
|
+
const endpoint = aggregatorURL
|
|
45
|
+
|
|
46
|
+
const suiClient = new SuiClient({
|
|
47
|
+
url: fullNodeURL,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
client = new AggregatorClient(endpoint, wallet, suiClient, Env.Mainnet)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test("Find Routers", async () => {
|
|
54
|
+
const amounts = ["1000", "1000000", "100000000", "5000000000", "10000000000000"]
|
|
55
|
+
|
|
56
|
+
for (const amount of amounts) {
|
|
57
|
+
const res = await client.findRouters({
|
|
58
|
+
from: T_USDC,
|
|
59
|
+
target: T_SUI,
|
|
60
|
+
amount: new BN(amount),
|
|
61
|
+
byAmountIn: true,
|
|
62
|
+
depth: 3,
|
|
63
|
+
splitCount: 1,
|
|
64
|
+
providers: ["STEAMMFE"],
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
if (res != null) {
|
|
68
|
+
console.log(JSON.stringify(res, null, 2))
|
|
69
|
+
}
|
|
70
|
+
console.log("amount in", res?.amountIn.toString())
|
|
71
|
+
console.log("amount out", res?.amountOut.toString())
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test("Build Router TX", async () => {
|
|
76
|
+
const amount = "100000"
|
|
77
|
+
|
|
78
|
+
const res = await client.findRouters({
|
|
79
|
+
from: T_USDC,
|
|
80
|
+
target: T_SUI,
|
|
81
|
+
amount: new BN(amount),
|
|
82
|
+
byAmountIn: true,
|
|
83
|
+
depth: 3,
|
|
84
|
+
providers: ["STEAMMFE"],
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
console.log("amount in", res?.amountIn.toString())
|
|
88
|
+
console.log("amount out", res?.amountOut.toString())
|
|
89
|
+
|
|
90
|
+
const txb = new Transaction()
|
|
91
|
+
|
|
92
|
+
if (res != null) {
|
|
93
|
+
console.log(JSON.stringify(res, null, 2))
|
|
94
|
+
await client.fastRouterSwap({
|
|
95
|
+
routers: res,
|
|
96
|
+
txb,
|
|
97
|
+
slippage: 0.01,
|
|
98
|
+
refreshAllCoins: true,
|
|
99
|
+
payDeepFeeAmount: 0,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
txb.setSender(client.signer)
|
|
103
|
+
const buildTxb = await txb.build({ client: client.client })
|
|
104
|
+
// const buildTxb = await txb.getData()
|
|
105
|
+
|
|
106
|
+
console.log("buildTxb", buildTxb)
|
|
107
|
+
|
|
108
|
+
printTransaction(txb)
|
|
109
|
+
|
|
110
|
+
let result = await client.devInspectTransactionBlock(txb)
|
|
111
|
+
console.log("🚀 ~ file: router.test.ts:180 ~ test ~ result:", result)
|
|
112
|
+
for (const event of result.events) {
|
|
113
|
+
console.log("event", JSON.stringify(event, null, 2))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (result.effects.status.status === "success") {
|
|
117
|
+
const result = await client.signAndExecuteTransaction(txb, keypair)
|
|
118
|
+
console.log("result", result)
|
|
119
|
+
} else {
|
|
120
|
+
console.log("result", result)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, 600000)
|
|
124
|
+
})
|