@strkfarm/sdk 1.1.59 → 1.1.60
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.browser.global.js +5 -9
- package/dist/index.browser.mjs +5 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -9
- package/dist/index.mjs +5 -9
- package/package.json +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +12 -9
|
@@ -80220,7 +80220,7 @@ spurious results.`);
|
|
|
80220
80220
|
}
|
|
80221
80221
|
};
|
|
80222
80222
|
}
|
|
80223
|
-
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4) {
|
|
80223
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
80224
80224
|
const poolKey = await this.getPoolKey();
|
|
80225
80225
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
80226
80226
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -80260,7 +80260,8 @@ spurious results.`);
|
|
|
80260
80260
|
token1Bal,
|
|
80261
80261
|
ekuboBounds,
|
|
80262
80262
|
maxIterations,
|
|
80263
|
-
priceRatioPrecision
|
|
80263
|
+
priceRatioPrecision,
|
|
80264
|
+
getQuoteCallback
|
|
80264
80265
|
);
|
|
80265
80266
|
}
|
|
80266
80267
|
assertValidBounds(bounds) {
|
|
@@ -80305,7 +80306,7 @@ spurious results.`);
|
|
|
80305
80306
|
* @returns {Promise<SwapInfo>}
|
|
80306
80307
|
*
|
|
80307
80308
|
*/
|
|
80308
|
-
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4) {
|
|
80309
|
+
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
80309
80310
|
logger2.verbose(
|
|
80310
80311
|
`${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
80311
80312
|
);
|
|
@@ -80340,12 +80341,7 @@ spurious results.`);
|
|
|
80340
80341
|
if (amountToSell.eq(0)) {
|
|
80341
80342
|
return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
|
|
80342
80343
|
}
|
|
80343
|
-
const quote = await this.
|
|
80344
|
-
tokenToSell.address,
|
|
80345
|
-
tokenToBuy.address,
|
|
80346
|
-
amountToSell.toWei(),
|
|
80347
|
-
this.address.address
|
|
80348
|
-
);
|
|
80344
|
+
const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
|
|
80349
80345
|
if (remainingSellAmount.eq(0)) {
|
|
80350
80346
|
const minAmountOut = Web3Number.fromWei(
|
|
80351
80347
|
quote.buyAmount.toString(),
|
package/dist/index.browser.mjs
CHANGED
|
@@ -16297,7 +16297,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16297
16297
|
}
|
|
16298
16298
|
};
|
|
16299
16299
|
}
|
|
16300
|
-
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16300
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16301
16301
|
const poolKey = await this.getPoolKey();
|
|
16302
16302
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
16303
16303
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -16337,7 +16337,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16337
16337
|
token1Bal,
|
|
16338
16338
|
ekuboBounds,
|
|
16339
16339
|
maxIterations,
|
|
16340
|
-
priceRatioPrecision
|
|
16340
|
+
priceRatioPrecision,
|
|
16341
|
+
getQuoteCallback
|
|
16341
16342
|
);
|
|
16342
16343
|
}
|
|
16343
16344
|
assertValidBounds(bounds) {
|
|
@@ -16382,7 +16383,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16382
16383
|
* @returns {Promise<SwapInfo>}
|
|
16383
16384
|
*
|
|
16384
16385
|
*/
|
|
16385
|
-
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16386
|
+
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16386
16387
|
logger.verbose(
|
|
16387
16388
|
`${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
16388
16389
|
);
|
|
@@ -16417,12 +16418,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16417
16418
|
if (amountToSell.eq(0)) {
|
|
16418
16419
|
return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
|
|
16419
16420
|
}
|
|
16420
|
-
const quote = await this.
|
|
16421
|
-
tokenToSell.address,
|
|
16422
|
-
tokenToBuy.address,
|
|
16423
|
-
amountToSell.toWei(),
|
|
16424
|
-
this.address.address
|
|
16425
|
-
);
|
|
16421
|
+
const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
|
|
16426
16422
|
if (remainingSellAmount.eq(0)) {
|
|
16427
16423
|
const minAmountOut = Web3Number.fromWei(
|
|
16428
16424
|
quote.buyAmount.toString(),
|
package/dist/index.d.ts
CHANGED
|
@@ -782,7 +782,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
782
782
|
usdValue: number;
|
|
783
783
|
};
|
|
784
784
|
}>;
|
|
785
|
-
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
785
|
+
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
|
|
786
786
|
assertValidBounds(bounds: EkuboBounds): void;
|
|
787
787
|
assertValidAmounts(expectedAmounts: any, token0Bal: Web3Number, token1Bal: Web3Number): void;
|
|
788
788
|
getSwapParams(expectedAmounts: any, poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number): {
|
|
@@ -802,7 +802,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
802
802
|
* @returns {Promise<SwapInfo>}
|
|
803
803
|
*
|
|
804
804
|
*/
|
|
805
|
-
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
805
|
+
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
|
|
806
806
|
/**
|
|
807
807
|
* Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
|
|
808
808
|
* Uses binary search approach to find optimal swap amount.
|
package/dist/index.js
CHANGED
|
@@ -16297,7 +16297,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16297
16297
|
}
|
|
16298
16298
|
};
|
|
16299
16299
|
}
|
|
16300
|
-
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16300
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16301
16301
|
const poolKey = await this.getPoolKey();
|
|
16302
16302
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
16303
16303
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -16337,7 +16337,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16337
16337
|
token1Bal,
|
|
16338
16338
|
ekuboBounds,
|
|
16339
16339
|
maxIterations,
|
|
16340
|
-
priceRatioPrecision
|
|
16340
|
+
priceRatioPrecision,
|
|
16341
|
+
getQuoteCallback
|
|
16341
16342
|
);
|
|
16342
16343
|
}
|
|
16343
16344
|
assertValidBounds(bounds) {
|
|
@@ -16382,7 +16383,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16382
16383
|
* @returns {Promise<SwapInfo>}
|
|
16383
16384
|
*
|
|
16384
16385
|
*/
|
|
16385
|
-
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16386
|
+
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16386
16387
|
logger.verbose(
|
|
16387
16388
|
`${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
16388
16389
|
);
|
|
@@ -16417,12 +16418,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16417
16418
|
if (amountToSell.eq(0)) {
|
|
16418
16419
|
return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
|
|
16419
16420
|
}
|
|
16420
|
-
const quote = await this.
|
|
16421
|
-
tokenToSell.address,
|
|
16422
|
-
tokenToBuy.address,
|
|
16423
|
-
amountToSell.toWei(),
|
|
16424
|
-
this.address.address
|
|
16425
|
-
);
|
|
16421
|
+
const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
|
|
16426
16422
|
if (remainingSellAmount.eq(0)) {
|
|
16427
16423
|
const minAmountOut = Web3Number.fromWei(
|
|
16428
16424
|
quote.buyAmount.toString(),
|
package/dist/index.mjs
CHANGED
|
@@ -16195,7 +16195,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16195
16195
|
}
|
|
16196
16196
|
};
|
|
16197
16197
|
}
|
|
16198
|
-
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16198
|
+
async getSwapInfoToHandleUnused(considerRebalance = true, newBounds = null, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16199
16199
|
const poolKey = await this.getPoolKey();
|
|
16200
16200
|
const unusedBalances = await this.unusedBalances(poolKey);
|
|
16201
16201
|
const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
|
|
@@ -16235,7 +16235,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16235
16235
|
token1Bal,
|
|
16236
16236
|
ekuboBounds,
|
|
16237
16237
|
maxIterations,
|
|
16238
|
-
priceRatioPrecision
|
|
16238
|
+
priceRatioPrecision,
|
|
16239
|
+
getQuoteCallback
|
|
16239
16240
|
);
|
|
16240
16241
|
}
|
|
16241
16242
|
assertValidBounds(bounds) {
|
|
@@ -16280,7 +16281,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16280
16281
|
* @returns {Promise<SwapInfo>}
|
|
16281
16282
|
*
|
|
16282
16283
|
*/
|
|
16283
|
-
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4) {
|
|
16284
|
+
async getSwapInfoGivenAmounts(poolKey, token0Bal, token1Bal, bounds, maxIterations = 20, priceRatioPrecision = 4, getQuoteCallback = this.avnu.getQuotes) {
|
|
16284
16285
|
logger.verbose(
|
|
16285
16286
|
`${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
|
|
16286
16287
|
);
|
|
@@ -16315,12 +16316,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16315
16316
|
if (amountToSell.eq(0)) {
|
|
16316
16317
|
return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
|
|
16317
16318
|
}
|
|
16318
|
-
const quote = await this.
|
|
16319
|
-
tokenToSell.address,
|
|
16320
|
-
tokenToBuy.address,
|
|
16321
|
-
amountToSell.toWei(),
|
|
16322
|
-
this.address.address
|
|
16323
|
-
);
|
|
16319
|
+
const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
|
|
16324
16320
|
if (remainingSellAmount.eq(0)) {
|
|
16325
16321
|
const minAmountOut = Web3Number.fromWei(
|
|
16326
16322
|
quote.buyAmount.toString(),
|
package/package.json
CHANGED
|
@@ -40,6 +40,7 @@ import { DepegRiskLevel, ImpermanentLossLevel, MarketRiskLevel, SmartContractRis
|
|
|
40
40
|
import { gql } from "@apollo/client";
|
|
41
41
|
import apolloClient from "@/modules/apollo-client";
|
|
42
42
|
import { binarySearch } from "@/utils/math-utils";
|
|
43
|
+
import { Quote } from "@avnu/avnu-sdk";
|
|
43
44
|
|
|
44
45
|
export interface EkuboPoolKey {
|
|
45
46
|
token0: ContractAddr;
|
|
@@ -1080,7 +1081,12 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1080
1081
|
};
|
|
1081
1082
|
}
|
|
1082
1083
|
|
|
1083
|
-
async getSwapInfoToHandleUnused(
|
|
1084
|
+
async getSwapInfoToHandleUnused(
|
|
1085
|
+
considerRebalance: boolean = true,
|
|
1086
|
+
newBounds: EkuboBounds | null = null,
|
|
1087
|
+
maxIterations = 20, priceRatioPrecision = 4,
|
|
1088
|
+
getQuoteCallback: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote> = this.avnu.getQuotes
|
|
1089
|
+
): Promise<SwapInfo> {
|
|
1084
1090
|
const poolKey = await this.getPoolKey();
|
|
1085
1091
|
|
|
1086
1092
|
// fetch current unused balances of vault
|
|
@@ -1145,7 +1151,8 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1145
1151
|
token1Bal,
|
|
1146
1152
|
ekuboBounds,
|
|
1147
1153
|
maxIterations,
|
|
1148
|
-
priceRatioPrecision
|
|
1154
|
+
priceRatioPrecision,
|
|
1155
|
+
getQuoteCallback
|
|
1149
1156
|
);
|
|
1150
1157
|
}
|
|
1151
1158
|
|
|
@@ -1229,7 +1236,8 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1229
1236
|
token1Bal: Web3Number,
|
|
1230
1237
|
bounds: EkuboBounds,
|
|
1231
1238
|
maxIterations: number = 20,
|
|
1232
|
-
priceRatioPrecision: number = 4
|
|
1239
|
+
priceRatioPrecision: number = 4,
|
|
1240
|
+
getQuoteCallback: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote> = this.avnu.getQuotes
|
|
1233
1241
|
): Promise<SwapInfo> {
|
|
1234
1242
|
logger.verbose(
|
|
1235
1243
|
`${
|
|
@@ -1284,12 +1292,7 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1284
1292
|
}
|
|
1285
1293
|
|
|
1286
1294
|
// Get a quote for swapping the calculated amount
|
|
1287
|
-
const quote = await this.
|
|
1288
|
-
tokenToSell.address,
|
|
1289
|
-
tokenToBuy.address,
|
|
1290
|
-
amountToSell.toWei(),
|
|
1291
|
-
this.address.address
|
|
1292
|
-
);
|
|
1295
|
+
const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
|
|
1293
1296
|
|
|
1294
1297
|
// If all of the token is to be swapped, return the swap info directly
|
|
1295
1298
|
if (remainingSellAmount.eq(0)) {
|