@gearbox-protocol/sdk 14.12.0-next.67 → 14.12.0-next.69

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 (53) hide show
  1. package/dist/cjs/model/index.js +13 -0
  2. package/dist/cjs/model/liquidations.schema.js +3 -1
  3. package/dist/cjs/model/opportunities.schema.js +10 -7
  4. package/dist/cjs/model/positions.schema.js +120 -0
  5. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +19 -8
  6. package/dist/cjs/sdk/market/MarketSuite.js +8 -12
  7. package/dist/cjs/sdk/market/credit/CreditSuite.js +4 -14
  8. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +8 -63
  9. package/dist/cjs/sdk/router/RouterV310Contract.js +34 -0
  10. package/dist/esm/dev/AccountOpener.js +1 -1
  11. package/dist/esm/dev/withdrawalUtils.js +1 -1
  12. package/dist/esm/model/index.js +3 -1
  13. package/dist/esm/model/liquidations.schema.js +3 -1
  14. package/dist/esm/model/opportunities.schema.js +10 -7
  15. package/dist/esm/model/positions.schema.js +109 -0
  16. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  17. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  18. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  19. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +20 -9
  20. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  21. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  22. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  23. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  24. package/dist/esm/sdk/base/TokensMeta.js +2 -2
  25. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  26. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  27. package/dist/esm/sdk/market/MarketSuite.js +8 -12
  28. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  29. package/dist/esm/sdk/market/credit/CreditSuite.js +5 -15
  30. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  31. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  32. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  33. package/dist/esm/sdk/opportunities/OpportunitiesService.js +8 -63
  34. package/dist/esm/sdk/pools/PoolService.js +1 -1
  35. package/dist/esm/sdk/router/RouterV310Contract.js +34 -0
  36. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  37. package/dist/types/model/index.d.ts +3 -1
  38. package/dist/types/model/liquidations.d.ts +9 -1
  39. package/dist/types/model/liquidations.schema.d.ts +5 -3
  40. package/dist/types/model/opportunities.d.ts +70 -29
  41. package/dist/types/model/opportunities.schema.d.ts +220 -249
  42. package/dist/types/model/positions.d.ts +239 -3
  43. package/dist/types/model/positions.schema.d.ts +701 -0
  44. package/dist/types/model/primitives.d.ts +3 -2
  45. package/dist/types/sdk/index.d.ts +3 -3
  46. package/dist/types/sdk/market/MarketSuite.d.ts +4 -15
  47. package/dist/types/sdk/market/credit/CreditSuite.d.ts +3 -7
  48. package/dist/types/sdk/market/index.d.ts +2 -2
  49. package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +6 -11
  50. package/dist/types/sdk/router/RouterV310Contract.d.ts +5 -1
  51. package/dist/types/sdk/router/index.d.ts +2 -2
  52. package/dist/types/sdk/router/types.d.ts +35 -1
  53. package/package.json +1 -1
@@ -100,7 +100,7 @@ declare const delayedReceivedAssetSchema: z.ZodObject<{
100
100
  assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
101
101
  }, z.core.$strip>;
102
102
  isDelayed: z.ZodLiteral<true>;
103
- redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
103
+ redeemer: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
104
104
  claimableAt: z.ZodOptional<z.ZodNumber>;
105
105
  }, z.core.$strip>;
106
106
  /**
@@ -130,7 +130,7 @@ declare const receivedAssetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
130
130
  assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
131
131
  }, z.core.$strip>;
132
132
  isDelayed: z.ZodLiteral<true>;
133
- redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
133
+ redeemer: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
134
134
  claimableAt: z.ZodOptional<z.ZodNumber>;
135
135
  }, z.core.$strip>], "isDelayed">;
136
136
  /**
@@ -153,6 +153,8 @@ declare const liquidationApprovalSchema: z.ZodObject<{
153
153
  * {@link LiquidationPosition}
154
154
  **/
155
155
  declare const liquidationPositionSchema: z.ZodObject<{
156
+ kind: z.ZodLiteral<"liquidation">;
157
+ name: z.ZodString;
156
158
  chainId: z.ZodNumber;
157
159
  sourceToken: z.ZodObject<{
158
160
  chainId: z.ZodNumber;
@@ -260,7 +262,7 @@ declare const liquidationDetailsSchema: z.ZodObject<{
260
262
  assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
261
263
  }, z.core.$strip>;
262
264
  isDelayed: z.ZodLiteral<true>;
263
- redeemerAddress: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
265
+ redeemer: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>;
264
266
  claimableAt: z.ZodOptional<z.ZodNumber>;
265
267
  }, z.core.$strip>], "isDelayed">>;
