@gearbox-protocol/sdk 3.0.0-next.246 → 3.0.0-next.248

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.
@@ -62,6 +62,8 @@ import {IPriceFeed} from "@gearbox-protocol/core-v2/contracts/interfaces/IPriceF
62
62
  import {ILPPriceFeed} from "@gearbox-protocol/oracles-v3/contracts/interfaces/ILPPriceFeed.sol";
63
63
  import {RedstonePriceFeed} from "@gearbox-protocol/oracles-v3/contracts/oracles/updatable/RedstonePriceFeed.sol";
64
64
  import {CompositePriceFeed} from "@gearbox-protocol/oracles-v3/contracts/oracles/CompositePriceFeed.sol";
65
+ // import {PendleTWAPPTPriceFeed} from "@gearbox-protocol/oracles-v3/contracts/oracles/pendle/PendleTWAPPTPriceFeed.sol";
66
+
65
67
 
66
68
  import {ICurveV1_2AssetsAdapter} from
67
69
  "@gearbox-protocol/integrations-v3/contracts/interfaces/curve/ICurveV1_2AssetsAdapter.sol";
@@ -74,6 +76,8 @@ import {ICurveV1_4AssetsAdapter} from
74
76
 
75
77
  import {IStakingRewardsAdapter} from
76
78
  "@gearbox-protocol/integrations-v3/contracts/interfaces/sky/IStakingRewardsAdapter.sol";
79
+
80
+
77
81
 
78
82
 
79
83
 
@@ -17,12 +17,14 @@ export interface CalcOverallAPYProps {
17
17
  debt: bigint | undefined;
18
18
  baseRateWithFee: number;
19
19
  underlyingToken: Address;
20
+ tokensList: Record<Address, TokenData>;
20
21
  }
21
22
  export interface CalcMaxLendingDebtProps {
22
23
  assets: Array<Asset>;
23
24
  prices: Record<Address, bigint>;
24
25
  liquidationThresholds: Record<Address, bigint>;
25
26
  underlyingToken: Address;
27
+ tokensList: Record<Address, TokenData>;
26
28
  targetHF?: bigint;
27
29
  }
28
30
  export interface CalcHealthFactorProps {
@@ -33,6 +35,7 @@ export interface CalcHealthFactorProps {
33
35
  liquidationThresholds: Record<Address, bigint>;
34
36
  underlyingToken: Address;
35
37
  debt: bigint;
38
+ tokensList: Record<Address, TokenData>;
36
39
  }
37
40
  export interface CalcDefaultQuotaProps {
38
41
  amount: bigint;
@@ -83,6 +86,7 @@ interface LiquidationPriceProps {
83
86
  underlyingToken: Address;
84
87
  targetToken: Address;
85
88
  assets: Record<Address, Asset>;
89
+ tokensList: Record<Address, TokenData>;
86
90
  }
87
91
  export interface TimeToLiquidationProps {
88
92
  totalBorrowRate_debt: bigint;
@@ -126,11 +130,11 @@ export declare class CreditAccountData {
126
130
  isQuoted(token: Address): boolean;
127
131
  isTokenEnabled(token: Address): boolean;
128
132
  static calcMaxDebtIncrease(healthFactor: number, debt: bigint, underlyingLT: number, minHf?: number): bigint;
129
- static calcMaxLendingDebt({ assets, liquidationThresholds, underlyingToken, prices, targetHF, }: CalcMaxLendingDebtProps): bigint;
130
- static calcOverallAPY({ caAssets, lpAPY, prices, quotas, quotaRates, feeInterest, totalValue, debt, baseRateWithFee, underlyingToken, }: CalcOverallAPYProps): bigint | undefined;
133
+ static calcMaxLendingDebt({ assets, liquidationThresholds, underlyingToken, prices, tokensList, targetHF, }: CalcMaxLendingDebtProps): bigint;
134
+ static calcOverallAPY({ caAssets, lpAPY, prices, quotas, quotaRates, feeInterest, totalValue, debt, baseRateWithFee, underlyingToken, tokensList, }: CalcOverallAPYProps): bigint | undefined;
131
135
  hash(): string;
132
136
  static hash(creditManager: Address, borrower: Address): string;
133
- static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, }: CalcHealthFactorProps): number;
137
+ static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, tokensList, }: CalcHealthFactorProps): number;
134
138
  static roundUpQuota(quotaChange: bigint): bigint;
135
139
  static calcRecommendedQuota({ amount, debt, lt, quotaReserve, }: CalcRecommendedQuotaProps): bigint;
136
140
  static calcDefaultQuota({ amount, lt, quotaReserve }: CalcDefaultQuotaProps): bigint;
@@ -138,7 +142,7 @@ export declare class CreditAccountData {
138
142
  private static getSingleQuotaChange;
139
143
  static calcQuotaBorrowRate({ quotas, quotaRates }: CalcQuotaBorrowRateProps): bigint;
140
144
  static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, }: CalcRelativeBaseBorrowRateProps): bigint;
