@gearbox-protocol/sdk 3.0.0-prevfour.14 → 3.0.0-prevfour.16

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.
Files changed (37) hide show
  1. package/contracts/index.sol +1 -0
  2. package/lib/apy/defiLamaAPY.js +1 -0
  3. package/lib/core/creditManager.d.ts +1 -3
  4. package/lib/core/creditManager.js +11 -19
  5. package/lib/core/endpoint.d.ts +1 -0
  6. package/lib/core/endpoint.js +3 -0
  7. package/lib/core/rewardClaimer/rewardConvex.js +1 -1
  8. package/lib/core/rewardClaimer/stakingRewards.js +1 -1
  9. package/lib/payload/creditManager.d.ts +12 -6
  10. package/lib/types/IPToken.d.ts +21 -0
  11. package/lib/types/{IPendleSY.js → IPToken.js} +11 -4
  12. package/lib/types/IPendleMarket.d.ts +3 -27
  13. package/lib/types/IPendleMarket.js +3 -19
  14. package/lib/types/IPendleRouter.d.ts +536 -0
  15. package/lib/types/IPendleRouter.js +370 -0
  16. package/lib/types/IPendleRouterAdapter.d.ts +831 -0
  17. package/lib/types/IPendleRouterAdapter.js +572 -0
  18. package/lib/types/IPendleRouterAdapterEvents.d.ts +26 -0
  19. package/lib/types/IPendleRouterAdapterEvents.js +39 -0
  20. package/lib/types/IPendleRouterAdapterExceptions.d.ts +9 -0
  21. package/lib/types/IPendleRouterAdapterExceptions.js +10 -0
  22. package/lib/types/{IPendleYT.d.ts → IRouterComponent.d.ts} +8 -8
  23. package/lib/types/{IPendleYT.js → IRouterComponent.js} +8 -8
  24. package/lib/types/IRouterStatic.d.ts +128 -0
  25. package/lib/types/IRouterStatic.js +68 -0
  26. package/lib/types/ISwapper.d.ts +100 -0
  27. package/lib/types/ISwapper.js +75 -0
  28. package/lib/types/IYToken.d.ts +21 -0
  29. package/lib/types/IYToken.js +22 -0
  30. package/lib/types/PendleSwapper.d.ts +182 -0
  31. package/lib/types/PendleSwapper.js +130 -0
  32. package/lib/types/RouterComponentConfigurator.d.ts +61 -0
  33. package/lib/types/RouterComponentConfigurator.js +48 -0
  34. package/lib/types/index.d.ts +11 -2
  35. package/lib/types/index.js +11 -2
  36. package/package.json +6 -6
  37. package/lib/types/IPendleSY.d.ts +0 -11
@@ -84,6 +84,7 @@ import {IStakingRewardsAdapter} from
84
84
  import {IMulticall3} from "@gearbox-protocol/router-v3/lib/forge-std/src/interfaces/IMulticall3.sol";
85
85
  import {IRouterV3} from "@gearbox-protocol/router-v3/contracts/interfaces/IRouterV3.sol";
86
86
  import {IRouter} from "@gearbox-protocol/router/contracts/interfaces/IRouter.sol";
87
+ import {PendleSwapper} from "@gearbox-protocol/router-v3/contracts/workers/PendleSwapper.sol";
87
88
 
88
89
  import {IFarmingPool} from "@1inch/farming/contracts/interfaces/IFarmingPool.sol";
89
90
 
@@ -48,6 +48,7 @@ const NORMAL_TO_LAMA = {
48
48
  PT_corn_eBTC_27MAR2025: "eb7de368-b460-4638-bde1-50a129109b7b",
49
49
  PT_corn_pumpBTC_26DEC2024: "a23e2b97-ff92-4ebf-8c7d-171cad8431ad",
50
50
  PT_sUSDe_27MAR2025: "6b28892f-0909-418d-b4bb-3106fff72449",
51
+ scrvUSD: "5fd328af-4203-471b-bd16-1705c726d926",
51
52
  },
52
53
  Optimism: { rETH: "d4b3c522-6127-4b89-bedf-83641cdcd2eb" },
