@suilend/sdk 1.1.76 → 1.1.77
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/lib/strategyOwnerCap.js +4 -4
- package/package.json +1 -1
- package/swap/quote.d.ts +1 -1
- package/swap/quote.js +28 -2
- package/swap/transaction.js +1 -1
package/lib/strategyOwnerCap.js
CHANGED
|
@@ -209,8 +209,8 @@ const strategyClaimRewardsAndSwap = (address, cetusSdk, cetusPartnerId, rewardsM
|
|
|
209
209
|
const slippagePercent = 3;
|
|
210
210
|
let coinOut;
|
|
211
211
|
try {
|
|
212
|
-
coinOut = yield cetusSdk.
|
|
213
|
-
routers,
|
|
212
|
+
coinOut = yield cetusSdk.fixableRouterSwapV3({
|
|
213
|
+
router: routers,
|
|
214
214
|
inputCoin: coinIn,
|
|
215
215
|
slippage: slippagePercent / 100,
|
|
216
216
|
txb: transaction,
|
|
@@ -281,8 +281,8 @@ const strategySwapNonLstDepositsForLst = (cetusSdk, cetusPartnerId, obligation,
|
|
|
281
281
|
const slippagePercent = 3;
|
|
282
282
|
let coinOut;
|
|
283
283
|
try {
|
|
284
|
-
coinOut = yield cetusSdk.
|
|
285
|
-
routers,
|
|
284
|
+
coinOut = yield cetusSdk.fixableRouterSwapV3({
|
|
285
|
+
router: routers,
|
|
286
286
|
inputCoin: coinIn,
|
|
287
287
|
slippage: slippagePercent / 100,
|
|
288
288
|
txb: transaction,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.77","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/suilend-fe-public.git"},"bugs":{"url":"https://github.com/suilend/suilend-fe-public/issues"},"dependencies":{"@7kprotocol/sdk-ts":"^3.4.0","@cetusprotocol/aggregator-sdk":"^1.1.2","@flowx-finance/sdk":"^1.11.3","@pythnetwork/pyth-sui-js":"^2.2.0","aftermath-ts-sdk":"^1.3.14","bignumber.js":"^9.1.2","bn.js":"^5.2.2","crypto-js":"^4.2.0","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"@types/bn.js":"^5.2.0","ts-node":"^10.9.2"},"peerDependencies":{"@mysten/bcs":"1.6.0","@mysten/sui":"1.28.2","@suilend/sui-fe":"^0.3.29"}}
|
package/swap/quote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QuoteResponse as _7kQuote } from "@7kprotocol/sdk-ts/cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { RouterDataV3 as CetusQuote, AggregatorClient as CetusSdk } from "@cetusprotocol/aggregator-sdk";
|
|
3
3
|
import { AggregatorQuoter as FlowXAggregatorQuoter, GetRoutesResult as FlowXGetRoutesResult } from "@flowx-finance/sdk";
|
|
4
4
|
import { RouterCompleteTradeRoute as AftermathQuote, Aftermath as AftermathSdk } from "aftermath-ts-sdk";
|
|
5
5
|
import BigNumber from "bignumber.js";
|
package/swap/quote.js
CHANGED
|
@@ -140,6 +140,32 @@ const getCetusQuote = (sdk, tokenIn, tokenOut, amountIn) => __awaiter(void 0, vo
|
|
|
140
140
|
});
|
|
141
141
|
if (!quote)
|
|
142
142
|
return null;
|
|
143
|
+
const routes = [];
|
|
144
|
+
// First pass: build initial routes
|
|
145
|
+
for (const path of quote.paths) {
|
|
146
|
+
let addedToExistingRoute = false;
|
|
147
|
+
// Try to add to an existing route
|
|
148
|
+
for (const route of routes) {
|
|
149
|
+
if (route.paths.length > 0 &&
|
|
150
|
+
path.amountIn === route.paths[route.paths.length - 1].amountOut &&
|
|
151
|
+
(0, utils_1.normalizeStructTag)(path.from) ===
|
|
152
|
+
(0, utils_1.normalizeStructTag)(route.paths[route.paths.length - 1].target)) {
|
|
153
|
+
route.paths.push(path);
|
|
154
|
+
addedToExistingRoute = true;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// If couldn't add to existing route, only start a new route if it's from the quote's from field
|
|
159
|
+
if (!addedToExistingRoute &&
|
|
160
|
+
(0, utils_1.normalizeStructTag)(path.from) === (0, utils_1.normalizeStructTag)(tokenIn.coinType)) {
|
|
161
|
+
routes.push({
|
|
162
|
+
amountIn: new bignumber_js_1.default(path.amountIn),
|
|
163
|
+
paths: [path],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const remainingPaths = quote.paths.filter((path) => !routes.some((route) => route.paths.some((p) => p.id === path.id)));
|
|
168
|
+
// TODO
|
|
143
169
|
const standardizedQuote = {
|
|
144
170
|
id: (0, uuid_1.v4)(),
|
|
145
171
|
provider: QuoteProvider.CETUS,
|
|
@@ -151,11 +177,11 @@ const getCetusQuote = (sdk, tokenIn, tokenOut, amountIn) => __awaiter(void 0, vo
|
|
|
151
177
|
coinType: tokenOut.coinType,
|
|
152
178
|
amount: new bignumber_js_1.default(quote.amountOut.toString()).div(10 ** tokenOut.decimals),
|
|
153
179
|
},
|
|
154
|
-
routes:
|
|
180
|
+
routes: routes.map((route, routeIndex) => ({
|
|
155
181
|
percent: new bignumber_js_1.default(route.amountIn.toString())
|
|
156
182
|
.div(quote.amountIn.toString())
|
|
157
183
|
.times(100),
|
|
158
|
-
path: route.
|
|
184
|
+
path: route.paths.map((path) => ({
|
|
159
185
|
id: (0, uuid_1.v4)(),
|
|
160
186
|
poolId: path.id,
|
|
161
187
|
routeIndex,
|
package/swap/transaction.js
CHANGED
|
@@ -86,7 +86,7 @@ const getSwapTransaction = (suiClient, address, quote, slippagePercent, sdkMap,
|
|
|
86
86
|
: transaction.object(mergeCoinIn.coinObjectId), [BigInt(quote.quote.amountIn.toString())]);
|
|
87
87
|
}
|
|
88
88
|
const coinOut = yield sdkMap[quote_1.QuoteProvider.CETUS].routerSwap({
|
|
89
|
-
|
|
89
|
+
router: quote.quote,
|
|
90
90
|
inputCoin: coinIn,
|
|
91
91
|
slippage: slippagePercent / 100,
|
|
92
92
|
txb: transaction,
|