@strkfarm/sdk 1.1.58 → 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.
@@ -49159,6 +49159,7 @@ ${JSON.stringify(data, null, 2)}`;
49159
49159
  decimals: 8,
49160
49160
  coingeckId: void 0,
49161
49161
  displayDecimals: 6,
49162
+ priceProxySymbol: "WBTC",
49162
49163
  priceCheckAmount: 1e-3
49163
49164
  // 112000 * 0.0001 = $110.2
49164
49165
  }, {
@@ -49181,8 +49182,9 @@ ${JSON.stringify(data, null, 2)}`;
49181
49182
  decimals: 18,
49182
49183
  coingeckId: void 0,
49183
49184
  displayDecimals: 6,
49184
- priceCheckAmount: 1e-3
49185
+ priceCheckAmount: 1e-3,
49185
49186
  // 112000 * 0.0001 = $110.2
49187
+ priceProxySymbol: "WBTC"
49186
49188
  }, {
49187
49189
  name: "xLBTC",
49188
49190
  symbol: "xLBTC",
@@ -49462,6 +49464,7 @@ ${JSON.stringify(data, null, 2)}`;
49462
49464
  throw new Error("Not implemented");
49463
49465
  }
49464
49466
  async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
49467
+ logger2.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
49465
49468
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
49466
49469
  const result2 = await axios_default.get(url);
49467
49470
  const data = result2.data;
@@ -80217,7 +80220,7 @@ spurious results.`);
80217
80220
  }
80218
80221
  };
80219
80222
  }
80220
- 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) {
80221
80224
  const poolKey = await this.getPoolKey();
80222
80225
  const unusedBalances = await this.unusedBalances(poolKey);
80223
80226
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -80257,7 +80260,8 @@ spurious results.`);
80257
80260
  token1Bal,
80258
80261
  ekuboBounds,
80259
80262
  maxIterations,
80260
- priceRatioPrecision
80263
+ priceRatioPrecision,
80264
+ getQuoteCallback
80261
80265
  );
80262
80266
  }
80263
80267
  assertValidBounds(bounds) {
@@ -80302,7 +80306,7 @@ spurious results.`);
80302
80306
  * @returns {Promise<SwapInfo>}
80303
80307
  *
80304
80308
  */
