@strkfarm/sdk 1.1.51 → 1.1.53

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.
@@ -94955,6 +94955,7 @@ spurious results.`);
94955
94955
  * @param params
94956
94956
  */
94957
94957
  async getVesuMultiplyCall(params) {
94958
+ const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
94958
94959
  const vesuAdapter1 = this.getVesuSameTokenAdapter();
94959
94960
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
94960
94961
  logger2.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
@@ -94990,7 +94991,8 @@ spurious results.`);
94990
94991
  marginAmount,
94991
94992
  debtAmount,
94992
94993
  lstDexPriceInUnderlying: dexPrice,
94993
- isIncrease: debtAmount.greaterThan(0)
94994
+ isIncrease: debtAmount.greaterThan(0),
94995
+ maxEkuboPriceImpact
94994
94996
  });
94995
94997
  }
94996
94998
  getLSTUnderlyingTokenInfo() {
@@ -95167,21 +95169,17 @@ spurious results.`);
95167
95169
  // negative for exact amount out
95168
95170
  );
95169
95171
  logger2.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
95170
- assert3(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
95172
+ assert3(leverSwapQuote.price_impact <= params.maxEkuboPriceImpact, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
95171
95173
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
95172
95174
  logger2.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
95173
95175
  let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
95174
95176
  const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
95175
- if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
95176
- minLSTReceived = minLSTReceivedAsPerTruePrice;
95177
- }
95177
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
95178
95178
  logger2.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
95179
95179
  let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
95180
95180
  const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
95181
95181
  logger2.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
95182
- if (maxUsedCollateralInLST > maxUsedCollateral) {
95183
- maxUsedCollateral = maxUsedCollateralInLST;
95184
- }
95182
+ maxUsedCollateral = maxUsedCollateralInLST;
95185
95183
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
95186
95184
  const manage2Info = this.getProofs(STEP2_ID);
95187
95185
  const manageCall2 = manage2Info.callConstructor({
@@ -31048,6 +31048,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31048
31048
  * @param params
31049
31049
  */
31050
31050
  async getVesuMultiplyCall(params) {
31051
+ const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
31051
31052
  const vesuAdapter1 = this.getVesuSameTokenAdapter();
31052
31053
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
31053
31054
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
@@ -31083,7 +31084,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31083
31084
  marginAmount,
31084
31085
  debtAmount,
31085
31086
  lstDexPriceInUnderlying: dexPrice,
31086
- isIncrease: debtAmount.greaterThan(0)
31087
+ isIncrease: debtAmount.greaterThan(0),
31088
+ maxEkuboPriceImpact
31087
31089
  });
31088
31090
  }
31089
31091
  getLSTUnderlyingTokenInfo() {
@@ -31260,21 +31262,17 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31260
31262
  // negative for exact amount out
31261
31263
  );
31262
31264
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
31263
- assert(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31265
+ assert(leverSwapQuote.price_impact <= params.maxEkuboPriceImpact, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31264
31266
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
31265
31267
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
31266
31268
  let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
31267
31269
  const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
31268
- if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
31269
- minLSTReceived = minLSTReceivedAsPerTruePrice;
31270
- }
31270
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
31271
31271
  logger.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
31272
31272
  let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
31273
31273
  const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
31274
31274
  logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
31275
- if (maxUsedCollateralInLST > maxUsedCollateral) {
31276
- maxUsedCollateral = maxUsedCollateralInLST;
31277
- }
31275
+ maxUsedCollateral = maxUsedCollateralInLST;
31278
31276
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
31279
31277
  const manage2Info = this.getProofs(STEP2_ID);
31280
31278
  const manageCall2 = manage2Info.callConstructor({
package/dist/index.d.ts CHANGED
@@ -1459,6 +1459,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
1459
1459
  getVesuMultiplyCall(params: {
1460
1460
  isDeposit: boolean;
1461
1461
  leg1DepositAmount: Web3Number;
1462
+ maxEkuboPriceImpact?: number;
1462
1463
  }): Promise<Call[]>;
1463
1464
  getLSTUnderlyingTokenInfo(): TokenInfo;
1464
1465
  getMaxBorrowableAmount(params?: {
@@ -1508,6 +1509,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
1508
1509
  debtAmount: Web3Number;
1509
1510
  lstDexPriceInUnderlying: number;
1510
1511
  isIncrease: boolean;
1512
+ maxEkuboPriceImpact: number;
1511
1513
  }): Promise<Call[]>;
1512
1514
  }
1513
1515
  declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
package/dist/index.js CHANGED
@@ -31048,6 +31048,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31048
31048
  * @param params
31049
31049
  */
31050
31050
  async getVesuMultiplyCall(params) {
31051
+ const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
31051
31052
  const vesuAdapter1 = this.getVesuSameTokenAdapter();
31052
31053
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
31053
31054
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
@@ -31083,7 +31084,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31083
31084
  marginAmount,
31084
31085
  debtAmount,
31085
31086
  lstDexPriceInUnderlying: dexPrice,
31086
- isIncrease: debtAmount.greaterThan(0)
31087
+ isIncrease: debtAmount.greaterThan(0),
31088
+ maxEkuboPriceImpact
31087
31089
  });
31088
31090
  }
31089
31091
  getLSTUnderlyingTokenInfo() {
@@ -31260,21 +31262,17 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31260
31262
  // negative for exact amount out
31261
31263
  );
31262
31264
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
31263
- assert(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31265
+ assert(leverSwapQuote.price_impact <= params.maxEkuboPriceImpact, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31264
31266
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
31265
31267
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
31266
31268
  let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
31267
31269
  const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
31268
- if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
31269
- minLSTReceived = minLSTReceivedAsPerTruePrice;
31270
- }
31270
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
31271
31271
  logger.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
31272
31272
  let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
31273
31273
  const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
31274
31274
  logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
31275
- if (maxUsedCollateralInLST > maxUsedCollateral) {
31276
- maxUsedCollateral = maxUsedCollateralInLST;
31277
- }
31275
+ maxUsedCollateral = maxUsedCollateralInLST;
31278
31276
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
31279
31277
  const manage2Info = this.getProofs(STEP2_ID);
31280
31278
  const manageCall2 = manage2Info.callConstructor({
package/dist/index.mjs CHANGED
@@ -30946,6 +30946,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
30946
30946
  * @param params
30947
30947
  */
30948
30948
  async getVesuMultiplyCall(params) {
30949
+ const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
30949
30950
  const vesuAdapter1 = this.getVesuSameTokenAdapter();
30950
30951
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
30951
30952
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
@@ -30981,7 +30982,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
30981
30982
  marginAmount,
30982
30983
  debtAmount,
30983
30984
  lstDexPriceInUnderlying: dexPrice,
30984
- isIncrease: debtAmount.greaterThan(0)
30985
+ isIncrease: debtAmount.greaterThan(0),
30986
+ maxEkuboPriceImpact
30985
30987
  });
30986
30988
  }
30987
30989
  getLSTUnderlyingTokenInfo() {
@@ -31158,21 +31160,17 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
31158
31160
  // negative for exact amount out
31159
31161
  );
31160
31162
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
31161
- assert(leverSwapQuote.price_impact < 0.01, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31163
+ assert(leverSwapQuote.price_impact <= params.maxEkuboPriceImpact, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
31162
31164
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
31163
31165
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
31164
31166
  let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE);
31165
31167
  const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate);
31166
- if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
31167
- minLSTReceived = minLSTReceivedAsPerTruePrice;
31168
- }
31168
+ minLSTReceived = minLSTReceivedAsPerTruePrice;
31169
31169
  logger.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
31170
31170
  let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE);
31171
31171
  const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005);
31172
31172
  logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
31173
- if (maxUsedCollateralInLST > maxUsedCollateral) {
31174
- maxUsedCollateral = maxUsedCollateralInLST;
31175
- }
31173
+ maxUsedCollateral = maxUsedCollateralInLST;
31176
31174
  const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
31177
31175
  const manage2Info = this.getProofs(STEP2_ID);
31178
31176
  const manageCall2 = manage2Info.callConstructor({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.51",
3
+ "version": "1.1.53",
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",
@@ -427,8 +427,10 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
427
427
  */
428
428
  async getVesuMultiplyCall(params: {
429
429
  isDeposit: boolean,
430
- leg1DepositAmount: Web3Number
430
+ leg1DepositAmount: Web3Number,
431
+ maxEkuboPriceImpact?: number
431
432
  }) {
433
+ const maxEkuboPriceImpact = params.maxEkuboPriceImpact || 0.01;
432
434
  const vesuAdapter1 = this.getVesuSameTokenAdapter();
433
435
  const legLTV = await vesuAdapter1.getLTVConfig(this.config);
434
436
  logger.verbose(`${this.getTag()}::getVesuMultiplyCall legLTV: ${legLTV}`);
@@ -498,7 +500,8 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
498
500
  marginAmount,
499
501
  debtAmount,
500
502
  lstDexPriceInUnderlying: dexPrice,
501
- isIncrease: debtAmount.greaterThan(0)
503
+ isIncrease: debtAmount.greaterThan(0),
504
+ maxEkuboPriceImpact
502
505
  });
503
506
  }
504
507
 
@@ -665,7 +668,8 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
665
668
  marginAmount: Web3Number, // >0 during deposit
666
669
  debtAmount: Web3Number,
667
670
  lstDexPriceInUnderlying: number,
668
- isIncrease: boolean
671
+ isIncrease: boolean,
672
+ maxEkuboPriceImpact: number
669
673
  }): Promise<Call[]> {
670
674
  logger.verbose(`${this.getTag()}::getModifyLeverCall marginAmount: ${params.marginAmount}, debtAmount: ${params.debtAmount}, lstDexPriceInUnderlying: ${params.lstDexPriceInUnderlying}, isIncrease: ${params.isIncrease}`);
671
675
  assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), 'Deposit/debt must be non-0');
@@ -714,7 +718,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
714
718
  );
715
719
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwapQuote: ${JSON.stringify(leverSwapQuote)}`);
716
720
  // Ekubo's price impact can randomly show high numbers sometimes.