141
- static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, }: LiquidationPriceProps): bigint;
145
+ static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, tokensList, }: LiquidationPriceProps): bigint;
142
146
  /**
143
147
  * Calculates the time remaining until liquidation for a credit account.
144
148
  * @returns The time remaining until liquidation in milliseconds.
@@ -155,9 +155,9 @@ class CreditAccountData {
155
155
  const result = (debt * BigInt(healthFactor - minHf)) / BigInt(minHf - underlyingLT);
156
156
  return math_1.BigIntMath.max(0n, result);
157
157
  }
158
- static calcMaxLendingDebt({ assets, liquidationThresholds, underlyingToken, prices, targetHF = sdk_gov_1.PERCENTAGE_FACTOR, }) {
158
+ static calcMaxLendingDebt({ assets, liquidationThresholds, underlyingToken, prices, tokensList, targetHF = sdk_gov_1.PERCENTAGE_FACTOR, }) {
159
159
  const assetsLTMoney = assets.reduce((acc, { token: tokenAddress, balance: amount }) => {
160
- const [, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(tokenAddress);
160
+ const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
161
161
  const lt = liquidationThresholds[tokenAddress] || 0n;
162
162
  const price = prices[tokenAddress] || 0n;
163
163
  const tokenMoney = price_1.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
@@ -165,7 +165,7 @@ class CreditAccountData {
165
165
  return acc + tokenLtMoney;
166
166
  }, 0n);
167
167
  const underlyingPrice = prices[underlyingToken] || 0n;
168
- const [, underlyingDecimals = 18] = (0, sdk_gov_1.extractTokenData)(underlyingToken);
168
+ const underlyingDecimals = tokensList[underlyingToken]?.decimals || 18;
169
169
  // HF = TWV / D => D = TWV / HF; D = amount * price
170
170
  // Debt_max = sum(LT_i * Asset_i * price_i) / (price_underlying * HF)
171
171
  const max = underlyingPrice > 0
@@ -176,26 +176,24 @@ class CreditAccountData {
176
176
  : 0n;
177
177
  return max;
178
178
  }
179
- static calcOverallAPY({ caAssets, lpAPY, prices, quotas, quotaRates, feeInterest, totalValue, debt, baseRateWithFee, underlyingToken, }) {
179
+ static calcOverallAPY({ caAssets, lpAPY, prices, quotas, quotaRates, feeInterest, totalValue, debt, baseRateWithFee, underlyingToken, tokensList, }) {
180
180
  if (!lpAPY ||
181
181
  !totalValue ||
182
182
  totalValue <= 0n ||
183
183
  !debt ||
184
184
  totalValue <= debt)
185
185
  return undefined;
186
- const underlyingTokenAddressLC = underlyingToken.toLowerCase();
187
- const underlyingTokenSymbol = sdk_gov_1.tokenSymbolByAddress[underlyingTokenAddressLC] || "";
186
+ const underlyingTokenSymbol = sdk_gov_1.tokenSymbolByAddress[underlyingToken] || "";
188
187
  const underlyingTokenDecimals = sdk_gov_1.decimals[underlyingTokenSymbol] || 18;
189
- const underlyingPrice = prices[underlyingTokenAddressLC];
188
+ const underlyingPrice = prices[underlyingToken];
190
189
  const assetAPYMoney = caAssets.reduce((acc, { token: tokenAddress, balance: amount }) => {
191
- const tokenAddressLC = tokenAddress.toLowerCase();
192
- const [symbol = "", tokenDecimals] = (0, sdk_gov_1.extractTokenData)(tokenAddressLC);
190
+ const { symbol = "", decimals: tokenDecimals = 18 } = tokensList[tokenAddress] || {};
193
191
  const apy = lpAPY[symbol] || 0;
194
- const price = prices[tokenAddressLC] || 0n;
192
+ const price = prices[tokenAddress] || 0n;
195
193
  const money = price_1.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
196
194
  const apyMoney = money * BigInt(apy);
197
- const { rate: quotaAPY = 0n, isActive = false } = quotaRates?.[tokenAddressLC] || {};
198
- const { balance: quotaBalance = 0n } = quotas[tokenAddressLC] || {};
195
+ const { rate: quotaAPY = 0n, isActive = false } = quotaRates?.[tokenAddress] || {};
196
+ const { balance: quotaBalance = 0n } = quotas[tokenAddress] || {};
199
197
  const quotaAmount = isActive ? quotaBalance : 0n;
200
198
  const quotaMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice || 0n, quotaAmount, underlyingTokenDecimals);
201
199
  const quotaRate = (quotaAPY * (BigInt(feeInterest) + sdk_gov_1.PERCENTAGE_FACTOR)) /
@@ -218,13 +216,13 @@ class CreditAccountData {
218
216
  static hash(creditManager, borrower) {
219
217
  return `${creditManager.toLowerCase()}:${borrower.toLowerCase()}`;
220
218
  }
221
- static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, }) {
219
+ static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, tokensList, }) {
222
220
  if (debt === 0n)
223
221
  return MAX_UINT16;
224
- const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(underlyingToken);
222
+ const underlyingDecimals = tokensList[underlyingToken]?.decimals || 18;
225
223
  const underlyingPrice = prices[underlyingToken] || 0n;
226
224
  const assetMoney = assets.reduce((acc, { token: tokenAddress, balance: amount }) => {
227
- const [, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(tokenAddress);
225
+ const tokenDecimals = tokensList[tokenAddress]?.decimals || 18;
228
226
  const lt = liquidationThresholds[tokenAddress] || 0n;
229
227
  const price = prices[tokenAddress] || 0n;
230
228
  const tokenMoney = price_1.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
@@ -369,19 +367,17 @@ class CreditAccountData {
369
367
  static calcRelativeBaseBorrowRate({ debt, baseRateWithFee, assetAmountInUnderlying, }) {
370
368
  return debt * BigInt(baseRateWithFee) * assetAmountInUnderlying;
371
369
  }
372
- static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, }) {
373
- const underlyingTokenLC = underlyingToken.toLowerCase();
374
- const [, underlyingDecimals = 18] = (0, sdk_gov_1.extractTokenData)(underlyingTokenLC);
375
- const { balance: underlyingBalance = 0n } = assets[underlyingTokenLC] || {};
370
+ static liquidationPrice({ liquidationThresholds, debt, underlyingToken, targetToken, assets, tokensList, }) {
371
+ const underlyingDecimals = tokensList[underlyingToken]?.decimals || 18;
372
+ const { balance: underlyingBalance = 0n } = assets[underlyingToken] || {};
376
373
  // effectiveDebt = Debt - underlyingBalance*LTunderlying
377
- const ltUnderlying = liquidationThresholds[underlyingTokenLC] || 0n;
374
+ const ltUnderlying = liquidationThresholds[underlyingToken] || 0n;
378
375
  const effectiveDebt = ((debt - (underlyingBalance * ltUnderlying) / sdk_gov_1.PERCENTAGE_FACTOR) * sdk_gov_1.WAD) /
379
376
  10n ** BigInt(underlyingDecimals);
380
- const targetTokenLC = targetToken.toLowerCase();
381
- const [, targetDecimals = 18] = (0, sdk_gov_1.extractTokenData)(targetTokenLC);
382
- const { balance: targetBalance = 0n } = assets[targetTokenLC] || {};
377
+ const targetDecimals = tokensList[targetToken]?.decimals || 18;
378
+ const { balance: targetBalance = 0n } = assets[targetToken] || {};
383
379
  const effectiveTargetBalance = (targetBalance * sdk_gov_1.WAD) / 10n ** BigInt(targetDecimals);
384
- const lpLT = liquidationThresholds[targetTokenLC] || 0n;
380
+ const lpLT = liquidationThresholds[targetToken] || 0n;
385
381
  if (targetBalance <= 0n || lpLT <= 0n)
386
382
  return 0n;
387
383
  // priceTarget = effectiveDebt / (lpLT*targetBalance)
@@ -2,10 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
4
4
  const chai_1 = require("chai");
5
+ const tokenData_1 = require("../tokens/tokenData");
5
6
  const formatter_1 = require("../utils/formatter");
6
7
  const price_1 = require("../utils/price");
7
8
  const assets_1 = require("./assets");
8
9
  const creditAccount_1 = require("./creditAccount");
10
+ const tokensFiltered = sdk_gov_1.TypedObjectUtils.fromEntries(sdk_gov_1.TypedObjectUtils.entries(sdk_gov_1.tokenDataByNetwork.Mainnet).filter(([_, address]) => !!address && address !== sdk_gov_1.NOT_DEPLOYED));
11
+ const tokenDataList = sdk_gov_1.TypedObjectUtils.fromEntries(sdk_gov_1.TypedObjectUtils.entries(tokensFiltered).map(([tokenSymbol, addr]) => {
12
+ const data = sdk_gov_1.supportedTokens[tokenSymbol];
13
+ return [
14
+ addr.toLowerCase(),
15
+ new tokenData_1.TokenData({
16
+ ...data,
17
+ addr,
18
+ decimals: sdk_gov_1.decimals[tokenSymbol],
19
+ }),
20
+ ];
21
+ }));
9
22
  const prices = {
10
23
  [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: (0, formatter_1.toBN)("1738.11830000", sdk_gov_1.PRICE_DECIMALS_POW),
11
24
  [sdk_gov_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: (0, formatter_1.toBN)("0.99941103", sdk_gov_1.PRICE_DECIMALS_POW),
@@ -82,6 +95,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
82
95
  feeInterest: 0,
83
96
  lpAPY,
84
97
  prices,
98
+ tokensList: tokenDataList,
85
99
  });
86
100
  (0, chai_1.expect)(result).to.be.eq(-69484n);
87
101
  });
@@ -97,6 +111,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
97
111
  feeInterest: 0,
98
112
  lpAPY,
99
113
  prices,
114
+ tokensList: tokenDataList,
100
115
  });
101
116
  (0, chai_1.expect)(result).to.be.eq(144919n);
102
117
  });
@@ -112,6 +127,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
112
127
  feeInterest: 0,
113
128
  lpAPY: undefined,
114
129
  prices,
130
+ tokensList: tokenDataList,
115
131
  });
116
132
  (0, chai_1.expect)(result).to.be.eq(undefined);
117
133
  });
@@ -127,6 +143,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
127
143
  feeInterest: 0,
128
144
  lpAPY,
129
145
  prices,
146
+ tokensList: tokenDataList,
130
147
  });
131
148
  (0, chai_1.expect)(result).to.be.eq(undefined);
132
149
  });
@@ -142,6 +159,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
142
159
  feeInterest: 0,
143
160
  lpAPY,
144
161
  prices,
162
+ tokensList: tokenDataList,
145
163
  });
146
164
  (0, chai_1.expect)(result).to.be.eq(undefined);
147
165
  });
@@ -157,6 +175,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
157
175
  feeInterest: 0,
158
176
  lpAPY,
159
177
  prices,
178
+ tokensList: tokenDataList,
160
179
  });
161
180
  (0, chai_1.expect)(result).to.be.eq(undefined);
162
181
  });
@@ -172,6 +191,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
172
191
  feeInterest: 0,
173
192
  lpAPY,
174
193
  prices,
194
+ tokensList: tokenDataList,
175
195
  });
176
196
  (0, chai_1.expect)(result).to.be.eq(-18680n);
177
197
  });
@@ -192,6 +212,7 @@ describe("CreditAccount CreditAccountData.calcOverallAPY test", () => {
192
212
  feeInterest: 0,
193
213
  lpAPY,
194
214
  prices,
215
+ tokensList: tokenDataList,
195
216
  });
196
217
  (0, chai_1.expect)(result).to.be.eq(144919n);
197
218
  });
@@ -240,6 +261,7 @@ describe("CreditAccount calcMaxLendingDebt test", () => {
240
261
  [sdk_gov_1.tokenDataByNetwork.Mainnet.USDC.toLowerCase()]: 1n,
241
262
  [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 1000n,
242
263
  },
264
+ tokensList: tokenDataList,
243
265
  });
244
266
  (0, chai_1.expect)(result).to.be.eq((0, formatter_1.toBN)("850", sdk_gov_1.decimals.USDC));
245
267
  });
@@ -261,6 +283,7 @@ describe("CreditAccount calcMaxLendingDebt test", () => {
261
283
  [sdk_gov_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: 1n,
262
284
  [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 1000n,
263
285
  },
286
+ tokensList: tokenDataList,
264
287
  });
265
288
  (0, chai_1.expect)(result).to.be.eq(0n);
266
289
  });
@@ -278,6 +301,7 @@ describe("CreditAccount calcMaxLendingDebt test", () => {
278
301
  [sdk_gov_1.tokenDataByNetwork.Mainnet.DAI.toLowerCase()]: 1n,
279
302
  [sdk_gov_1.tokenDataByNetwork.Mainnet.USDC.toLowerCase()]: 1n,
280
303
  },
304
+ tokensList: tokenDataList,
281
305
  });
282
306
  (0, chai_1.expect)(result).to.be.eq((0, formatter_1.toBN)("930", sdk_gov_1.decimals.USDC));
283
307
  });
@@ -300,6 +324,7 @@ describe("CreditAccount calcMaxLendingDebt test", () => {
300
324
  [sdk_gov_1.tokenDataByNetwork.Mainnet.USDC.toLowerCase()]: 1n,
301
325
  [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 1000n,
302
326
  },
327
+ tokensList: tokenDataList,
303
328
  });
304
329
  (0, chai_1.expect)(result).to.be.eq((0, formatter_1.toBN)("1780", sdk_gov_1.decimals.USDC));
305
330
  });
@@ -323,6 +348,7 @@ describe("CreditAccount calcMaxLendingDebt test", () => {
323
348
  [sdk_gov_1.tokenDataByNetwork.Mainnet.WETH.toLowerCase()]: 1000n,
324
349
  },
325
350
  targetHF: 12500n,
351
+ tokensList: tokenDataList,
326
352
  });
327
353
  (0, chai_1.expect)(result).to.be.eq((0, formatter_1.toBN)("1424", sdk_gov_1.decimals.USDC));
328
354
  });
@@ -364,6 +390,7 @@ describe("CreditAccount calcHealthFactor test", () => {
364
390
  liquidationThresholds,
365
391
  underlyingToken: defaultCA.underlyingToken,
366
392
  debt: defaultCA.debt,
393
+ tokensList: tokenDataList,
367
394
  });
368
395
  (0, chai_1.expect)(result).to.be.eq(defaultCA.healthFactor);
369
396
  });
@@ -376,6 +403,7 @@ describe("CreditAccount calcHealthFactor test", () => {
376
403
  liquidationThresholds: {},
377
404
  underlyingToken: "",
378
405
  debt: 0n,
406
+ tokensList: tokenDataList,
379
407
  });
380
408
  (0, chai_1.expect)(result).to.be.eq(65535);
381
409
  });
@@ -393,6 +421,7 @@ describe("CreditAccount calcHealthFactor test", () => {
393
421
  liquidationThresholds,
394
422
  underlyingToken: defaultCA.underlyingToken,
395
423
  debt: defaultCA.debt,
424
+ tokensList: tokenDataList,
396
425
  });
397
426
  (0, chai_1.expect)(result).to.be.eq(11188);
398
427
  });
@@ -413,6 +442,7 @@ describe("CreditAccount calcHealthFactor test", () => {
413
442
  liquidationThresholds,
414
443
  underlyingToken: defaultCA.underlyingToken,
415
444
  debt: defaultCA.debt - amountDecrease,
445
+ tokensList: tokenDataList,
416
446
  });
417
447
  (0, chai_1.expect)(result).to.be.eq(10308);
418
448
  });
@@ -433,6 +463,7 @@ describe("CreditAccount calcHealthFactor test", () => {
433
463
  liquidationThresholds,
434
464
  underlyingToken: defaultCA.underlyingToken,
435
465
  debt: defaultCA.debt + amountIncrease,
466
+ tokensList: tokenDataList,
436
467
  });
437
468
  (0, chai_1.expect)(result).to.be.eq(10137);
438
469
  });
@@ -458,6 +489,7 @@ describe("CreditAccount calcHealthFactor test", () => {
458
489
  liquidationThresholds,
459
490
  underlyingToken: defaultCA.underlyingToken,
460
491
  debt: defaultCA.debt,
492
+ tokensList: tokenDataList,
461
493
  });
462
494
  (0, chai_1.expect)(result).to.be.eq(9444);
463
495
  });
@@ -470,6 +502,7 @@ describe("CreditAccount calcHealthFactor test", () => {
470
502
  liquidationThresholds,
471
503
  underlyingToken: defaultCA.underlyingToken,
472
504
  debt: defaultCA.debt,
505
+ tokensList: tokenDataList,
473
506
  });
474
507
  (0, chai_1.expect)(result).to.be.eq(defaultCA.healthFactor);
475
508
  });
@@ -487,6 +520,7 @@ describe("CreditAccount calcHealthFactor test", () => {
487
520
  liquidationThresholds,
488
521
  underlyingToken: defaultCA.underlyingToken,
489
522
  debt: defaultCA.debt,
523
+ tokensList: tokenDataList,
490
524
  });
491
525
  (0, chai_1.expect)(result).to.be.eq(9300);
492
526
  });
@@ -503,6 +537,7 @@ describe("CreditAccount calcHealthFactor test", () => {
503
537
  liquidationThresholds,
504
538
  underlyingToken: defaultCA.underlyingToken,
505
539
  debt: defaultCA.debt,
540
+ tokensList: tokenDataList,
506
541
  });
507
542
  (0, chai_1.expect)(result).to.be.eq(9300);
508
543
  });
@@ -1,5 +1,6 @@
1
1
  import { NetworkType, SupportedToken } from "@gearbox-protocol/sdk-gov";
2
2
  import { Address, PublicClient, WalletClient } from "viem";
3
+ import { TokenData } from "../tokens/tokenData";
3
4
  export interface GearboxExtraMerkleLmReward {
4
5
  poolToken: Address;
5
6
  rewardToken: Address;
@@ -39,6 +40,7 @@ type PoolsWithExtraRewardsList = Record<NetworkType, Array<SupportedToken>>;
39
40
  type ReportHandler = (e: unknown, description?: string) => void;
40
41
  export interface GetLmRewardsInfoProps {
41
42
  currentTokenData: Record<SupportedToken, Address>;
43
+ tokensList: Record<Address, TokenData>;
42
44
  provider: PublicClient;
43
45
  multicallAddress: Address;
44
46
  poolsWithExtraRewards?: PoolsWithExtraRewardsList;
@@ -67,7 +69,7 @@ export interface ClaimLmRewardsV3Props {
67
69
  signer: WalletClient;
68
70
  }
69
71
  export declare class GearboxRewardsApi {
70
- static getLmRewardsInfo({ currentTokenData, provider, multicallAddress, poolsWithExtraRewards, network, reportError, }: GetLmRewardsInfoProps): Promise<{
72
+ static getLmRewardsInfo({ currentTokenData, provider, multicallAddress, tokensList, poolsWithExtraRewards, network, reportError, }: GetLmRewardsInfoProps): Promise<{
71
73
  rewardPoolsInfo: Record<string, FarmInfo[]>;
72
74
  baseRewardPoolsInfo: Record<string, FarmInfo>;
73
75
  extraRewardPoolsInfo: Record<string, FarmInfo[]>;
@@ -19,7 +19,7 @@ const DEFAULT_POOLS_WITH_EXTRA_REWARDS = {
19
19
  Base: [],
20
20
  };
21
21
  class GearboxRewardsApi {
22
- static async getLmRewardsInfo({ currentTokenData, provider, multicallAddress, poolsWithExtraRewards = DEFAULT_POOLS_WITH_EXTRA_REWARDS, network, reportError, }) {
22
+ static async getLmRewardsInfo({ currentTokenData, provider, multicallAddress, tokensList, poolsWithExtraRewards = DEFAULT_POOLS_WITH_EXTRA_REWARDS, network, reportError, }) {
23
23
  const poolTokens = sdk_gov_1.TypedObjectUtils.entries(currentTokenData).filter(([symbol]) => (0, sdk_gov_1.isDieselStakedToken)(symbol));
24
24
  const farmInfoCalls = poolTokens.map(([, address]) => ({
25
25
  address,
@@ -88,15 +88,15 @@ class GearboxRewardsApi {
88
88
  const finished = (0, sdk_gov_1.toBigInt)(d.endTimestamp || 0);
89
89
  if (blockTimestamp >= started && blockTimestamp <= finished) {
90
90
  const rewardTokenLc = (d.rewardToken || "").toLowerCase();
91
- const [rewardSymbol, decimals = 18] = (0, sdk_gov_1.extractTokenData)(rewardTokenLc);
92
- const reward = (0, formatter_1.toBN)(d.amountDecimal, decimals);
93
- if (rewardSymbol && reward > 0) {
91
+ const rewardTokenData = tokensList[rewardTokenLc];
92
+ const reward = (0, formatter_1.toBN)(d.amountDecimal, rewardTokenData?.decimals || 18);
93
+ if (rewardTokenData && reward > 0) {
94
94
  infos.push({
95
95
  duration: (0, sdk_gov_1.toBigInt)(d.endTimestamp - d.startTimestamp),
96
96
  finished,
97
97
  reward,
98
98
  balance: 0n,
99
- symbol: rewardSymbol,
99
+ symbol: rewardTokenData.symbol,
100
100
  });
101
101
  }
102
102
  }
@@ -109,14 +109,15 @@ class GearboxRewardsApi {
109
109
  }, {});
110
110
  const rewardPoolsInfo = poolTokens.reduce((acc, [, address], i) => {
111
111
  const currentInfo = farmInfo[i];
112
- const [symbol] = (0, sdk_gov_1.extractTokenData)(rewardTokens[i] || "");
113
- if (symbol) {
112
+ const poolBaseRewardTokenLc = (rewardTokens[i] || "").toLowerCase();
113
+ const tokenData = tokensList[poolBaseRewardTokenLc];
114
+ if (tokenData) {
114
115
  const baseReward = {
115
116
  duration: BigInt(currentInfo.duration),
116
117
  finished: BigInt(currentInfo.finished),
117
118
  reward: currentInfo.reward,
118
119
  balance: currentInfo.balance,
119
- symbol: symbol,
120
+ symbol: tokenData.symbol,
120
121
  };
121
122
  const extra = extraRewards[address] || [];
122
123
  acc.base[address] = baseReward;
@@ -34,7 +34,8 @@ export declare class RedstoneApi {
34
34
  reserve: RedstonePriceFeeds;
35
35
  allReserve: Record<`0x${string}`, `0x${string}`>;
36
36
  }>;
37
- private static getPriceFeedsOfInterest_Onchain;
37
+ private static unwrapSecondStage;
38
+ private static unwrapThirdStage;
38
39
  private static getRedstonePF_Onchain;
39
40
  }
40
41
  export {};
@@ -92,7 +92,8 @@ class RedstoneApi {
92
92
  };
93
93
  static getRedstonePriceFeeds = async ({ priceOracleAddress, currentTokenData, provider, network, }) => {
94
94
  const allTokens = sdk_gov_1.TypedObjectUtils.entries(currentTokenData);
95
- const feeds = (await provider.multicall({
95
+ // STAGE 1: get direct price feeds and reserve price feeds
96
+ const st1_response = (await provider.multicall({
96
97
  allowFailure: true,
97
98
  multicallAddress: sdk_gov_1.MULTICALL_ADDRESS,
98
99
  contracts: [
@@ -110,11 +111,11 @@ class RedstoneApi {
110
111
  })),
111
112
  ],
112
113
  }));
113
- const mainFeedsEnd = allTokens.length;
114
- const mainFeedsUnsafe = feeds.slice(0, mainFeedsEnd);
115
- const reserveFeedsEnd = mainFeedsEnd + allTokens.length;
116
- const reserveFeedsUnsafe = feeds.slice(mainFeedsEnd, reserveFeedsEnd);
117
- const notTrustedMainPF = mainFeedsUnsafe.reduce((acc, p, index) => {
114
+ const st1_MainFeedsEnd = allTokens.length;
115
+ const st1_MainFeedsUnsafe = st1_response.slice(0, st1_MainFeedsEnd);
116
+ const st1_ReserveFeedsEnd = st1_MainFeedsEnd + allTokens.length;
117
+ const st1_ReserveFeedsUnsafe = st1_response.slice(st1_MainFeedsEnd, st1_ReserveFeedsEnd);
118
+ const st1_NotTrustedMainPF = st1_MainFeedsUnsafe.reduce((acc, p, index) => {
118
119
  const symbol = allTokens[index][0];
119
120
  if (!p.error && typeof p.result === "object" && p.result[4] === false) {
120
121
  const [priceFeed] = p.result;
@@ -122,51 +123,93 @@ class RedstoneApi {
122
123
  }
123
124
  return acc;
124
125
  }, []);
125
- const notTrustedMainPFRecord = sdk_gov_1.TypedObjectUtils.fromEntries(notTrustedMainPF);
126
- const reservePF = reserveFeedsUnsafe.reduce((acc, p, index) => {
126
+ const st1_NotTrustedMainPFRecord = sdk_gov_1.TypedObjectUtils.fromEntries(st1_NotTrustedMainPF);
127
+ const st1_ReservePF = st1_ReserveFeedsUnsafe.reduce((acc, p, index) => {
127
128
  const symbol = allTokens[index][0];
128
129
  if (!p.error &&
129
130
  typeof p.result === "string" &&
130
- notTrustedMainPFRecord[symbol]) {
131
+ st1_NotTrustedMainPFRecord[symbol]) {
131
132
  acc.push([symbol, p.result]);
132
133
  }
133
134
  return acc;
134
135
  }, []);
135
- const typeResponse = (await provider.multicall({
136
+ // STAGE 2: get price feeds and their types. If type is Pendle TWAP, get the underlying price feeds for the next stage
137
+ const st2_response = (await provider.multicall({
136
138
  allowFailure: true,
137
139
  multicallAddress: sdk_gov_1.MULTICALL_ADDRESS,
138
140
  contracts: [
139
- ...notTrustedMainPF.map(([, address]) => ({
141
+ ...st1_NotTrustedMainPF.map(([, address]) => ({
140
142
  address,
141
143
  abi: types_1.iPriceFeedAbi,
142
144
  functionName: "priceFeedType",
143
145
  args: [],
144
146
  })),
145
- ...notTrustedMainPF.map(([, address]) => ({
147
+ ...st1_NotTrustedMainPF.map(([, address]) => ({
148
+ address,
149
+ abi: types_1.pendleTwapptPriceFeedAbi,
150
+ functionName: "priceFeed",
151
+ args: [],
152
+ })),
153
+ ...st1_ReservePF.map(([, address]) => ({
154
+ address,
155
+ abi: types_1.iPriceFeedAbi,
156
+ functionName: "priceFeedType",
157
+ args: [],
158
+ })),
159
+ ...st1_ReservePF.map(([, address]) => ({
160
+ address,
161
+ abi: types_1.pendleTwapptPriceFeedAbi,
162
+ functionName: "priceFeed",
163
+ args: [],
164
+ })),
165
+ ],
166
+ }));
167
+ const st2_MainFeedsTypeEnd = st1_NotTrustedMainPF.length;
168
+ const st2_MainFeedsTypeUnsafe = st2_response.slice(0, st2_MainFeedsTypeEnd);
169
+ const st2_MainFeedsEnd = st2_MainFeedsTypeEnd + st1_NotTrustedMainPF.length;
170
+ const st2_MainFeedsUnsafe = st2_response.slice(st2_MainFeedsTypeEnd, st2_MainFeedsEnd);
171
+ const st2_ReserveFeedsTypeEnd = st2_MainFeedsEnd + st1_ReservePF.length;
172
+ const st2_ReserveFeedsTypeUnsafe = st2_response.slice(st2_MainFeedsEnd, st2_ReserveFeedsTypeEnd);
173
+ const st2_ReserveFeedsEnd = st2_ReserveFeedsTypeEnd + st1_ReservePF.length;
174
+ const st2_ReserveFeedsUnsafe = st2_response.slice(st2_ReserveFeedsTypeEnd, st2_ReserveFeedsEnd);
175
+ const st2_NotTrustedMainPF = this.unwrapSecondStage(st1_NotTrustedMainPF, st2_MainFeedsTypeUnsafe, st2_MainFeedsUnsafe);
176
+ const st2_ReservePF = this.unwrapSecondStage(st1_ReservePF, st2_ReserveFeedsTypeUnsafe, st2_ReserveFeedsUnsafe);
177
+ // STAGE 3: get price feeds and their types. If types is composite, get the underlying price feeds
178
+ const st3_response = (await provider.multicall({
179
+ allowFailure: true,
180
+ multicallAddress: sdk_gov_1.MULTICALL_ADDRESS,
181
+ contracts: [
182
+ ...st2_NotTrustedMainPF.map(([, address]) => ({
183
+ address,
184
+ abi: types_1.iPriceFeedAbi,
185
+ functionName: "priceFeedType",
186
+ args: [],
187
+ })),
188
+ ...st2_NotTrustedMainPF.map(([, address]) => ({
146
189
  address,
147
190
  abi: types_1.compositePriceFeedAbi,
148
191
  functionName: "priceFeed0",
149
192
  args: [],
150
193
  })),
151
- ...notTrustedMainPF.map(([, address]) => ({
194
+ ...st2_NotTrustedMainPF.map(([, address]) => ({
152
195
  address,
153
196
  abi: types_1.compositePriceFeedAbi,
154
197
  functionName: "priceFeed1",
155
198
  args: [],
156
199
  })),
157
- ...reservePF.map(([, address]) => ({
200
+ ...st2_ReservePF.map(([, address]) => ({
158
201
  address,
159
202
  abi: types_1.iPriceFeedAbi,
160
203
  functionName: "priceFeedType",
161
204
  args: [],
162
205
  })),
163
- ...reservePF.map(([, address]) => ({
206
+ ...st2_ReservePF.map(([, address]) => ({
164
207
  address,
165
208
  abi: types_1.compositePriceFeedAbi,
166
209
  functionName: "priceFeed0",
167
210
  args: [],
168
211
  })),
169
- ...reservePF.map(([, address]) => ({
212
+ ...st2_ReservePF.map(([, address]) => ({
170
213
  address,
171
214
  abi: types_1.compositePriceFeedAbi,
172
215
  functionName: "priceFeed1",
@@ -174,43 +217,44 @@ class RedstoneApi {
174
217
  })),
175
218
  ],
176
219
  }));
177
- const mainFeedsTypeEnd = notTrustedMainPF.length;
178
- const mainFeedsTypeUnsafe = typeResponse.slice(0, mainFeedsTypeEnd);
179
- const mainPriceFeed0End = mainFeedsTypeEnd + notTrustedMainPF.length;
180
- const mainPriceFeed0Unsafe = typeResponse.slice(mainFeedsTypeEnd, mainPriceFeed0End);
181
- const mainPriceFeed1End = mainPriceFeed0End + notTrustedMainPF.length;
182
- const mainPriceFeed1Unsafe = typeResponse.slice(mainPriceFeed0End, mainPriceFeed1End);
183
- const reserveFeedsTypeEnd = mainPriceFeed1End + reservePF.length;
184
- const reserveFeedsTypeUnsafe = typeResponse.slice(mainPriceFeed1End, reserveFeedsTypeEnd);
185
- const reservePriceFeed0End = reserveFeedsTypeEnd + reservePF.length;
186
- const reservePriceFeed0Unsafe = typeResponse.slice(reserveFeedsTypeEnd, reservePriceFeed0End);
187
- const reservePriceFeed1End = reservePriceFeed0End + reservePF.length;
188
- const reservePriceFeed1Unsafe = typeResponse.slice(reservePriceFeed0End, reservePriceFeed1End);
189
- const realNotTrustedMainPriceFeeds = this.getPriceFeedsOfInterest_Onchain(notTrustedMainPF, mainFeedsTypeUnsafe, mainPriceFeed0Unsafe, mainPriceFeed1Unsafe);
190
- const realReservePriceFeeds = this.getPriceFeedsOfInterest_Onchain(reservePF, reserveFeedsTypeUnsafe, reservePriceFeed0Unsafe, reservePriceFeed1Unsafe);
191
- const response = (await provider.multicall({
220
+ const st3_MainFeedsTypeEnd = st2_NotTrustedMainPF.length;
221
+ const st3_MainFeedsTypeUnsafe = st3_response.slice(0, st3_MainFeedsTypeEnd);
222
+ const st3_MainPriceFeed0End = st3_MainFeedsTypeEnd + st2_NotTrustedMainPF.length;
223
+ const st3_MainPriceFeed0Unsafe = st3_response.slice(st3_MainFeedsTypeEnd, st3_MainPriceFeed0End);
224
+ const st3_MainPriceFeed1End = st3_MainPriceFeed0End + st2_NotTrustedMainPF.length;
225
+ const st3_MainPriceFeed1Unsafe = st3_response.slice(st3_MainPriceFeed0End, st3_MainPriceFeed1End);
226
+ const st3_ReserveFeedsTypeEnd = st3_MainPriceFeed1End + st2_ReservePF.length;
227
+ const st3_ReserveFeedsTypeUnsafe = st3_response.slice(st3_MainPriceFeed1End, st3_ReserveFeedsTypeEnd);
228
+ const st3_ReservePriceFeed0End = st3_ReserveFeedsTypeEnd + st2_ReservePF.length;
229
+ const st3_ReservePriceFeed0Unsafe = st3_response.slice(st3_ReserveFeedsTypeEnd, st3_ReservePriceFeed0End);
230
+ const st3_ReservePriceFeed1End = st3_ReservePriceFeed0End + st2_ReservePF.length;
231
+ const st3_ReservePriceFeed1Unsafe = st3_response.slice(st3_ReservePriceFeed0End, st3_ReservePriceFeed1End);
232
+ const st3_NotTrustedMainPF = this.unwrapThirdStage(st2_NotTrustedMainPF, st3_MainFeedsTypeUnsafe, st3_MainPriceFeed0Unsafe, st3_MainPriceFeed1Unsafe);
233
+ const st3_ReservePF = this.unwrapThirdStage(st2_ReservePF, st3_ReserveFeedsTypeUnsafe, st3_ReservePriceFeed0Unsafe, st3_ReservePriceFeed1Unsafe);
234
+ // STAGE 4: get price feed types and data feed ids for unwrapped price feeds
235
+ const st4_response = (await provider.multicall({
192
236
  allowFailure: true,
193
237
  multicallAddress: sdk_gov_1.MULTICALL_ADDRESS,
194
238
  contracts: [
195
- ...realNotTrustedMainPriceFeeds.map(([, address]) => ({
239
+ ...st3_NotTrustedMainPF.map(([, address]) => ({
196
240
  address,
197
241
  abi: types_1.iPriceFeedAbi,
198
242
  functionName: "priceFeedType",
199
243
  args: [],
200
244
  })),
201
- ...realNotTrustedMainPriceFeeds.map(([, address]) => ({
245
+ ...st3_NotTrustedMainPF.map(([, address]) => ({
202
246
  address,
203
247
  abi: types_1.redstonePriceFeedAbi,
204
248
  functionName: "dataFeedId",
205
249
  args: [],
206
250
  })),
207
- ...realReservePriceFeeds.map(([, address]) => ({
251
+ ...st3_ReservePF.map(([, address]) => ({
208
252
  address,
209
253
  abi: types_1.iPriceFeedAbi,
210
254
  functionName: "priceFeedType",
211
255
  args: [],
212
256
  })),
213
- ...realReservePriceFeeds.map(([, address]) => ({
257
+ ...st3_ReservePF.map(([, address]) => ({
214
258
  address,
215
259
  abi: types_1.redstonePriceFeedAbi,
216
260
  functionName: "dataFeedId",
@@ -218,25 +262,42 @@ class RedstoneApi {
218
262
  })),
219
263
  ],
220
264
  }));
221
- const mainTypeEnd = realNotTrustedMainPriceFeeds.length;
222
- const mainTypeType = response.slice(0, mainTypeEnd);
223
- const mainFeedIdEnd = mainTypeEnd + realNotTrustedMainPriceFeeds.length;
224
- const mainFeedId = response.slice(mainTypeEnd, mainFeedIdEnd);
225
- const reserveTypeEnd = mainFeedIdEnd + realReservePriceFeeds.length;
226
- const reserveType = response.slice(mainFeedIdEnd, reserveTypeEnd);
227
- const reserveFeedIdEnd = reserveTypeEnd + realReservePriceFeeds.length;
228
- const reserveFeedId = response.slice(reserveTypeEnd, reserveFeedIdEnd);
265
+ const st4_MainTypeEnd = st3_NotTrustedMainPF.length;
266
+ const st4_MainTypeType = st4_response.slice(0, st4_MainTypeEnd);
267
+ const st4_MainFeedIdEnd = st4_MainTypeEnd + st3_NotTrustedMainPF.length;
268
+ const st4_MainFeedId = st4_response.slice(st4_MainTypeEnd, st4_MainFeedIdEnd);
269
+ const st4_ReserveTypeEnd = st4_MainFeedIdEnd + st3_ReservePF.length;
270
+ const st4_ReserveType = st4_response.slice(st4_MainFeedIdEnd, st4_ReserveTypeEnd);
271
+ const st4_ReserveFeedIdEnd = st4_ReserveTypeEnd + st3_ReservePF.length;
272
+ const st4_ReserveFeedId = st4_response.slice(st4_ReserveTypeEnd, st4_ReserveFeedIdEnd);
229
273
  const getMain = (symbol) => (0, sdk_gov_1.getPriceFeedsByToken)(symbol, network)?.Main;
230
274
  const getReserve = (symbol) => (0, sdk_gov_1.getPriceFeedsByToken)(symbol, network)?.Reserve;
231
- const mainPFData = this.getRedstonePF_Onchain(realNotTrustedMainPriceFeeds, mainTypeType, mainFeedId, getMain, currentTokenData, false, network);
232
- const reservePFData = this.getRedstonePF_Onchain(realReservePriceFeeds, reserveType, reserveFeedId, getReserve, currentTokenData, true, network);
275
+ const mainPFData = this.getRedstonePF_Onchain(st3_NotTrustedMainPF, st4_MainTypeType, st4_MainFeedId, getMain, currentTokenData, false, network);
276
+ const reservePFData = this.getRedstonePF_Onchain(st3_ReservePF, st4_ReserveType, st4_ReserveFeedId, getReserve, currentTokenData, true, network);
233
277
  return {
234
278
  main: mainPFData,
235
279
  reserve: reservePFData,
236
- allReserve: sdk_gov_1.TypedObjectUtils.fromEntries(reservePF.map(([s, a]) => [currentTokenData[s], a])),
280
+ allReserve: sdk_gov_1.TypedObjectUtils.fromEntries(st3_ReservePF.map(([s, a]) => [currentTokenData[s], a])),
237
281
  };
238
282
  };
239
- static getPriceFeedsOfInterest_Onchain(priceFeeds, feedsTypeResponse, priceFeed0Response, priceFeed1Response) {
283
+ static unwrapSecondStage(priceFeeds, feedsTypeResponse, priceFeedResponse) {
284
+ const result = priceFeeds.reduce((acc, [symbol, baseAddress], index) => {
285
+ const { error: typeError, result: feedType } = feedsTypeResponse[index];
286
+ const { error: feedError, result: feed } = priceFeedResponse[index];
287
+ const isPendle = !typeError &&
288
+ Number(feedType) === sdk_gov_1.PriceFeedType.PENDLE_PT_TWAP_ORACLE;
289
+ const hasFeed = !feedError && typeof feed === "string";
290
+ if (isPendle && hasFeed) {
291
+ acc.push([symbol, feed]);
292
+ }
293
+ else {
294
+ acc.push([symbol, baseAddress]);
295
+ }
296
+ return acc;
297
+ }, []);
298
+ return result;
299
+ }
300
+ static unwrapThirdStage(priceFeeds, feedsTypeResponse, priceFeed0Response, priceFeed1Response) {
240
301
  const result = priceFeeds.reduce((acc, [symbol, baseAddress], index) => {
241
302
  const { error: typeError, result: feedType } = feedsTypeResponse[index];
242
303
  const { error: feed0Error, result: feed0 } = priceFeed0Response[index];
@@ -0,0 +1,43 @@
1
+ export declare const iPendleMarketAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly inputs: readonly [];
4
+ readonly name: "expiry";
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly internalType: "uint256";
8
+ readonly type: "uint256";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly inputs: readonly [{
14
+ readonly name: "secondsAgos";
15
+ readonly internalType: "uint32[]";
16
+ readonly type: "uint32[]";
17
+ }];
18
+ readonly name: "observe";
19
+ readonly outputs: readonly [{
20
+ readonly name: "";
21
+ readonly internalType: "uint216[]";
22
+ readonly type: "uint216[]";
23
+ }];
24
+ readonly stateMutability: "view";
25
+ }, {
26
+ readonly type: "function";
27
+ readonly inputs: readonly [];
28
+ readonly name: "readTokens";
29
+ readonly outputs: readonly [{
30
+ readonly name: "";
31
+ readonly internalType: "address";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly name: "";
35
+ readonly internalType: "address";
36
+ readonly type: "address";
37
+ }, {
38
+ readonly name: "";
39
+ readonly internalType: "address";
40
+ readonly type: "address";
41
+ }];
42
+ readonly stateMutability: "view";
43
+ }];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
+ // IPendleMarket
4
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.iPendleMarketAbi = void 0;
7
+ exports.iPendleMarketAbi = [
8
+ {
9
+ type: "function",
10
+ inputs: [],
11
+ name: "expiry",
12
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
13
+ stateMutability: "view",
14
+ },
15
+ {
16
+ type: "function",
17
+ inputs: [
18
+ { name: "secondsAgos", internalType: "uint32[]", type: "uint32[]" },
19
+ ],
20
+ name: "observe",
21
+ outputs: [{ name: "", internalType: "uint216[]", type: "uint216[]" }],
22
+ stateMutability: "view",
23
+ },
24
+ {
25
+ type: "function",
26
+ inputs: [],
27
+ name: "readTokens",
28
+ outputs: [
29
+ { name: "", internalType: "address", type: "address" },
30
+ { name: "", internalType: "address", type: "address" },
31
+ { name: "", internalType: "address", type: "address" },
32
+ ],
33
+ stateMutability: "view",
34
+ },
35
+ ];
@@ -0,0 +1,11 @@
1
+ export declare const iPendleSyAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly inputs: readonly [];
4
+ readonly name: "exchangeRate";
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly internalType: "uint256";
8
+ readonly type: "uint256";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
+ // IPendleSY
4
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.iPendleSyAbi = void 0;
7
+ exports.iPendleSyAbi = [
8
+ {
9
+ type: "function",
10
+ inputs: [],
11
+ name: "exchangeRate",
12
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
13
+ stateMutability: "view",
14
+ },
15
+ ];
@@ -0,0 +1,31 @@
1
+ export declare const iPendleYtAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly inputs: readonly [];
4
+ readonly name: "doCacheIndexSameBlock";
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly internalType: "bool";
8
+ readonly type: "bool";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly inputs: readonly [];
14
+ readonly name: "pyIndexLastUpdatedBlock";
15
+ readonly outputs: readonly [{
16
+ readonly name: "";
17
+ readonly internalType: "uint256";
18
+ readonly type: "uint256";
19
+ }];
20
+ readonly stateMutability: "view";
21
+ }, {
22
+ readonly type: "function";
23
+ readonly inputs: readonly [];
24
+ readonly name: "pyIndexStored";
25
+ readonly outputs: readonly [{
26
+ readonly name: "";
27
+ readonly internalType: "uint256";
28
+ readonly type: "uint256";
29
+ }];
30
+ readonly stateMutability: "view";
31
+ }];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
+ // IPendleYT
4
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.iPendleYtAbi = void 0;
7
+ exports.iPendleYtAbi = [
8
+ {
9
+ type: "function",
10
+ inputs: [],
11
+ name: "doCacheIndexSameBlock",
12
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
13
+ stateMutability: "view",
14
+ },
15
+ {
16
+ type: "function",
17
+ inputs: [],
18
+ name: "pyIndexLastUpdatedBlock",
19
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
20
+ stateMutability: "view",
21
+ },
22
+ {
23
+ type: "function",
24
+ inputs: [],
25
+ name: "pyIndexStored",
26
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
27
+ stateMutability: "view",
28
+ },
29
+ ];
@@ -0,0 +1,201 @@
1
+ export declare const pendleTwapptPriceFeedAbi: readonly [{
2
+ readonly type: "constructor";
3
+ readonly inputs: readonly [{
4
+ readonly name: "_market";
5
+ readonly internalType: "address";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly name: "_priceFeed";
9
+ readonly internalType: "address";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly name: "_stalenessPeriod";
13
+ readonly internalType: "uint32";
14
+ readonly type: "uint32";
15
+ }, {
16
+ readonly name: "_twapWindow";
17
+ readonly internalType: "uint32";
18
+ readonly type: "uint32";
19
+ }];
20
+ readonly stateMutability: "nonpayable";
21
+ }, {
22
+ readonly type: "function";
23
+ readonly inputs: readonly [];
24
+ readonly name: "decimals";
25
+ readonly outputs: readonly [{
26
+ readonly name: "";
27
+ readonly internalType: "uint8";
28
+ readonly type: "uint8";
29
+ }];
30
+ readonly stateMutability: "view";
31
+ }, {
32
+ readonly type: "function";
33
+ readonly inputs: readonly [];
34
+ readonly name: "description";
35
+ readonly outputs: readonly [{
36
+ readonly name: "";
37
+ readonly internalType: "string";
38
+ readonly type: "string";
39
+ }];
40
+ readonly stateMutability: "view";
41
+ }, {
42
+ readonly type: "function";
43
+ readonly inputs: readonly [];
44
+ readonly name: "expiry";
45
+ readonly outputs: readonly [{
46
+ readonly name: "";
47
+ readonly internalType: "uint256";
48
+ readonly type: "uint256";
49
+ }];
50
+ readonly stateMutability: "view";
51
+ }, {
52
+ readonly type: "function";
53
+ readonly inputs: readonly [];
54
+ readonly name: "latestRoundData";
55
+ readonly outputs: readonly [{
56
+ readonly name: "";
57
+ readonly internalType: "uint80";
58
+ readonly type: "uint80";
59
+ }, {
60
+ readonly name: "";
61
+ readonly internalType: "int256";
62
+ readonly type: "int256";
63
+ }, {
64
+ readonly name: "";
65
+ readonly internalType: "uint256";
66
+ readonly type: "uint256";
67
+ }, {
68
+ readonly name: "";
69
+ readonly internalType: "uint256";
70
+ readonly type: "uint256";
71
+ }, {
72
+ readonly name: "";
73
+ readonly internalType: "uint80";
74
+ readonly type: "uint80";
75
+ }];
76
+ readonly stateMutability: "view";
77
+ }, {
78
+ readonly type: "function";
79
+ readonly inputs: readonly [];
80
+ readonly name: "market";
81
+ readonly outputs: readonly [{
82
+ readonly name: "";
83
+ readonly internalType: "address";
84
+ readonly type: "address";
85
+ }];
86
+ readonly stateMutability: "view";
87
+ }, {
88
+ readonly type: "function";
89
+ readonly inputs: readonly [];
90
+ readonly name: "priceFeed";
91
+ readonly outputs: readonly [{
92
+ readonly name: "";
93
+ readonly internalType: "address";
94
+ readonly type: "address";
95
+ }];
96
+ readonly stateMutability: "view";
97
+ }, {
98
+ readonly type: "function";
99
+ readonly inputs: readonly [];
100
+ readonly name: "priceFeedType";
101
+ readonly outputs: readonly [{
102
+ readonly name: "";
103
+ readonly internalType: "enum PriceFeedType";
104
+ readonly type: "uint8";
105
+ }];
106
+ readonly stateMutability: "view";
107
+ }, {
108
+ readonly type: "function";
109
+ readonly inputs: readonly [];
110
+ readonly name: "skipCheck";
111
+ readonly outputs: readonly [{
112
+ readonly name: "";
113
+ readonly internalType: "bool";
114
+ readonly type: "bool";
115
+ }];
116
+ readonly stateMutability: "view";
117
+ }, {
118
+ readonly type: "function";
119
+ readonly inputs: readonly [];
120
+ readonly name: "skipPriceCheck";
121
+ readonly outputs: readonly [{
122
+ readonly name: "";
123
+ readonly internalType: "bool";
124
+ readonly type: "bool";
125
+ }];
126
+ readonly stateMutability: "view";
127
+ }, {
128
+ readonly type: "function";
129
+ readonly inputs: readonly [];
130
+ readonly name: "stalenessPeriod";
131
+ readonly outputs: readonly [{
132
+ readonly name: "";
133
+ readonly internalType: "uint32";
134
+ readonly type: "uint32";
135
+ }];
136
+ readonly stateMutability: "view";
137
+ }, {
138
+ readonly type: "function";
139
+ readonly inputs: readonly [];
140
+ readonly name: "sy";
141
+ readonly outputs: readonly [{
142
+ readonly name: "";
143
+ readonly internalType: "address";
144
+ readonly type: "address";
145
+ }];
146
+ readonly stateMutability: "view";
147
+ }, {
148
+ readonly type: "function";
149
+ readonly inputs: readonly [];
150
+ readonly name: "twapWindow";
151
+ readonly outputs: readonly [{
152
+ readonly name: "";
153
+ readonly internalType: "uint32";
154
+ readonly type: "uint32";
155
+ }];
156
+ readonly stateMutability: "view";
157
+ }, {
158
+ readonly type: "function";
159
+ readonly inputs: readonly [];
160
+ readonly name: "version";
161
+ readonly outputs: readonly [{
162
+ readonly name: "";
163
+ readonly internalType: "uint256";
164
+ readonly type: "uint256";
165
+ }];
166
+ readonly stateMutability: "view";
167
+ }, {
168
+ readonly type: "function";
169
+ readonly inputs: readonly [];
170
+ readonly name: "yt";
171
+ readonly outputs: readonly [{
172
+ readonly name: "";
173
+ readonly internalType: "address";
174
+ readonly type: "address";
175
+ }];
176
+ readonly stateMutability: "view";
177
+ }, {
178
+ readonly type: "error";
179
+ readonly inputs: readonly [{
180
+ readonly name: "";
181
+ readonly internalType: "address";
182
+ readonly type: "address";
183
+ }];
184
+ readonly name: "AddressIsNotContractException";
185
+ }, {
186
+ readonly type: "error";
187
+ readonly inputs: readonly [];
188
+ readonly name: "IncorrectParameterException";
189
+ }, {
190
+ readonly type: "error";
191
+ readonly inputs: readonly [];
192
+ readonly name: "IncorrectPriceException";
193
+ }, {
194
+ readonly type: "error";
195
+ readonly inputs: readonly [];
196
+ readonly name: "IncorrectPriceFeedException";
197
+ }, {
198
+ readonly type: "error";
199
+ readonly inputs: readonly [];
200
+ readonly name: "StalePriceException";
201
+ }];
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
+ // PendleTWAPPTPriceFeed
4
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pendleTwapptPriceFeedAbi = void 0;
7
+ exports.pendleTwapptPriceFeedAbi = [
8
+ {
9
+ type: "constructor",
10
+ inputs: [
11
+ { name: "_market", internalType: "address", type: "address" },
12
+ { name: "_priceFeed", internalType: "address", type: "address" },
13
+ { name: "_stalenessPeriod", internalType: "uint32", type: "uint32" },
14
+ { name: "_twapWindow", internalType: "uint32", type: "uint32" },
15
+ ],
16
+ stateMutability: "nonpayable",
17
+ },
18
+ {
19
+ type: "function",
20
+ inputs: [],
21
+ name: "decimals",
22
+ outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
23
+ stateMutability: "view",
24
+ },
25
+ {
26
+ type: "function",
27
+ inputs: [],
28
+ name: "description",
29
+ outputs: [{ name: "", internalType: "string", type: "string" }],
30
+ stateMutability: "view",
31
+ },
32
+ {
33
+ type: "function",
34
+ inputs: [],
35
+ name: "expiry",
36
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
37
+ stateMutability: "view",
38
+ },
39
+ {
40
+ type: "function",
41
+ inputs: [],
42
+ name: "latestRoundData",
43
+ outputs: [
44
+ { name: "", internalType: "uint80", type: "uint80" },
45
+ { name: "", internalType: "int256", type: "int256" },
46
+ { name: "", internalType: "uint256", type: "uint256" },
47
+ { name: "", internalType: "uint256", type: "uint256" },
48
+ { name: "", internalType: "uint80", type: "uint80" },
49
+ ],
50
+ stateMutability: "view",
51
+ },
52
+ {
53
+ type: "function",
54
+ inputs: [],
55
+ name: "market",
56
+ outputs: [{ name: "", internalType: "address", type: "address" }],
57
+ stateMutability: "view",
58
+ },
59
+ {
60
+ type: "function",
61
+ inputs: [],
62
+ name: "priceFeed",
63
+ outputs: [{ name: "", internalType: "address", type: "address" }],
64
+ stateMutability: "view",
65
+ },
66
+ {
67
+ type: "function",
68
+ inputs: [],
69
+ name: "priceFeedType",
70
+ outputs: [{ name: "", internalType: "enum PriceFeedType", type: "uint8" }],
71
+ stateMutability: "view",
72
+ },
73
+ {
74
+ type: "function",
75
+ inputs: [],
76
+ name: "skipCheck",
77
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
78
+ stateMutability: "view",
79
+ },
80
+ {
81
+ type: "function",
82
+ inputs: [],
83
+ name: "skipPriceCheck",
84
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
85
+ stateMutability: "view",
86
+ },
87
+ {
88
+ type: "function",
89
+ inputs: [],
90
+ name: "stalenessPeriod",
91
+ outputs: [{ name: "", internalType: "uint32", type: "uint32" }],
92
+ stateMutability: "view",
93
+ },
94
+ {
95
+ type: "function",
96
+ inputs: [],
97
+ name: "sy",
98
+ outputs: [{ name: "", internalType: "address", type: "address" }],
99
+ stateMutability: "view",
100
+ },
101
+ {
102
+ type: "function",
103
+ inputs: [],
104
+ name: "twapWindow",
105
+ outputs: [{ name: "", internalType: "uint32", type: "uint32" }],
106
+ stateMutability: "view",
107
+ },
108
+ {
109
+ type: "function",
110
+ inputs: [],
111
+ name: "version",
112
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
113
+ stateMutability: "view",
114
+ },
115
+ {
116
+ type: "function",
117
+ inputs: [],
118
+ name: "yt",
119
+ outputs: [{ name: "", internalType: "address", type: "address" }],
120
+ stateMutability: "view",
121
+ },
122
+ {
123
+ type: "error",
124
+ inputs: [{ name: "", internalType: "address", type: "address" }],
125
+ name: "AddressIsNotContractException",
126
+ },
127
+ { type: "error", inputs: [], name: "IncorrectParameterException" },
128
+ { type: "error", inputs: [], name: "IncorrectPriceException" },
129
+ { type: "error", inputs: [], name: "IncorrectPriceFeedException" },
130
+ { type: "error", inputs: [], name: "StalePriceException" },
131
+ ];
@@ -34,6 +34,9 @@ export * from "./ILidoV1Adapter";
34
34
  export * from "./IMulticall3";
35
35
  export * from "./IOffchainOracle";
36
36
  export * from "./IPartialLiquidationBotV3";
37
+ export * from "./IPendleMarket";
38
+ export * from "./IPendleSY";
39
+ export * from "./IPendleYT";
37
40
  export * from "./IPoolV3";
38
41
  export * from "./IPriceFeed";
39
42
  export * from "./IPriceOracleBase";
@@ -48,5 +51,6 @@ export * from "./IwstETH";
48
51
  export * from "./IwstETHV1Adapter";
49
52
  export * from "./IYearnV2Adapter";
50
53
  export * from "./IZapper";
54
+ export * from "./PendleTWAPPTPriceFeed";
51
55
  export * from "./RedstonePriceFeed";
52
56
  export * from "./SignUpRepository";
@@ -50,6 +50,9 @@ __exportStar(require("./ILidoV1Adapter"), exports);
50
50
  __exportStar(require("./IMulticall3"), exports);
51
51
  __exportStar(require("./IOffchainOracle"), exports);
52
52
  __exportStar(require("./IPartialLiquidationBotV3"), exports);
53
+ __exportStar(require("./IPendleMarket"), exports);
54
+ __exportStar(require("./IPendleSY"), exports);
55
+ __exportStar(require("./IPendleYT"), exports);
53
56
  __exportStar(require("./IPoolV3"), exports);
54
57
  __exportStar(require("./IPriceFeed"), exports);
55
58
  __exportStar(require("./IPriceOracleBase"), exports);
@@ -64,5 +67,6 @@ __exportStar(require("./IwstETH"), exports);
64
67
  __exportStar(require("./IwstETHV1Adapter"), exports);
65
68
  __exportStar(require("./IYearnV2Adapter"), exports);
66
69
  __exportStar(require("./IZapper"), exports);
70
+ __exportStar(require("./PendleTWAPPTPriceFeed"), exports);
67
71
  __exportStar(require("./RedstonePriceFeed"), exports);
68
72
  __exportStar(require("./SignUpRepository"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.246",
3
+ "version": "3.0.0-next.248",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -28,8 +28,7 @@
28
28
  "test": "npx mocha -r ts-node/register -r dotenv/config 'src/**/*.spec.ts'"
29
29
  },
30
30
  "dependencies": {
31
- "@gearbox-protocol/bots-v3": "^1.5.1",
32
- "@gearbox-protocol/sdk-gov": "^2.25.6",
31
+ "@gearbox-protocol/sdk-gov": "^2.26.1",
33
32
  "@wagmi/cli": "^2.1.13",
34
33
  "axios": "^1.2.6",
35
34
  "decimal.js-light": "^2.5.1",
@@ -49,7 +48,8 @@
49
48
  "@gearbox-protocol/periphery-v3": "^1.6.1",
50
49
  "@gearbox-protocol/prettier-config": "^1.4.1",
51
50
  "@gearbox-protocol/router": "^1.5.5",
52
- "@gearbox-protocol/router-v3": "^1.36.1",
51
+ "@gearbox-protocol/bots-v3": "^1.5.1",
52
+ "@gearbox-protocol/router-v3": "^1.37.0",
53
53
  "@openzeppelin/contracts": "^4.9.3",
54
54
  "@redstone-finance/evm-connector": "^0.5.4",
55
55
  "@types/chai": "^4.3.3",