80305
- 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) {
80306
80310
  logger2.verbose(
80307
80311
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
80308
80312
  );
@@ -80337,12 +80341,7 @@ spurious results.`);
80337
80341
  if (amountToSell.eq(0)) {
80338
80342
  return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
80339
80343
  }
80340
- const quote = await this.avnu.getQuotes(
80341
- tokenToSell.address,
80342
- tokenToBuy.address,
80343
- amountToSell.toWei(),
80344
- this.address.address
80345
- );
80344
+ const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
80346
80345
  if (remainingSellAmount.eq(0)) {
80347
80346
  const minAmountOut = Web3Number.fromWei(
80348
80347
  quote.buyAmount.toString(),
@@ -239,6 +239,7 @@ var defaultTokens = [{
239
239
  decimals: 8,
240
240
  coingeckId: void 0,
241
241
  displayDecimals: 6,
242
+ priceProxySymbol: "WBTC",
242
243
  priceCheckAmount: 1e-3
243
244
  // 112000 * 0.0001 = $110.2
244
245
  }, {
@@ -261,8 +262,9 @@ var defaultTokens = [{
261
262
  decimals: 18,
262
263
  coingeckId: void 0,
263
264
  displayDecimals: 6,
264
- priceCheckAmount: 1e-3
265
+ priceCheckAmount: 1e-3,
265
266
  // 112000 * 0.0001 = $110.2
267
+ priceProxySymbol: "WBTC"
266
268
  }, {
267
269
  name: "xLBTC",
268
270
  symbol: "xLBTC",
@@ -542,6 +544,7 @@ var Pricer = class extends PricerBase {
542
544
  throw new Error("Not implemented");
543
545
  }
544
546
  async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
547
+ logger.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
545
548
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
546
549
  const result = await axios2.get(url);
547
550
  const data = result.data;
@@ -16294,7 +16297,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16294
16297
  }
16295
16298
  };
16296
16299
  }
16297
- 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) {
16298
16301
  const poolKey = await this.getPoolKey();
16299
16302
  const unusedBalances = await this.unusedBalances(poolKey);
16300
16303
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -16334,7 +16337,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16334
16337
  token1Bal,
16335
16338
  ekuboBounds,
16336
16339
  maxIterations,
16337
- priceRatioPrecision
16340
+ priceRatioPrecision,
16341
+ getQuoteCallback
16338
16342
  );
16339
16343
  }
16340
16344
  assertValidBounds(bounds) {
@@ -16379,7 +16383,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16379
16383
  * @returns {Promise<SwapInfo>}
16380
16384
  *
16381
16385
  */
16382
- 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) {
16383
16387
  logger.verbose(
16384
16388
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
16385
16389
  );
@@ -16414,12 +16418,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16414
16418
  if (amountToSell.eq(0)) {
16415
16419
  return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
16416
16420
  }
16417
- const quote = await this.avnu.getQuotes(
16418
- tokenToSell.address,
16419
- tokenToBuy.address,
16420
- amountToSell.toWei(),
16421
- this.address.address
16422
- );
16421
+ const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
16423
16422
  if (remainingSellAmount.eq(0)) {
16424
16423
  const minAmountOut = Web3Number.fromWei(
16425
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
@@ -386,6 +386,7 @@ var defaultTokens = [{
386
386
  decimals: 8,
387
387
  coingeckId: void 0,
388
388
  displayDecimals: 6,
389
+ priceProxySymbol: "WBTC",
389
390
  priceCheckAmount: 1e-3
390
391
  // 112000 * 0.0001 = $110.2
391
392
  }, {
@@ -408,8 +409,9 @@ var defaultTokens = [{
408
409
  decimals: 18,
409
410
  coingeckId: void 0,
410
411
  displayDecimals: 6,
411
- priceCheckAmount: 1e-3
412
+ priceCheckAmount: 1e-3,
412
413
  // 112000 * 0.0001 = $110.2
414
+ priceProxySymbol: "WBTC"
413
415
  }, {
414
416
  name: "xLBTC",
415
417
  symbol: "xLBTC",
@@ -689,6 +691,7 @@ var Pricer = class extends PricerBase {
689
691
  throw new Error("Not implemented");
690
692
  }
691
693
  async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
694
+ logger.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
692
695
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
693
696
  const result = await import_axios2.default.get(url);
694
697
  const data = result.data;
@@ -16294,7 +16297,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16294
16297
  }
16295
16298
  };
16296
16299
  }
16297
- 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) {
16298
16301
  const poolKey = await this.getPoolKey();
16299
16302
  const unusedBalances = await this.unusedBalances(poolKey);
16300
16303
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -16334,7 +16337,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16334
16337
  token1Bal,
16335
16338
  ekuboBounds,
16336
16339
  maxIterations,
16337
- priceRatioPrecision
16340
+ priceRatioPrecision,
16341
+ getQuoteCallback
16338
16342
  );
16339
16343
  }
16340
16344
  assertValidBounds(bounds) {
@@ -16379,7 +16383,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16379
16383
  * @returns {Promise<SwapInfo>}
16380
16384
  *
16381
16385
  */
16382
- 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) {
16383
16387
  logger.verbose(
16384
16388
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
16385
16389
  );
@@ -16414,12 +16418,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16414
16418
  if (amountToSell.eq(0)) {
16415
16419
  return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
16416
16420
  }
16417
- const quote = await this.avnu.getQuotes(
16418
- tokenToSell.address,
16419
- tokenToBuy.address,
16420
- amountToSell.toWei(),
16421
- this.address.address
16422
- );
16421
+ const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
16423
16422
  if (remainingSellAmount.eq(0)) {
16424
16423
  const minAmountOut = Web3Number.fromWei(
16425
16424
  quote.buyAmount.toString(),
package/dist/index.mjs CHANGED
@@ -280,6 +280,7 @@ var defaultTokens = [{
280
280
  decimals: 8,
281
281
  coingeckId: void 0,
282
282
  displayDecimals: 6,
283
+ priceProxySymbol: "WBTC",
283
284
  priceCheckAmount: 1e-3
284
285
  // 112000 * 0.0001 = $110.2
285
286
  }, {
@@ -302,8 +303,9 @@ var defaultTokens = [{
302
303
  decimals: 18,
303
304
  coingeckId: void 0,
304
305
  displayDecimals: 6,
305
- priceCheckAmount: 1e-3
306
+ priceCheckAmount: 1e-3,
306
307
  // 112000 * 0.0001 = $110.2
308
+ priceProxySymbol: "WBTC"
307
309
  }, {
308
310
  name: "xLBTC",
309
311
  symbol: "xLBTC",
@@ -583,6 +585,7 @@ var Pricer = class extends PricerBase {
583
585
  throw new Error("Not implemented");
584
586
  }
585
587
  async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
588
+ logger.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
586
589
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
587
590
  const result = await axios2.get(url);
588
591
  const data = result.data;
@@ -16192,7 +16195,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16192
16195
  }
16193
16196
  };
16194
16197
  }
16195
- 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) {
16196
16199
  const poolKey = await this.getPoolKey();
16197
16200
  const unusedBalances = await this.unusedBalances(poolKey);
16198
16201
  const { amount: token0Bal1, usdValue: token0PriceUsd } = unusedBalances.token0;
@@ -16232,7 +16235,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16232
16235
  token1Bal,
16233
16236
  ekuboBounds,
16234
16237
  maxIterations,
16235
- priceRatioPrecision
16238
+ priceRatioPrecision,
16239
+ getQuoteCallback
16236
16240
  );
16237
16241
  }
16238
16242
  assertValidBounds(bounds) {
@@ -16277,7 +16281,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16277
16281
  * @returns {Promise<SwapInfo>}
16278
16282
  *
16279
16283
  */
16280
- 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) {
16281
16285
  logger.verbose(
16282
16286
  `${_EkuboCLVault.name}: getSwapInfoGivenAmounts::pre => token0Bal: ${token0Bal.toString()}, token1Bal: ${token1Bal.toString()}`
16283
16287
  );
@@ -16312,12 +16316,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16312
16316
  if (amountToSell.eq(0)) {
16313
16317
  return AvnuWrapper.buildZeroSwap(tokenToSell, this.address.address);
16314
16318
  }
16315
- const quote = await this.avnu.getQuotes(
16316
- tokenToSell.address,
16317
- tokenToBuy.address,
16318
- amountToSell.toWei(),
16319
- this.address.address
16320
- );
16319
+ const quote = await getQuoteCallback(tokenToSell.address, tokenToBuy.address, amountToSell.toWei(), this.address.address);
16321
16320
  if (remainingSellAmount.eq(0)) {
16322
16321
  const minAmountOut = Web3Number.fromWei(
16323
16322
  quote.buyAmount.toString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.58",
3
+ "version": "1.1.60",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
package/src/global.ts CHANGED
@@ -105,6 +105,7 @@ const defaultTokens: TokenInfo[] = [{
105
105
  decimals: 8,
106
106
  coingeckId: undefined,
107
107
  displayDecimals: 6,
108
+ priceProxySymbol: 'WBTC',
108
109
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
109
110
  }, {
110
111
  name: 'xsBTC',
@@ -126,6 +127,7 @@ const defaultTokens: TokenInfo[] = [{
126
127
  coingeckId: undefined,
127
128
  displayDecimals: 6,
128
129
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
130
+ priceProxySymbol: 'WBTC',
129
131
  }, {
130
132
  name: 'xLBTC',
131
133
  symbol: 'xLBTC',
@@ -201,6 +201,7 @@ export class Pricer extends PricerBase {
201
201
  }
202
202
 
203
203
  async _getPriceEkubo(token: TokenInfo, amountIn = new Web3Number(1, token.decimals), retry = 0): Promise<number> {
204
+ logger.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
204
205
  const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
205
206
  const result = await axios.get(url);
206
207
  const data: any = result.data;
@@ -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(considerRebalance: boolean = true, newBounds: EkuboBounds | null = null, maxIterations = 20, priceRatioPrecision = 4): Promise<SwapInfo> {
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.avnu.getQuotes(
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)) {