266
268
  isLiquidatorEligible: z.ZodBoolean;
@@ -80,12 +80,17 @@ interface ApyBreakdown {
80
80
  /**
81
81
  * Everything combined, in basis points: the number a UI shows as "APY".
82
82
  *
83
+ * Absent in `onchain` mode: it folds in the incentives of {@link rewards},
84
+ * which only the backend knows.
85
+ *
83
86
  * @example `842` for 8.42% APY
87
+ *
88
+ * @mode offchain
84
89
  **/
85
- totalApy: Bps;
90
+ totalApy?: Bps;
86
91
  /**
87
92
  * The part generated by the underlying protocol alone, without incentives,
88
- * in basis points.
93
+ * in basis points. Always readable from the chain.
89
94
  *
90
95
  * @example `610` for 6.10% APY
91
96
  **/
@@ -93,8 +98,10 @@ interface ApyBreakdown {
93
98
  /**
94
99
  * Incentives that make up the difference between {@link organicApy} and
95
100
  * {@link totalApy}, plus any points programs that carry no APY at all.
101
+ *
102
+ * @mode offchain
96
103
  **/
97
- rewards: Rewards[];
104
+ rewards?: Rewards[];
98
105
  }
99
106
  /**
100
107
  * Fields both opportunity kinds share.
@@ -109,7 +116,7 @@ interface OpportunityBase {
109
116
  *
110
117
  * @example `"USDC Pool"`, `"wstETH / WETH"`
111
118
  **/
112
- title: string;
119
+ name: string;
113
120
  /**
114
121
  * Curator of the market this opportunity belongs to.
115
122
  **/
@@ -123,32 +130,12 @@ interface OpportunityBase {
123
130
  **/
124
131
  underlyingToken: Token;
125
132
  /**
126
- * Size of the opportunity.
127
- *
128
- * For a pool this is the supply of pool shares; for a strategy it is the
129
- * summed total value of the credit accounts holding the target collateral.
130
- **/
131
- totalSupply: Amount;
132
- /**
133
- * Debt principal drawn against the opportunity.
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)`).
134
137
  **/
135
138
  totalBorrow: Amount;
136
- /**
137
- * How much of the available capital is currently borrowed, in basis points.
138
- *
139
- * @example `7500` for 75% utilization
140
- **/
141
- utilization: Bps;
142
- /**
143
- * Yield earned by supplying. For a strategy it is the net yield at
144
- * {@link StrategyOpportunity.maxLeverage}.
145
- *
146
- * Absent in `onchain` mode: every yield figure that folds in incentives,
147
- * points or smoothing is computed by the backend.
148
- *
149
- * @mode offchain
150
- **/
151
- supplyApy?: ApyBreakdown;
152
139
  /**
153
140
  * Tokens accepted as collateral, i.e. the tokens that have both a non-zero
154
141
  * liquidation threshold and a non-zero quota limit.
@@ -184,6 +171,27 @@ interface PoolOpportunity extends OpportunityBase {
184
171
  * Address of the ERC-4626 pool contract.
185
172
  **/
186
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;
187
195
  }
188
196
  /**
189
197
  * A leveraged position: one credit manager plus one target collateral token.
@@ -233,11 +241,22 @@ interface StrategyOpportunity extends OpportunityBase {
233
241
  expirationDate: Timestamp | null;
234
242
  /**
235
243
  * Yield the collateral itself earns while it sits in the credit account,
236
- * before leverage.
244
+ * before leverage. Comes from external sources rather than from the chain.
237
245
  *
238
246
  * @mode offchain
239
247
  **/
240
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;
241
260
  /**
242
261
  * Annual cost of the borrowed underlying, in basis points, including the
243
262
  * protocol's interest fee.
@@ -253,6 +272,28 @@ interface StrategyOpportunity extends OpportunityBase {
253
272
  * @example `90` for +0.9% APY
254
273
  **/
255
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;
256
297
  /**
257
298
  * Largest debt a single new position can take on right now: the tightest of
258
299
  * the credit manager's remaining debt limit, the pool's free liquidity and