53
54
  Arbitrum: {
@@ -1,6 +1,5 @@
1
1
  import { Address } from "viem";
2
2
  import { ChartsCreditManagerPayload, CreditManagerDataPayload, QuotaInfo } from "../payload/creditManager";
3
- import { LinearModel } from "../payload/pool";
4
3
  export type CreditManagerType = "universal" | "trade" | "farm" | "restaking";
5
4
  export declare class CreditManagerData {
6
5
  readonly address: Address;
@@ -32,11 +31,10 @@ export declare class CreditManagerData {
32
31
  readonly collateralTokens: Array<Address>;
33
32
  readonly supportedTokens: Record<Address, true>;
34
33
  readonly usableTokens: Record<Address, true>;
35
- readonly adapters: Record<Address, Address>;
34
+ readonly adapters: Record<Address, CreditManagerDataPayload["adapters"][1]>;
36
35
  readonly contractsByAdapter: Record<Address, Address>;
37
36
  readonly liquidationThresholds: Record<Address, bigint>;
38
37
  readonly quotas: Record<Address, QuotaInfo>;
39
- readonly interestModel: LinearModel;
40
38
  constructor(payload: CreditManagerDataPayload);
41
39
  isQuoted(token: Address): boolean;
42
40
  static getTier(name: string): number;
@@ -36,7 +36,6 @@ class CreditManagerData {
36
36
  contractsByAdapter = {};
37
37
  liquidationThresholds;
38
38
  quotas;
39
- interestModel;
40
39
  constructor(payload) {
41
40
  this.address = payload.addr.toLowerCase();
42
41
  this.underlyingToken = payload.underlying.toLowerCase();
@@ -70,14 +69,18 @@ class CreditManagerData {
70
69
  this.liquidationDiscountExpired = Number(payload.liquidationDiscountExpired);
71
70
  payload.adapters.forEach(a => {
72
71
  const contractLc = a.targetContract.toLowerCase();
73
- const adaptertLc = a.adapter.toLowerCase();
74
- this.adapters[contractLc] = adaptertLc;
75
- this.contractsByAdapter[adaptertLc] = contractLc;
72
+ const adapterLc = a.address.toLowerCase();
73
+ this.adapters[contractLc] = {
74
+ address: adapterLc,
75
+ contractType: a.contractType,
76
+ version: a.version,
77
+ name: a.name,
78
+ targetContract: contractLc,
79
+ };
80
+ this.contractsByAdapter[adapterLc] = contractLc;
76
81
  });
77
- this.liquidationThresholds = payload.liquidationThresholds.reduce((acc, threshold, index) => {
78
- const address = payload.collateralTokens[index];
79
- if (address)
80
- acc[address.toLowerCase()] = threshold;
82
+ this.liquidationThresholds = payload.liquidationThresholds.reduce((acc, [token, threshold]) => {
83
+ acc[token.toLowerCase()] = BigInt(threshold);
81
84
  return acc;
82
85
  }, {});
83
86
  this.quotas = payload.quotas.reduce((acc, q) => {
@@ -92,17 +95,6 @@ class CreditManagerData {
92
95
  };
93
96
  return acc;
94
97
  }, {});
95
- this.interestModel = {
96
- interestModel: payload.lirm.interestModel.toLowerCase(),
97
- U_1: BigInt(payload.lirm.U_1),
98
- U_2: BigInt(payload.lirm.U_2),
99
- R_base: BigInt(payload.lirm.R_base),
100
- R_slope1: BigInt(payload.lirm.R_slope1),
101
- R_slope2: BigInt(payload.lirm.R_slope2),
102
- R_slope3: BigInt(payload.lirm.R_slope3),
103
- version: Number(payload?.lirm?.version),
104
- isBorrowingMoreU2Forbidden: payload?.lirm?.isBorrowingMoreU2Forbidden,
105
- };
106
98
  payload.collateralTokens.forEach(t => {
107
99
  const tLc = t.toLowerCase();
108
100
  const zeroLt = this.liquidationThresholds[tLc] === 0n;
@@ -10,6 +10,7 @@ export declare class GearboxBackendApi {
10
10
  static getNFTMerkleUrl: (network: NetworkType, root: Address) => string;
11
11
  static getLeaderboardUrl: (url: string, chainId: number) => string;
12
12
  static getReferralUrl: () => string;
13
+ static apyServerAllRewards: (chainId: number) => string;
13
14
  }
14
15
  interface Options {
15
16
  params?: Record<string, string | number>;
@@ -62,6 +62,9 @@ class GearboxBackendApi {
62
62
  return `${LEADERBOARD_APIS[chainId]}${url}`;
63
63
  };
64
64
  static getReferralUrl = () => REFERRAL_API;
65
+ static apyServerAllRewards = (chainId) => URLApi.getRelativeUrl("https://testnet.gearbox.foundation/apy-server/api/rewards/all", {
66
+ params: { chain_id: chainId },
67
+ });
65
68
  }
66
69
  exports.GearboxBackendApi = GearboxBackendApi;
67
70
  class URLApi {
@@ -48,7 +48,7 @@ class RewardConvex {
48
48
  return Object.entries(cm.adapters)
49
49
  .filter(([contract]) => !!convexPools[sdk_gov_1.contractsByAddress[contract.toLowerCase()]])
50
50
  .map(([contract, adapter]) => ({
51
- adapter,
51
+ adapter: adapter.address,
52
52
  contractAddress: contract,
53
53
  contract: sdk_gov_1.contractsByAddress[contract.toLowerCase()],
54
54
  }));
@@ -49,7 +49,7 @@ class StakingRewards {
49
49
  return Object.entries(cm.adapters)
50
50
  .filter(([contract]) => !!contractsRecord[sdk_gov_1.contractsByAddress[contract.toLowerCase()]])
51
51
  .map(([contract, adapter]) => ({
52
- adapter,
52
+ adapter: adapter.address,
53
53
  contractAddress: contract,
54
54
  contract: sdk_gov_1.contractsByAddress[contract.toLowerCase()],
55
55
  }));
@@ -15,6 +15,15 @@ export interface QuotaInfo {
15
15
  limit: bigint;
16
16
  isActive: boolean;
17
17
  }
18
+ interface IBaseContract {
19
+ address: Address;
20
+ contractType: string;
21
+ version: number;
22
+ name: string;
23
+ }
24
+ interface IAdapterContract extends IBaseContract {
25
+ targetContract: Address;
26
+ }
18
27
  export interface CreditManagerDataPayload {
19
28
  addr: Address;
20
29
  name: string;
@@ -34,11 +43,8 @@ export interface CreditManagerDataPayload {
34
43
  forbiddenTokenMask: bigint;
35
44
  isPaused: boolean;
36
45
  collateralTokens: readonly Address[];
37
- adapters: readonly {
38
- targetContract: Address;
39
- adapter: Address;
40
- }[];
41
- liquidationThresholds: readonly bigint[];
46
+ adapters: Array<IAdapterContract>;
47
+ liquidationThresholds: Array<[token: Address, lt: number]>;
42
48
  maxEnabledTokensLength: number;
43
49
  feeInterest: number;
44
50
  feeLiquidation: number;
@@ -46,7 +52,6 @@ export interface CreditManagerDataPayload {
46
52
  feeLiquidationExpired: number;
47
53
  liquidationDiscountExpired: number;
48
54
  quotas: PoolDataPayload["quotas"];
49
- lirm: PoolDataPayload["lirm"];
50
55
  isBorrowingForbidden: boolean;
51
56
  }
52
57
  export interface ChartsCreditManagerPayload {
@@ -96,3 +101,4 @@ export interface ChartsCreditManagerPayload {
96
101
  liquidityThresholds: Record<Address, number>;
97
102
  totalDebtLimit: BigNumberish;
98
103
  }
104
+ export {};
@@ -0,0 +1,21 @@
1
+ export declare const ipTokenAbi: readonly [{
2
+ readonly type: "function";
3
+ readonly inputs: readonly [];
4
+ readonly name: "YT";
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly internalType: "address";
8
+ readonly type: "address";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly inputs: readonly [];
14
+ readonly name: "expiry";
15
+ readonly outputs: readonly [{
16
+ readonly name: "";
17
+ readonly internalType: "uint256";
18
+ readonly type: "uint256";
19
+ }];
20
+ readonly stateMutability: "view";
21
+ }];
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3
- // IPendleSY
3
+ // IPToken
4
4
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.iPendleSyAbi = void 0;
7
- exports.iPendleSyAbi = [
6
+ exports.ipTokenAbi = void 0;
7
+ exports.ipTokenAbi = [
8
8
  {
9
9
  type: "function",
10
10
  inputs: [],
11
- name: "exchangeRate",
11
+ name: "YT",
12
+ outputs: [{ name: "", internalType: "address", type: "address" }],
13
+ stateMutability: "view",
14
+ },
15
+ {
16
+ type: "function",
17
+ inputs: [],
18
+ name: "expiry",
12
19
  outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
13
20
  stateMutability: "view",
14
21
  },
@@ -1,41 +1,17 @@
1
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
2
  readonly type: "function";
27
3
  readonly inputs: readonly [];
28
4
  readonly name: "readTokens";
29
5
  readonly outputs: readonly [{
30
- readonly name: "";
6
+ readonly name: "sy";
31
7
  readonly internalType: "address";
32
8
  readonly type: "address";
33
9
  }, {
34
- readonly name: "";
10
+ readonly name: "pt";
35
11
  readonly internalType: "address";
36
12
  readonly type: "address";
37
13
  }, {
38
- readonly name: "";
14
+ readonly name: "yt";
39
15
  readonly internalType: "address";
40
16
  readonly type: "address";
41
17
  }];
@@ -5,30 +5,14 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.iPendleMarketAbi = void 0;
7
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
8
  {
25
9
  type: "function",
26
10
  inputs: [],
27
11
  name: "readTokens",
28
12
  outputs: [
29
- { name: "", internalType: "address", type: "address" },
30
- { name: "", internalType: "address", type: "address" },
31
- { name: "", internalType: "address", type: "address" },
13
+ { name: "sy", internalType: "address", type: "address" },
14
+ { name: "pt", internalType: "address", type: "address" },
15
+ { name: "yt", internalType: "address", type: "address" },
32
16
  ],
33
17
  stateMutability: "view",
34
18
  },