717
- assert(leverSwapQuote.price_impact < 0.01, 'getIncreaseLeverCall: Price impact is too high [Debt swap]');
721
+ assert(leverSwapQuote.price_impact <= params.maxEkuboPriceImpact, 'getIncreaseLeverCall: Price impact is too high [Debt swap]');
718
722
  const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
719
723
  logger.verbose(`${this.getTag()}::getModifyLeverCall leverSwap: ${JSON.stringify(leverSwap)}`);
720
724
 
@@ -722,18 +726,20 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
722
726
  // is Deposit
723
727
  let minLSTReceived = params.debtAmount.dividedBy(lstDexPriceInUnderlying).multipliedBy(1 - MAX_SLIPPAGE); // used for increase
724
728
  const minLSTReceivedAsPerTruePrice = params.debtAmount.dividedBy(lstTrueExchangeRate); // execution output to be <= True LST price
725
- if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
726
- minLSTReceived = minLSTReceivedAsPerTruePrice; // the execution shouldn't be bad than True price logi
727
- }
729
+ // if (minLSTReceived < minLSTReceivedAsPerTruePrice) {
730
+ // minLSTReceived = minLSTReceivedAsPerTruePrice; // the execution shouldn't be bad than True price logi
731
+ // }
732
+ minLSTReceived = minLSTReceivedAsPerTruePrice; // in any case, we are ok with this, bcz the BTC LST spread shouldnt be high
728
733
  logger.verbose(`${this.getTag()}::getModifyLeverCall minLSTReceivedAsPerTruePrice: ${minLSTReceivedAsPerTruePrice}, minLSTReceived: ${minLSTReceived}`);
