@gearbox-protocol/sdk 14.12.0-next.66 → 14.12.0-next.68
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.
- package/dist/cjs/common-utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +3 -3
- package/dist/cjs/common-utils/utils/assets-math.js +7 -7
- package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/debt.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +5 -5
- package/dist/cjs/common-utils/utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +5 -5
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +2 -2
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +4 -4
- package/dist/cjs/model/history.js +28 -0
- package/dist/cjs/model/history.schema.js +84 -0
- package/dist/cjs/model/index.js +77 -0
- package/dist/cjs/model/liquidations.js +23 -0
- package/dist/cjs/model/liquidations.schema.js +93 -0
- package/dist/cjs/model/opportunities.js +55 -0
- package/dist/cjs/model/opportunities.schema.js +223 -0
- package/dist/cjs/model/package.json +1 -0
- package/dist/cjs/model/positions.js +1 -0
- package/dist/cjs/model/positions.schema.js +120 -0
- package/dist/cjs/model/primitives.js +1 -0
- package/dist/cjs/model/primitives.schema.js +85 -0
- package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
- package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
- package/dist/cjs/new-sdk/index.js +11 -0
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
- package/dist/cjs/new-sdk/opportunities/index.js +4 -0
- package/dist/cjs/new-sdk/opportunities/types.js +1 -0
- package/dist/cjs/new-sdk/package.json +1 -0
- package/dist/cjs/new-sdk/types.js +22 -0
- package/dist/cjs/new-sdk/utils/history.js +1 -0
- package/dist/cjs/new-sdk/utils/index.js +2 -0
- package/dist/cjs/offchain/GearboxAPI.js +33 -0
- package/dist/cjs/offchain/index.js +8 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
- package/dist/cjs/offchain/opportunities/index.js +4 -0
- package/dist/cjs/offchain/package.json +1 -0
- package/dist/cjs/offchain/types.js +1 -0
- package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
- package/dist/cjs/rewards/rewards/api.js +2 -2
- package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
- package/dist/cjs/sdk/MultichainSDK.js +18 -2
- package/dist/cjs/sdk/OnchainSDK.js +8 -1
- package/dist/cjs/sdk/accounts/index.js +2 -0
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +161 -106
- package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
- package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
- package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
- package/dist/cjs/sdk/base/TokensMeta.js +51 -0
- package/dist/cjs/sdk/base/index.js +2 -0
- package/dist/cjs/sdk/chain/chains.js +76 -0
- package/dist/cjs/sdk/chain/index.js +4 -0
- package/dist/cjs/sdk/core/errors.js +13 -0
- package/dist/cjs/sdk/core/index.js +2 -1
- package/dist/cjs/sdk/index.js +25 -1
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/cjs/sdk/market/MarketSuite.js +159 -0
- package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +92 -0
- package/dist/cjs/sdk/market/math.js +104 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
- package/dist/cjs/sdk/market/pool/math.js +44 -0
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +48 -0
- package/dist/cjs/sdk/opportunities/index.js +12 -0
- package/dist/cjs/sdk/types/multichain.js +1 -0
- package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/cjs/sdk/utils/index.js +3 -0
- package/dist/cjs/sdk/utils/zod.js +12 -0
- package/dist/esm/common-utils/index.js +1 -1
- package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
- package/dist/esm/common-utils/utils/assets-math.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
- package/dist/esm/common-utils/utils/index.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/history.js +26 -0
- package/dist/esm/model/history.schema.js +76 -0
- package/dist/esm/model/index.js +11 -0
- package/dist/esm/model/liquidations.js +22 -0
- package/dist/esm/model/liquidations.schema.js +85 -0
- package/dist/esm/model/opportunities.js +51 -0
- package/dist/esm/model/opportunities.schema.js +201 -0
- package/dist/esm/model/package.json +1 -0
- package/dist/esm/model/positions.js +1 -0
- package/dist/esm/model/positions.schema.js +109 -0
- package/dist/esm/model/primitives.js +1 -0
- package/dist/esm/model/primitives.schema.js +75 -0
- package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
- package/dist/esm/new-sdk/GearboxSDK.js +121 -0
- package/dist/esm/new-sdk/index.js +7 -0
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
- package/dist/esm/new-sdk/opportunities/index.js +3 -0
- package/dist/esm/new-sdk/opportunities/types.js +1 -0
- package/dist/esm/new-sdk/package.json +1 -0
- package/dist/esm/new-sdk/types.js +21 -0
- package/dist/esm/new-sdk/utils/history.js +1 -0
- package/dist/esm/new-sdk/utils/index.js +2 -0
- package/dist/esm/offchain/GearboxAPI.js +32 -0
- package/dist/esm/offchain/index.js +5 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
- package/dist/esm/offchain/opportunities/index.js +2 -0
- package/dist/esm/offchain/package.json +1 -0
- package/dist/esm/offchain/types.js +1 -0
- package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/rewards/rewards/api.js +1 -1
- package/dist/esm/rewards/rewards/extra-apy.js +1 -1
- package/dist/esm/sdk/MultichainSDK.js +18 -2
- package/dist/esm/sdk/OnchainSDK.js +8 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/index.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +164 -109
- package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
- package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/MultichainConstruct.js +79 -0
- package/dist/esm/sdk/base/TokensMeta.js +53 -2
- package/dist/esm/sdk/base/index.js +2 -1
- package/dist/esm/sdk/chain/chains.js +74 -2
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/core/errors.js +13 -1
- package/dist/esm/sdk/core/index.js +2 -2
- package/dist/esm/sdk/index.js +11 -5
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/esm/sdk/market/MarketSuite.js +159 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/esm/sdk/market/credit/CreditSuite.js +92 -0
- package/dist/esm/sdk/market/math.js +98 -0
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +28 -1
- package/dist/esm/sdk/market/pool/math.js +41 -0
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +59 -0
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +47 -0
- package/dist/esm/sdk/opportunities/index.js +4 -0
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/types/multichain.js +1 -0
- package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/esm/sdk/utils/index.js +3 -2
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/utils/zod.js +13 -2
- package/dist/types/common-utils/index.d.ts +1 -1
- package/dist/types/common-utils/utils/index.d.ts +1 -1
- package/dist/types/model/history.d.ts +105 -0
- package/dist/types/model/history.schema.d.ts +66 -0
- package/dist/types/model/index.d.ts +11 -0
- package/dist/types/model/liquidations.d.ts +238 -0
- package/dist/types/model/liquidations.schema.d.ts +294 -0
- package/dist/types/model/opportunities.d.ts +584 -0
- package/dist/types/model/opportunities.schema.d.ts +1037 -0
- package/dist/types/model/positions.d.ts +247 -0
- package/dist/types/model/positions.schema.d.ts +701 -0
- package/dist/types/model/primitives.d.ts +194 -0
- package/dist/types/model/primitives.schema.d.ts +81 -0
- package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
- package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
- package/dist/types/new-sdk/index.d.ts +9 -0
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
- package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
- package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
- package/dist/types/new-sdk/types.d.ts +149 -0
- package/dist/types/new-sdk/utils/history.d.ts +44 -0
- package/dist/types/new-sdk/utils/index.d.ts +2 -0
- package/dist/types/offchain/GearboxAPI.d.ts +31 -0
- package/dist/types/offchain/index.d.ts +5 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
- package/dist/types/offchain/opportunities/index.d.ts +2 -0
- package/dist/types/offchain/types.d.ts +50 -0
- package/dist/types/sdk/MultichainSDK.d.ts +15 -2
- package/dist/types/sdk/OnchainSDK.d.ts +9 -3
- package/dist/types/sdk/accounts/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
- package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
- package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
- package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
- package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
- package/dist/types/sdk/base/index.d.ts +2 -1
- package/dist/types/sdk/chain/chains.d.ts +68 -1
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/core/errors.d.ts +10 -1
- package/dist/types/sdk/core/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +15 -8
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
- package/dist/types/sdk/market/MarketSuite.d.ts +98 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +43 -0
- package/dist/types/sdk/market/credit/types.d.ts +22 -0
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/math.d.ts +74 -0
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
- package/dist/types/sdk/market/oracle/types.d.ts +46 -0
- package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
- package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
- package/dist/types/sdk/market/pool/math.d.ts +57 -0
- package/dist/types/sdk/market/pool/types.d.ts +23 -0
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
- package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
- package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +42 -0
- package/dist/types/sdk/opportunities/index.d.ts +4 -0
- package/dist/types/sdk/types/index.d.ts +2 -1
- package/dist/types/sdk/types/multichain.d.ts +65 -0
- package/dist/types/sdk/types/state.d.ts +1 -1
- package/dist/types/sdk/types/transactions.d.ts +3 -0
- package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
- package/dist/types/sdk/utils/index.d.ts +3 -2
- package/dist/types/sdk/utils/zod.d.ts +6 -2
- package/package.json +16 -1
- package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
- package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
- package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { Amount, AssetType, Bps, ChainId, Curator, Leverage, Timestamp, Token } from "./primitives.js";
|
|
2
|
+
import { Address } from "viem";
|
|
3
|
+
//#region src/model/opportunities.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Discriminator of the two opportunity kinds.
|
|
6
|
+
*
|
|
7
|
+
* - `"pool"` — passive lending: deposit the underlying, earn the supply rate.
|
|
8
|
+
* - `"strategy"` — leveraged position: deposit collateral, borrow the
|
|
9
|
+
* underlying against it inside a credit account.
|
|
10
|
+
**/
|
|
11
|
+
type OpportunityKind = "pool" | "strategy";
|
|
12
|
+
/**
|
|
13
|
+
* An off-chain points program a position accrues towards, e.g. a partner
|
|
14
|
+
* protocol's season points. Points have no APY, so they are listed separately
|
|
15
|
+
* from token rewards.
|
|
16
|
+
**/
|
|
17
|
+
interface PointsProgram {
|
|
18
|
+
/**
|
|
19
|
+
* Stable slug of the program.
|
|
20
|
+
*
|
|
21
|
+
* @example `"ethena-sats-s3"`
|
|
22
|
+
**/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
* Display name of the program.
|
|
26
|
+
*
|
|
27
|
+
* @example `"Ethena Sats Season 3"`
|
|
28
|
+
**/
|
|
29
|
+
name: string;
|
|
30
|
+
/**
|
|
31
|
+
* Points earned per unit of position relative to the program's base rate, or
|
|
32
|
+
* `null` when the program does not publish one.
|
|
33
|
+
*
|
|
34
|
+
* @example `2` for a 2x boost
|
|
35
|
+
**/
|
|
36
|
+
multiplier: number | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Rewards paid out in a token, e.g. a liquidity mining program.
|
|
40
|
+
**/
|
|
41
|
+
interface TokenRewards {
|
|
42
|
+
kind: "token";
|
|
43
|
+
/**
|
|
44
|
+
* Token the rewards are paid in.
|
|
45
|
+
**/
|
|
46
|
+
token: Token;
|
|
47
|
+
/**
|
|
48
|
+
* Extra APR earned by supplying, in basis points.
|
|
49
|
+
*
|
|
50
|
+
* @example `120` for +1.2% APR
|
|
51
|
+
**/
|
|
52
|
+
supplyApr?: Bps;
|
|
53
|
+
/**
|
|
54
|
+
* Extra APR earned on the borrowed side, in basis points. Present when a
|
|
55
|
+
* program rebates part of the borrow cost.
|
|
56
|
+
*
|
|
57
|
+
* @example `45` for +0.45% APR
|
|
58
|
+
**/
|
|
59
|
+
borrowApr?: Bps;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Rewards accrued as points rather than tokens.
|
|
63
|
+
**/
|
|
64
|
+
interface PointRewards {
|
|
65
|
+
kind: "point";
|
|
66
|
+
/**
|
|
67
|
+
* Programs the position accrues points in.
|
|
68
|
+
**/
|
|
69
|
+
points: PointsProgram[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Any reward stream attached to an opportunity.
|
|
73
|
+
**/
|
|
74
|
+
type Rewards = TokenRewards | PointRewards;
|
|
75
|
+
/**
|
|
76
|
+
* A yield figure split into the part the protocol itself generates and the
|
|
77
|
+
* incentives layered on top.
|
|
78
|
+
**/
|
|
79
|
+
interface ApyBreakdown {
|
|
80
|
+
/**
|
|
81
|
+
* Everything combined, in basis points: the number a UI shows as "APY".
|
|
82
|
+
*
|
|
83
|
+
* Absent in `onchain` mode: it folds in the incentives of {@link rewards},
|
|
84
|
+
* which only the backend knows.
|
|
85
|
+
*
|
|
86
|
+
* @example `842` for 8.42% APY
|
|
87
|
+
*
|
|
88
|
+
* @mode offchain
|
|
89
|
+
**/
|
|
90
|
+
totalApy?: Bps;
|
|
91
|
+
/**
|
|
92
|
+
* The part generated by the underlying protocol alone, without incentives,
|
|
93
|
+
* in basis points. Always readable from the chain.
|
|
94
|
+
*
|
|
95
|
+
* @example `610` for 6.10% APY
|
|
96
|
+
**/
|
|
97
|
+
organicApy: Bps;
|
|
98
|
+
/**
|
|
99
|
+
* Incentives that make up the difference between {@link organicApy} and
|
|
100
|
+
* {@link totalApy}, plus any points programs that carry no APY at all.
|
|
101
|
+
*
|
|
102
|
+
* @mode offchain
|
|
103
|
+
**/
|
|
104
|
+
rewards?: Rewards[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Fields both opportunity kinds share.
|
|
108
|
+
**/
|
|
109
|
+
interface OpportunityBase {
|
|
110
|
+
/**
|
|
111
|
+
* Chain the opportunity lives on.
|
|
112
|
+
**/
|
|
113
|
+
chainId: ChainId;
|
|
114
|
+
/**
|
|
115
|
+
* Human-readable name for the row.
|
|
116
|
+
*
|
|
117
|
+
* @example `"USDC Pool"`, `"wstETH / WETH"`
|
|
118
|
+
**/
|
|
119
|
+
name: string;
|
|
120
|
+
/**
|
|
121
|
+
* Curator of the market this opportunity belongs to.
|
|
122
|
+
**/
|
|
123
|
+
curator: Curator;
|
|
124
|
+
/**
|
|
125
|
+
* Token that is supplied to the pool and borrowed by credit accounts. All
|
|
126
|
+
* amounts of the opportunity are denominated in it.
|
|
127
|
+
*
|
|
128
|
+
* For RWA markets it's an unwrapped, e.g. — `USDC`, not `dcUSDC` (pool underlying according to contract).
|
|
129
|
+
* The wrapper converts one-for-one, so every amount stays exact.
|
|
130
|
+
**/
|
|
131
|
+
underlyingToken: Token;
|
|
132
|
+
/**
|
|
133
|
+
* Debt principal drawn against the opportunity: everything the pool has lent
|
|
134
|
+
* out for a {@link PoolOpportunity} (`pool.totalBorrowed()`), only what the
|
|
135
|
+
* strategy's credit manager has drawn for a {@link StrategyOpportunity}
|
|
136
|
+
* (`pool.creditManagerBorrowed(creditManager)`).
|
|
137
|
+
**/
|
|
138
|
+
totalBorrow: Amount;
|
|
139
|
+
/**
|
|
140
|
+
* Tokens accepted as collateral, i.e. the tokens that have both a non-zero
|
|
141
|
+
* liquidation threshold and a non-zero quota limit.
|
|
142
|
+
**/
|
|
143
|
+
collateralTokens: Token[];
|
|
144
|
+
/**
|
|
145
|
+
* The contract's own pause flag: the pool for a {@link PoolOpportunity}, the
|
|
146
|
+
* credit facade or the pool it borrows from for a
|
|
147
|
+
* {@link StrategyOpportunity}.
|
|
148
|
+
**/
|
|
149
|
+
paused: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Whether at least one of {@link collateralTokens} is a real-world-asset
|
|
152
|
+
* token. Read from a hardcoded per-chain list rather than from the chain.
|
|
153
|
+
**/
|
|
154
|
+
rwa: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the opportunity is being wound down and should no longer be
|
|
157
|
+
* entered. Read from a hardcoded per-chain list, kept separately for pools
|
|
158
|
+
* and for strategies, and unrelated to
|
|
159
|
+
* {@link StrategyOpportunity.expirationDate}.
|
|
160
|
+
**/
|
|
161
|
+
sunset: boolean;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Passive lending into a Gearbox pool.
|
|
165
|
+
*
|
|
166
|
+
* Identified by `(chainId, pool)`, see {@link poolOpportunityId}.
|
|
167
|
+
**/
|
|
168
|
+
interface PoolOpportunity extends OpportunityBase {
|
|
169
|
+
kind: "pool";
|
|
170
|
+
/**
|
|
171
|
+
* Address of the ERC-4626 pool contract.
|
|
172
|
+
**/
|
|
173
|
+
pool: Address;
|
|
174
|
+
/**
|
|
175
|
+
* Size of the pool: the underlying its shares are worth, converted at the
|
|
176
|
+
* current share rate, i.e. `pool.totalAssets()`. Denominated in the
|
|
177
|
+
* underlying rather than in shares, so it is comparable with
|
|
178
|
+
* {@link OpportunityBase.totalBorrow}.
|
|
179
|
+
**/
|
|
180
|
+
totalSupply: Amount;
|
|
181
|
+
/**
|
|
182
|
+
* How much of the pool's capital is currently borrowed, in basis points.
|
|
183
|
+
*
|
|
184
|
+
* @example `7500` for 75% utilization
|
|
185
|
+
**/
|
|
186
|
+
utilization: Bps;
|
|
187
|
+
/**
|
|
188
|
+
* Yield earned by supplying to the pool.
|
|
189
|
+
*
|
|
190
|
+
* Its {@link ApyBreakdown.organicApy} is the pool's own supply rate (
|
|
191
|
+
* which consists of base interest and quota revenue)
|
|
192
|
+
* so this group is present in `onchain` mode too, with only that part filled.
|
|
193
|
+
**/
|
|
194
|
+
supplyApy: ApyBreakdown;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A leveraged position: one credit manager plus one target collateral token.
|
|
198
|
+
* A credit manager that accepts five collateral tokens therefore produces five
|
|
199
|
+
* strategies.
|
|
200
|
+
*
|
|
201
|
+
* Identified by `(chainId, creditManager, targetCollateral.address)`,
|
|
202
|
+
* see {@link strategyOpportunityId}.
|
|
203
|
+
**/
|
|
204
|
+
interface StrategyOpportunity extends OpportunityBase {
|
|
205
|
+
kind: "strategy";
|
|
206
|
+
/**
|
|
207
|
+
* Address of the credit manager the position is opened in.
|
|
208
|
+
**/
|
|
209
|
+
creditManager: Address;
|
|
210
|
+
/**
|
|
211
|
+
* Collateral token the position is built around.
|
|
212
|
+
**/
|
|
213
|
+
targetCollateral: Token;
|
|
214
|
+
/**
|
|
215
|
+
* Liquidation threshold of {@link targetCollateral} in this credit manager,
|
|
216
|
+
* in basis points: the share of the collateral value that counts towards
|
|
217
|
+
* covering debt.
|
|
218
|
+
*
|
|
219
|
+
* @example `9000` for an 86% threshold
|
|
220
|
+
**/
|
|
221
|
+
liquidationThreshold: Bps;
|
|
222
|
+
/**
|
|
223
|
+
* Share of a liquidated account's value paid to the liquidator, in basis
|
|
224
|
+
* points.
|
|
225
|
+
*
|
|
226
|
+
* @example `400` for a 4% premium
|
|
227
|
+
**/
|
|
228
|
+
liquidationPremium: Bps;
|
|
229
|
+
/**
|
|
230
|
+
* Share of a liquidated account's value taken by the protocol, in basis
|
|
231
|
+
* points.
|
|
232
|
+
*
|
|
233
|
+
* @example `150` for a 1.5% fee
|
|
234
|
+
**/
|
|
235
|
+
liquidationFee: Bps;
|
|
236
|
+
/**
|
|
237
|
+
* Moment the credit facade expires, after which positions can no longer be
|
|
238
|
+
* opened and open ones become liquidatable, or `null` when the facade is not
|
|
239
|
+
* expirable. A timestamp in the past means it has already expired.
|
|
240
|
+
**/
|
|
241
|
+
expirationDate: Timestamp | null;
|
|
242
|
+
/**
|
|
243
|
+
* Yield the collateral itself earns while it sits in the credit account,
|
|
244
|
+
* before leverage. Comes from external sources rather than from the chain.
|
|
245
|
+
*
|
|
246
|
+
* @mode offchain
|
|
247
|
+
**/
|
|
248
|
+
collateralApy?: ApyBreakdown;
|
|
249
|
+
/**
|
|
250
|
+
* Net yield at {@link maxLeverage}:
|
|
251
|
+
* `collateralApy * maxLeverage - borrowApy * (maxLeverage - 1)`, applied to
|
|
252
|
+
* {@link ApyBreakdown.totalApy}, {@link ApyBreakdown.organicApy} and
|
|
253
|
+
* {@link ApyBreakdown.rewards} alike.
|
|
254
|
+
*
|
|
255
|
+
* Absent in `onchain` mode: its {@link collateralApy} term is.
|
|
256
|
+
*
|
|
257
|
+
* @mode offchain
|
|
258
|
+
**/
|
|
259
|
+
maxLeverageApy?: ApyBreakdown;
|
|
260
|
+
/**
|
|
261
|
+
* Annual cost of the borrowed underlying, in basis points, including the
|
|
262
|
+
* protocol's interest fee.
|
|
263
|
+
*
|
|
264
|
+
* @example `520` for 5.2% APY
|
|
265
|
+
**/
|
|
266
|
+
borrowApy?: Bps;
|
|
267
|
+
/**
|
|
268
|
+
* Annual cost of the quota on {@link targetCollateral}, scaled to the debt a
|
|
269
|
+
* maximally leveraged position carries, in basis points. Comes on top of
|
|
270
|
+
* {@link borrowApy}.
|
|
271
|
+
*
|
|
272
|
+
* @example `90` for +0.9% APY
|
|
273
|
+
**/
|
|
274
|
+
additionalBorrowApy?: Bps;
|
|
275
|
+
/**
|
|
276
|
+
* Size of the strategy: the summed total value of the credit accounts
|
|
277
|
+
* holding {@link targetCollateral}. An account that holds several strategy
|
|
278
|
+
* collaterals counts in full towards each of them.
|
|
279
|
+
*
|
|
280
|
+
* Absent in `onchain` mode.
|
|
281
|
+
*
|
|
282
|
+
* @mode offchain
|
|
283
|
+
**/
|
|
284
|
+
totalValue?: Amount;
|
|
285
|
+
/**
|
|
286
|
+
* Share of {@link totalValue} that is borrowed, in basis points:
|
|
287
|
+
* `totalBorrow / totalValue`.
|
|
288
|
+
*
|
|
289
|
+
* Absent in `onchain` mode, because its denominator is, see
|
|
290
|
+
* {@link totalValue}.
|
|
291
|
+
*
|
|
292
|
+
* @example `7500` for 75% utilization
|
|
293
|
+
*
|
|
294
|
+
* @mode offchain
|
|
295
|
+
**/
|
|
296
|
+
utilization?: Bps;
|
|
297
|
+
/**
|
|
298
|
+
* Largest debt a single new position can take on right now: the tightest of
|
|
299
|
+
* the credit manager's remaining debt limit, the pool's free liquidity and
|
|
300
|
+
* the facade's per-account maximum.
|
|
301
|
+
**/
|
|
302
|
+
maxBorrowAmount: Amount;
|
|
303
|
+
/**
|
|
304
|
+
* Highest leverage the liquidation threshold allows,
|
|
305
|
+
* `1 / (1 - liquidationThreshold)`.
|
|
306
|
+
*
|
|
307
|
+
* @example `10` at a 90% threshold
|
|
308
|
+
**/
|
|
309
|
+
maxLeverage: Leverage;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* A row of the opportunities list.
|
|
313
|
+
**/
|
|
314
|
+
type Opportunity = PoolOpportunity | StrategyOpportunity;
|
|
315
|
+
/**
|
|
316
|
+
* Canonical id of an opportunity: the string used to match a row read from the
|
|
317
|
+
* chain with the same row served by the backend.
|
|
318
|
+
**/
|
|
319
|
+
type OpportunityId = string;
|
|
320
|
+
/**
|
|
321
|
+
* Builds the canonical id of a pool opportunity.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* poolOpportunityId(1, "0xda00...") // "1:0xda00..."
|
|
326
|
+
* ```
|
|
327
|
+
**/
|
|
328
|
+
declare function poolOpportunityId(chainId: ChainId, pool: Address): OpportunityId;
|
|
329
|
+
/**
|
|
330
|
+
* Builds the canonical id of a strategy opportunity.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* strategyOpportunityId(1, "0x3eb9...", "0x7f39...") // "1:0x3eb9...:0x7f39..."
|
|
335
|
+
* ```
|
|
336
|
+
**/
|
|
337
|
+
declare function strategyOpportunityId(chainId: ChainId, creditManager: Address, targetCollateral: Address): OpportunityId;
|
|
338
|
+
/**
|
|
339
|
+
* Canonical id of any opportunity, dispatching on {@link Opportunity.kind}.
|
|
340
|
+
**/
|
|
341
|
+
declare function opportunityId(opportunity: Opportunity): OpportunityId;
|
|
342
|
+
/**
|
|
343
|
+
* Optional narrowing of an opportunities list.
|
|
344
|
+
*
|
|
345
|
+
* The list is filtered in memory over final values, so there is no paging and
|
|
346
|
+
* no sorting: a screen sorts what it got.
|
|
347
|
+
*
|
|
348
|
+
* Every criterion is optional and an omitted one matches any value, so an empty
|
|
349
|
+
* filter is the same as no filter at all. Criteria combine with AND.
|
|
350
|
+
**/
|
|
351
|
+
interface OpportunityFilter {
|
|
352
|
+
/**
|
|
353
|
+
* Keep only pools or only strategies.
|
|
354
|
+
**/
|
|
355
|
+
kind?: OpportunityKind;
|
|
356
|
+
/**
|
|
357
|
+
* Keep only opportunities on these chains.
|
|
358
|
+
**/
|
|
359
|
+
chainIds?: ChainId[];
|
|
360
|
+
/**
|
|
361
|
+
* Keep only opportunities whose {@link OpportunityBase.underlyingToken} is of
|
|
362
|
+
* this class, which for an RWA market means the class of the token its
|
|
363
|
+
* wrapper holds. An underlying that is not in the hardcoded table never
|
|
364
|
+
* matches, so a set filter also drops unclassified rows.
|
|
365
|
+
**/
|
|
366
|
+
underlyingType?: AssetType;
|
|
367
|
+
/**
|
|
368
|
+
* Keep only paused opportunities, or only unpaused ones.
|
|
369
|
+
**/
|
|
370
|
+
paused?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Keep only opportunities being wound down, or only the ones that are not.
|
|
373
|
+
**/
|
|
374
|
+
sunset?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Keep only opportunities that accept RWA collateral, or only the ones that
|
|
377
|
+
* do not.
|
|
378
|
+
**/
|
|
379
|
+
rwa?: boolean;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Whether an opportunity satisfies every criterion of a filter.
|
|
383
|
+
*
|
|
384
|
+
* This is the single definition of what each criterion means: every source
|
|
385
|
+
* builds its rows first and runs them through here, so the chain and the
|
|
386
|
+
* backend cannot disagree on what a filter selects.
|
|
387
|
+
*
|
|
388
|
+
* @param opportunity - Row to test.
|
|
389
|
+
* @param filter - Criteria to test against. An absent filter matches anything.
|
|
390
|
+
**/
|
|
391
|
+
declare function matchesOpportunityFilter(opportunity: Opportunity, filter?: OpportunityFilter): boolean;
|
|
392
|
+
/**
|
|
393
|
+
* One point of an interest rate curve.
|
|
394
|
+
**/
|
|
395
|
+
interface RateCurvePoint {
|
|
396
|
+
/**
|
|
397
|
+
* Utilization this point is sampled at, in basis points.
|
|
398
|
+
*
|
|
399
|
+
* @example `9000` for 90% utilization
|
|
400
|
+
**/
|
|
401
|
+
utilization: Bps;
|
|
402
|
+
/**
|
|
403
|
+
* Rate depositors earn at this utilization, in basis points.
|
|
404
|
+
*
|
|
405
|
+
* @example `430` for 4.3%
|
|
406
|
+
**/
|
|
407
|
+
supplyApy: Bps;
|
|
408
|
+
/**
|
|
409
|
+
* Base rate borrowers pay at this utilization, in basis points. Excludes the
|
|
410
|
+
* per-credit-manager interest fee, because the curve belongs to the pool and
|
|
411
|
+
* every credit manager of a market can charge a different one.
|
|
412
|
+
*
|
|
413
|
+
* @example `620` for 6.2%
|
|
414
|
+
**/
|
|
415
|
+
borrowApy: Bps;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The pool's interest rate model, evaluated into chart-ready points so that no
|
|
419
|
+
* consumer has to reimplement the model.
|
|
420
|
+
**/
|
|
421
|
+
interface RateCurve {
|
|
422
|
+
/**
|
|
423
|
+
* Points ordered by ascending utilization, always including the kinks of the
|
|
424
|
+
* model so the polyline is exact rather than approximated.
|
|
425
|
+
**/
|
|
426
|
+
points: RateCurvePoint[];
|
|
427
|
+
/**
|
|
428
|
+
* Utilization above which borrowing is forbidden, in basis points, or `null`
|
|
429
|
+
* when the model has no such cutoff.
|
|
430
|
+
*
|
|
431
|
+
* @example `9000` for a cutoff at 90% utilization
|
|
432
|
+
**/
|
|
433
|
+
borrowingLimitUtilization: Bps | null;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Quota configuration of one collateral token: how much of it the market
|
|
437
|
+
* accepts in total, and what holding it costs.
|
|
438
|
+
**/
|
|
439
|
+
interface QuotaAsset {
|
|
440
|
+
/**
|
|
441
|
+
* Token the quota applies to.
|
|
442
|
+
**/
|
|
443
|
+
token: Token;
|
|
444
|
+
/**
|
|
445
|
+
* Annual quota rate paid on the quoted amount, in basis points.
|
|
446
|
+
*
|
|
447
|
+
* @example `250` for 2.5% per year
|
|
448
|
+
**/
|
|
449
|
+
quotaRate: Bps;
|
|
450
|
+
/**
|
|
451
|
+
* Maximum amount that can be quoted across all credit accounts, denominated
|
|
452
|
+
* in the market's underlying.
|
|
453
|
+
**/
|
|
454
|
+
limit: Amount;
|
|
455
|
+
/**
|
|
456
|
+
* Amount currently quoted, denominated in the market's underlying.
|
|
457
|
+
**/
|
|
458
|
+
used: Amount;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* A price feed and the feeds it is composed of.
|
|
462
|
+
**/
|
|
463
|
+
interface PriceFeedData {
|
|
464
|
+
/**
|
|
465
|
+
* Display name of the feed.
|
|
466
|
+
*
|
|
467
|
+
* @example `"CompositePriceFeed wstETH / USD"`
|
|
468
|
+
**/
|
|
469
|
+
name: string;
|
|
470
|
+
/**
|
|
471
|
+
* Gearbox price feed contract type.
|
|
472
|
+
*
|
|
473
|
+
* @example `"PRICE_FEED::COMPOSITE"`, `"PRICE_FEED::REDSTONE"`
|
|
474
|
+
**/
|
|
475
|
+
type: string;
|
|
476
|
+
/**
|
|
477
|
+
* Address of the feed contract.
|
|
478
|
+
**/
|
|
479
|
+
feedAddress: Address;
|
|
480
|
+
/**
|
|
481
|
+
* Feeds this feed reads from. Empty for a leaf feed.
|
|
482
|
+
**/
|
|
483
|
+
dependencies: PriceFeedData[];
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Prices and feeds behind a strategy, i.e. everything a liquidation-price chart
|
|
487
|
+
* needs.
|
|
488
|
+
**/
|
|
489
|
+
interface PriceFeedSummary {
|
|
490
|
+
/**
|
|
491
|
+
* Price of one whole underlying token in USD.
|
|
492
|
+
*
|
|
493
|
+
* @example `1.0001` for USDC
|
|
494
|
+
**/
|
|
495
|
+
underlyingPriceInUsd: number;
|
|
496
|
+
/**
|
|
497
|
+
* Price of one whole collateral token in USD.
|
|
498
|
+
*
|
|
499
|
+
* @example `4210.55` for wstETH
|
|
500
|
+
**/
|
|
501
|
+
collateralPriceInUsd: number;
|
|
502
|
+
/**
|
|
503
|
+
* Price of one whole collateral token expressed in the underlying.
|
|
504
|
+
*
|
|
505
|
+
* @example `4210.13` for wstETH priced in USDC
|
|
506
|
+
**/
|
|
507
|
+
collateralPriceInUnderlying: number;
|
|
508
|
+
/**
|
|
509
|
+
* Main feed of the underlying token.
|
|
510
|
+
**/
|
|
511
|
+
underlyingFeed: PriceFeedData;
|
|
512
|
+
/**
|
|
513
|
+
* Main feed of the collateral token. Reserve feeds are not included.
|
|
514
|
+
**/
|
|
515
|
+
collateralFeed: PriceFeedData;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* A pool opportunity plus the data only its detail screen needs.
|
|
519
|
+
**/
|
|
520
|
+
interface PoolOpportunityDetail extends PoolOpportunity {
|
|
521
|
+
/**
|
|
522
|
+
* Interest rate curve of the pool.
|
|
523
|
+
**/
|
|
524
|
+
rateCurve: RateCurve;
|
|
525
|
+
/**
|
|
526
|
+
* Quota configuration of every collateral token of the market.
|
|
527
|
+
**/
|
|
528
|
+
quotaAssets: QuotaAsset[];
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* A strategy opportunity plus the data only its detail screen needs.
|
|
532
|
+
**/
|
|
533
|
+
interface StrategyOpportunityDetail extends StrategyOpportunity {
|
|
534
|
+
/**
|
|
535
|
+
* Interest rate curve of the pool the strategy borrows from.
|
|
536
|
+
**/
|
|
537
|
+
rateCurve: RateCurve;
|
|
538
|
+
/**
|
|
539
|
+
* Prices and feeds of the underlying and the target collateral.
|
|
540
|
+
**/
|
|
541
|
+
priceFeeds: PriceFeedSummary;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Detailed view of any opportunity.
|
|
545
|
+
**/
|
|
546
|
+
type OpportunityDetail = PoolOpportunityDetail | StrategyOpportunityDetail;
|
|
547
|
+
/**
|
|
548
|
+
* Identifies a pool opportunity in a detail request.
|
|
549
|
+
**/
|
|
550
|
+
interface PoolOpportunityKey {
|
|
551
|
+
chainId: ChainId;
|
|
552
|
+
pool: Address;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Identifies a strategy opportunity in a detail request.
|
|
556
|
+
**/
|
|
557
|
+
interface StrategyOpportunityKey {
|
|
558
|
+
chainId: ChainId;
|
|
559
|
+
creditManager: Address;
|
|
560
|
+
/**
|
|
561
|
+
* Address of the target collateral token.
|
|
562
|
+
**/
|
|
563
|
+
targetCollateral: Address;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* {@link PoolOpportunityKey} tagged with its kind, for requests that accept
|
|
567
|
+
* both kinds.
|
|
568
|
+
**/
|
|
569
|
+
interface PoolOpportunityRef extends PoolOpportunityKey {
|
|
570
|
+
kind: "pool";
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* {@link StrategyOpportunityKey} tagged with its kind, for requests that accept
|
|
574
|
+
* both kinds.
|
|
575
|
+
**/
|
|
576
|
+
interface StrategyOpportunityRef extends StrategyOpportunityKey {
|
|
577
|
+
kind: "strategy";
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Identifies any opportunity, for requests that accept both kinds.
|
|
581
|
+
**/
|
|
582
|
+
type OpportunityKey = PoolOpportunityRef | StrategyOpportunityRef;
|
|
583
|
+
//#endregion
|
|
584
|
+
export { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId };
|