@gearbox-protocol/sdk 3.0.0-next.180 → 3.0.0-next.182

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.
@@ -17,7 +17,7 @@ function getConvexAPYBulk(props) {
17
17
  acc.push(currentResponse);
18
18
  return [acc, end];
19
19
  }, [[], 0]);
20
- const apyList = parsedResponse.map(([cvxPoolRewardsFinish = 0n, cvxPoolRate = 0n, cvxPoolSupply = 0n, crvVPrice = 0n, cvxTokenSupply = 0n, ...rest], i) => {
20
+ const apyList = parsedResponse.map(([cvxPoolRewardsFinish, cvxPoolRate, cvxPoolSupply, crvVPrice, cvxTokenSupply, ...rest], i) => {
21
21
  const { cvxExtraPools, crvLpPrice: crvLpPriceList } = poolsInfo[i];
22
22
  const extraEnd = cvxExtraPools.length;
23
23
  const cvxExtraRewards = rest.slice(0, extraEnd);
@@ -26,11 +26,11 @@ function getConvexAPYBulk(props) {
26
26
  const lpPriceEnd = extraFinishEnd + crvLpPriceList.length;
27
27
  const crvLpPrice = rest.slice(extraFinishEnd, lpPriceEnd);
28
28
  const apy = calculateConvexAPY({
29
- cvxPoolRewardsFinish: (0, sdk_gov_1.toBigInt)(cvxPoolRewardsFinish),
30
- cvxPoolRate: (0, sdk_gov_1.toBigInt)(cvxPoolRate),
31
- cvxPoolSupply: (0, sdk_gov_1.toBigInt)(cvxPoolSupply),
32
- crvVPrice: (0, sdk_gov_1.toBigInt)(crvVPrice),
33
- cvxTokenSupply: (0, sdk_gov_1.toBigInt)(cvxTokenSupply),
29
+ cvxPoolRewardsFinish: (0, sdk_gov_1.toBigInt)(cvxPoolRewardsFinish || 0n),
30
+ cvxPoolRate: (0, sdk_gov_1.toBigInt)(cvxPoolRate || 0n),
31
+ cvxPoolSupply: (0, sdk_gov_1.toBigInt)(cvxPoolSupply || 0n),
32
+ crvVPrice: (0, sdk_gov_1.toBigInt)(crvVPrice || 0n),
33
+ cvxTokenSupply: (0, sdk_gov_1.toBigInt)(cvxTokenSupply || 0n),
34
34
  cvxExtraRewards: cvxExtraRewards.map(v => (0, sdk_gov_1.toBigInt)(v || 0n)),
35
35
  cvxExtraRewardsFinish: cvxExtraRewardsFinish.map(v => (0, sdk_gov_1.toBigInt)(v || 0n)),
36
36
  crvLpPrice: crvLpPrice.map(v => (0, sdk_gov_1.toBigInt)(v || 0n)),
@@ -60,12 +60,10 @@ export interface CalcRelativeBaseBorrowRateProps {
60
60
  debt: bigint;
61
61
  baseRateWithFee: number;
62
62
  assetAmountInUnderlying: bigint;
63
- totalValue: bigint;
64
63
  }
65
64
  export interface CalcAvgQuotaBorrowRateProps {
66
65
  quotas: Record<string, Asset>;
67
66
  quotaRates: Record<string, Pick<QuotaInfo, "isActive" | "rate">>;
68
- totalValue: bigint;
69
67
  }
70
68
  interface LiquidationPriceProps {
71
69
  liquidationThresholds: Record<string, bigint>;
@@ -127,7 +125,7 @@ export declare class CreditAccountData {
127
125
  static calcQuotaUpdate(props: CalcQuotaUpdateProps): CalcQuotaUpdateReturnType;
128
126
  private static getSingleQuotaChange;
129
127
  static calcQuotaBorrowRate({ quotas, quotaRates }: CalcQuotaBorrowRateProps): bigint;
130
- static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, totalValue, }: CalcRelativeBaseBorrowRateProps): bigint;
128
+ static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, }: CalcRelativeBaseBorrowRateProps): bigint;
131
129
  static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, }: LiquidationPriceProps): bigint;
132
130
  }
133
131
  export {};
@@ -341,10 +341,8 @@ class CreditAccountData {
341
341
  }, 0n);
342
342
  return totalRateBalance;
343
343
  }
344
- static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, totalValue, }) {
345
- if (totalValue === 0n)
346
- return 0n;
347
- return ((debt * BigInt(baseRateWithFee) * assetAmountInUnderlying) / totalValue);
344
+ static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, }) {
345
+ return debt * BigInt(baseRateWithFee) * assetAmountInUnderlying;
348
346
  }
349
347
  static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, }) {
350
348
  const underlyingTokenLC = underlyingToken.toLowerCase();
@@ -1429,25 +1429,22 @@ describe("CreditAccount calcRelativeBaseBorrowRate test", () => {
1429
1429
  debt: 200n,
1430
1430
  baseRateWithFee: 250,
1431
1431
  assetAmountInUnderlying: 200n,
1432
- totalValue: 400n,
1433
1432
  });
1434
- (0, chai_1.expect)(result).to.be.eq(25000n);
1433
+ (0, chai_1.expect)(result).to.be.eq(10000000n);
1435
1434
  });
1436
1435
  it("should calculate relative borrow rate if position asset === 0", () => {
1437
1436
  const result = creditAccount_1.CreditAccountData.calcRelativeBaseBorrowRate({
1438
1437
  debt: 200n,
1439
1438
  baseRateWithFee: 250,
1440
1439
  assetAmountInUnderlying: 1n,
1441
- totalValue: 400n,
1442
1440
  });
1443
- (0, chai_1.expect)(result).to.be.eq(125n);
1441
+ (0, chai_1.expect)(result).to.be.eq(50000n);
1444
1442
  });
1445
1443
  it("should calculate relative borrow rate if position === 0", () => {
1446
1444
  const result = creditAccount_1.CreditAccountData.calcRelativeBaseBorrowRate({
1447
1445
  debt: 1n,
1448
1446
  baseRateWithFee: 250,
1449
1447
  assetAmountInUnderlying: 1n,
1450
- totalValue: 1n,
1451
1448
  });
1452
1449
  (0, chai_1.expect)(result).to.be.eq(250n);
1453
1450
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.180",
3
+ "version": "3.0.0-next.182",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",