729
734
 
730
735
  // is withdraw
731
736
  let maxUsedCollateral = params.debtAmount.abs().dividedBy(lstDexPriceInUnderlying).multipliedBy(1 + MAX_SLIPPAGE); // +ve for exact amount out, used for decrease
732
737
  const maxUsedCollateralInLST = params.debtAmount.abs().dividedBy(lstTrueExchangeRate).multipliedBy(1.005); // 0.5% slippage, worst case based on true price
733
738
  logger.verbose(`${this.getTag()}::getModifyLeverCall maxUsedCollateralInLST: ${maxUsedCollateralInLST}, maxUsedCollateral: ${maxUsedCollateral}`);
734
- if (maxUsedCollateralInLST > maxUsedCollateral) {
735
- maxUsedCollateral = maxUsedCollateralInLST;
736
- }
739
+ // if (maxUsedCollateralInLST > maxUsedCollateral) {
740
+ // maxUsedCollateral = maxUsedCollateralInLST;
741
+ // }
742
+ maxUsedCollateral = maxUsedCollateralInLST; // in any case, we are ok with this, bcz the BTC LST spread shouldnt be high
737
743
 
738
744
  const STEP2_ID = LST_MULTIPLIER_MANAGE_IDS.SWITCH_DELEGATION_ON;
739
745
  const manage2Info = this.getProofs<VesuModifyDelegationCallParams>(STEP2_ID);