@gearbox-protocol/sdk 15.1.0-next.24 → 15.1.0-next.25

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 (72) hide show
  1. package/dist/cjs/model/charts.js +20 -34
  2. package/dist/cjs/model/opportunities.schema.js +14 -12
  3. package/dist/cjs/sdk/OnchainSDK.js +16 -0
  4. package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +2 -2
  5. package/dist/cjs/sdk/base/TokensMeta.js +33 -1
  6. package/dist/cjs/sdk/base/index.js +1 -0
  7. package/dist/cjs/sdk/base/token-types.js +13 -0
  8. package/dist/cjs/sdk/chain/chains.js +9 -12
  9. package/dist/cjs/sdk/chain/index.js +0 -1
  10. package/dist/cjs/sdk/index.js +1 -2
  11. package/dist/cjs/sdk/market/MarketSuite.js +11 -5
  12. package/dist/cjs/sdk/market/credit/CreditSuite.js +1 -1
  13. package/dist/cjs/sdk/market/credit/collateralUtils.js +2 -14
  14. package/dist/cjs/sdk/market/credit/index.js +0 -1
  15. package/dist/cjs/sdk/market/index.js +0 -1
  16. package/dist/cjs/sdk/market/strategyName.js +4 -6
  17. package/dist/cjs/sdk/positions/PositionsService.js +1 -1
  18. package/dist/esm/dev/AccountOpener.js +1 -1
  19. package/dist/esm/dev/withdrawalUtils.js +1 -1
  20. package/dist/esm/model/charts.js +20 -34
  21. package/dist/esm/model/opportunities.schema.js +14 -12
  22. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  23. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  24. package/dist/esm/sdk/OnchainSDK.js +16 -0
  25. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  26. package/dist/esm/sdk/accounts/intents/utils/pick-token.js +1 -1
  27. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
  28. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  29. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  30. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  31. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  32. package/dist/esm/sdk/base/TokensMeta.js +36 -4
  33. package/dist/esm/sdk/base/index.js +2 -2
  34. package/dist/esm/sdk/base/token-types.js +13 -1
  35. package/dist/esm/sdk/chain/chains.js +10 -12
  36. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  37. package/dist/esm/sdk/chain/index.js +2 -2
  38. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  39. package/dist/esm/sdk/index.js +4 -4
  40. package/dist/esm/sdk/market/MarketSuite.js +11 -5
  41. package/dist/esm/sdk/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  42. package/dist/esm/sdk/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  43. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  44. package/dist/esm/sdk/market/credit/CreditSuite.js +1 -1
  45. package/dist/esm/sdk/market/credit/collateralUtils.js +2 -13
  46. package/dist/esm/sdk/market/credit/index.js +2 -2
  47. package/dist/esm/sdk/market/index.js +2 -2
  48. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  49. package/dist/esm/sdk/market/strategyName.js +4 -6
  50. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  51. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  52. package/dist/esm/sdk/pools/PoolService.js +1 -1
  53. package/dist/esm/sdk/positions/PositionsService.js +1 -1
  54. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  55. package/dist/types/model/charts.d.ts +16 -23
  56. package/dist/types/model/charts.schema.d.ts +24 -52
  57. package/dist/types/model/opportunities.d.ts +18 -4
  58. package/dist/types/model/opportunities.schema.d.ts +101 -38
  59. package/dist/types/model/primitives.d.ts +4 -0
  60. package/dist/types/new-sdk/opportunities/types.d.ts +1 -1
  61. package/dist/types/new-sdk/positions/types.d.ts +1 -1
  62. package/dist/types/sdk/base/TokensMeta.d.ts +31 -2
  63. package/dist/types/sdk/base/index.d.ts +3 -3
  64. package/dist/types/sdk/base/token-types.d.ts +14 -1
  65. package/dist/types/sdk/chain/chains.d.ts +3 -11
  66. package/dist/types/sdk/chain/index.d.ts +2 -2
  67. package/dist/types/sdk/index.d.ts +5 -5
  68. package/dist/types/sdk/market/credit/collateralUtils.d.ts +1 -7
  69. package/dist/types/sdk/market/credit/index.d.ts +2 -2
  70. package/dist/types/sdk/market/index.d.ts +2 -2
  71. package/dist/types/sdk/market/strategyName.d.ts +3 -5
  72. package/package.json +1 -1
@@ -29,11 +29,10 @@ const CHART_RANGES = [
29
29
  **/
30
30
  const POOL_OPPORTUNITY_CHART_METRICS = [
31
31
  "depositApy",
32
- "borrowApy",
32
+ "depositApyAvg7d",
33
33
  "dieselRate",
34
34
  "supplied",
35
- "borrowed",
36
- "availableLiquidity"
35
+ "borrowed"
37
36
  ];
38
37
  /**
39
38
  * Every metric a strategy opportunity can chart.
@@ -42,8 +41,10 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
42
41
  * chart draws; the two USD series are the same prices quoted in dollars.
43
42
  **/
44
43
  const STRATEGY_OPPORTUNITY_CHART_METRICS = [
45
- "netApy",
46
44
  "borrowApy",
45
+ "borrowApyAvg7d",
46
+ "quotaRate",
47
+ "liquidationThreshold",
47
48
  "collateralApy",
48
49
  "tvl",
49
50
  "collateralPrice",
@@ -54,42 +55,32 @@ const STRATEGY_OPPORTUNITY_CHART_METRICS = [
54
55
  * Every metric a pool position can chart.
55
56
  *
56
57
  * Nothing to do with {@link POOL_OPPORTUNITY_CHART_METRICS}: an opportunity charts what the
57
- * pool did, a position charts what one wallet's deposit did in it. `mwr` and
58
- * `twr` are cumulative returns since the position opened money-weighted, so
59
- * sensitive to when deposits and withdrawals landed, and time-weighted, which
60
- * strips that timing out. Both are anchored at inception, so a narrow `range`
61
- * only zooms the visible slice and its first point is rarely zero.
58
+ * pool did, a position charts what one wallet's deposit did in it. `mwr` is the
59
+ * money-weighted return since the position opened, so it is sensitive to when
60
+ * deposits and withdrawals landed. It is anchored at inception, so a narrow
61
+ * `range` only zooms the visible slice and its first point is rarely zero.
62
62
  **/
63
63
  const POOL_POSITION_CHART_METRICS = [
64
- "value",
65
64
  "apy",
66
65
  "pnl",
67
- "mwr",
68
- "twr",
69
- "underlyingPrice"
66
+ "mwr"
70
67
  ];
71
68
  /**
72
69
  * Every metric a strategy position can chart.
73
70
  *
74
- * `twrApy` annualizes `twr` over the position's whole life; the two trailing
75
- * APYs annualize it over a fixed window instead, so they track the current pace
76
- * rather than the lifetime rate and are comparable across positions of
77
- * different ages.
71
+ * `netApy7d` is the trailing seven-day net yield, so it tracks the position's
72
+ * recent pace rather than its lifetime return and is comparable across
73
+ * positions of different ages.
78
74
  **/
79
75
  const STRATEGY_POSITION_CHART_METRICS = [
80
- "totalValueUsd",
81
76
  "totalValueUnderlying",
82
77
  "debt",
83
78
  "healthFactor",
84
- "leverage",
85
79
  "borrowApy",
86
- "underlyingPrice",
80
+ "borrowApyAvg7d",
87
81
  "pnl",
88
82
  "mwr",
89
- "twr",
90
- "twrApy",
91
- "trailingApy7d",
92
- "trailingApy30d"
83
+ "netApy7d"
93
84
  ];
94
85
  /**
95
86
  * Unit of every metric, the one place either side decides it.
@@ -100,31 +91,26 @@ const STRATEGY_POSITION_CHART_METRICS = [
100
91
  **/
101
92
  const CHART_METRIC_UNITS = {
102
93
  depositApy: "bps",
94
+ depositApyAvg7d: "bps",
103
95
  borrowApy: "bps",
104
- netApy: "bps",
96
+ borrowApyAvg7d: "bps",
97
+ quotaRate: "bps",
98
+ liquidationThreshold: "bps",
105
99
  collateralApy: "bps",
106
100
  supplied: "token",
107
101
  borrowed: "token",
108
- availableLiquidity: "token",
109
102
  tvl: "token",
110
103
  dieselRate: "ratio",
111
104
  collateralPrice: "ratio",
112
105
  collateralUsdPrice: "usd",
113
106
  underlyingUsdPrice: "usd",
114
- value: "token",
115
107
  apy: "bps",
116
108
  pnl: "token",
117
109
  mwr: "bps",
118
- twr: "bps",
119
- underlyingPrice: "usd",
120
- totalValueUsd: "usd",
121
110
  totalValueUnderlying: "token",
122
111
  debt: "token",
123
112
  healthFactor: "bps",
124
- leverage: "scalar",
125
- twrApy: "bps",
126
- trailingApy7d: "bps",
127
- trailingApy30d: "bps"
113
+ netApy7d: "bps"
128
114
  };
129
115
  /**
130
116
  * Reason a series could not be produced at all, which is not the same as a
@@ -66,6 +66,17 @@ const opportunityBaseSchema = zod_v4.z.object({
66
66
  sunset: zod_v4.z.boolean()
67
67
  });
68
68
  /**
69
+ * {@link QuotaAsset}
70
+ **/
71
+ const quotaAssetSchema = zod_v4.z.object({
72
+ token: require_model_primitives_schema.tokenSchema,
73
+ quotaRate: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps"),
74
+ limit: require_model_primitives_schema.amountSchema,
75
+ used: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
76
+ allocationShare: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps"),
77
+ allocatedDebt: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount")
78
+ });
79
+ /**
69
80
  * {@link PoolOpportunity}
70
81
  **/
71
82
  const poolOpportunitySchema = zod_v4.z.object({
@@ -76,7 +87,8 @@ const poolOpportunitySchema = zod_v4.z.object({
76
87
  availableLiquidity: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
77
88
  utilization: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps"),
78
89
  supplyApy: apyBreakdownSchema,
79
- supplyApyAvg7D: require_model_compare_schema.offchainOnly(apyBreakdownSchema).optional()
90
+ supplyApyAvg7D: require_model_compare_schema.offchainOnly(apyBreakdownSchema).optional(),
91
+ quotaAssets: zod_v4.z.array(quotaAssetSchema)
80
92
  });
81
93
  /**
82
94
  * {@link StrategyOpportunity}
@@ -170,15 +182,6 @@ const rateCurveSchema = zod_v4.z.object({
170
182
  borrowingLimitUtilization: require_model_primitives_schema.bpsSchema.nullable()
171
183
  });
172
184
  /**
173
- * {@link QuotaAsset}
174
- **/
175
- const quotaAssetSchema = zod_v4.z.object({
176
- token: require_model_primitives_schema.tokenSchema,
177
- quotaRate: require_model_primitives_schema.bpsSchema,
178
- limit: require_model_primitives_schema.amountSchema,
179
- used: require_model_primitives_schema.amountSchema
180
- });
181
- /**
182
185
  * {@link PriceFeedData}. Recursive: a composite feed lists the feeds it reads.
183
186
  **/
184
187
  const priceFeedDataSchema = zod_v4.z.object({
@@ -204,8 +207,7 @@ const priceFeedSummarySchema = zod_v4.z.object({
204
207
  **/
205
208
  const poolOpportunityDetailSchema = zod_v4.z.object({
206
209
  ...poolOpportunitySchema.shape,
207
- rateCurve: rateCurveSchema,
208
- quotaAssets: zod_v4.z.array(quotaAssetSchema)
210
+ rateCurve: rateCurveSchema
209
211
  });
210
212
  /**
211
213
  * {@link StrategyOpportunityDetail}
@@ -229,6 +229,21 @@ var OnchainSDK = class extends require_sdk_base_ChainContractsRegister.ChainCont
229
229
  ...this.#withdrawalCompressor ? [this.#withdrawalCompressor.getLoadWithdrawableAssetsMulticall(force)] : [],
230
230
  this.tokensMeta.getLoadTokenDataMulticall()
231
231
  ], { blockNumber: this.currentBlock });
232
+ this.#renameRedemptionPhantoms();
233
+ }
234
+ /**
235
+ * Rewrites redemption phantom display symbols from the withdrawal
236
+ * compressor's source/target mapping. No-op when the compressor is missing
237
+ * or its assets cache has not been loaded.
238
+ **/
239
+ #renameRedemptionPhantoms() {
240
+ const compressor = this.#withdrawalCompressor;
241
+ if (!compressor?.state) return;
242
+ this.tokensMeta.renameRedemptionPhantoms(compressor.getWithdrawableAssets().map((a) => ({
243
+ phantom: a.withdrawalPhantomToken,
244
+ source: a.token,
245
+ target: a.underlying
246
+ })));
232
247
  }
233
248
  /**
234
249
  * Restores SDK state from a previously serialised {@link GearboxState}
@@ -257,6 +272,7 @@ var OnchainSDK = class extends require_sdk_base_ChainContractsRegister.ChainCont
257
272
  this.#rwa.setState(state.rwa);
258
273
  if (state.withdrawals) this.#withdrawalCompressor?.hydrate(state.withdrawals);
259
274
  if (state.tokens) this.tokensMeta.hydrate(state.tokens);
275
+ this.#renameRedemptionPhantoms();
260
276
  for (const [name, plugin] of require_sdk_utils_mappers.TypedObjectUtils.entries(this.plugins)) {
261
277
  const pluginState = state.plugins[name];
262
278
  if (plugin.hydrate && pluginState) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sdk_market_credit_collateralUtils = require("../../../market/credit/collateralUtils.js");
2
+ const require_sdk_base_token_types = require("../../../base/token-types.js");
3
3
  const require_sdk_accounts_intents_utils_common = require("./common.js");
4
4
  const require_sdk_accounts_intents_utils_convert_amount = require("./convert-amount.js");
5
5
  //#region src/sdk/accounts/intents/utils/pick-token.ts
@@ -16,7 +16,7 @@ const PHANTOM_TOKEN_PREFIX = "PHANTOM_TOKEN::";
16
16
  function isPhantomToken(sdk, token) {
17
17
  return !!sdk.tokensMeta.get(token)?.contractType?.startsWith(PHANTOM_TOKEN_PREFIX);
18
18
  }
19
- const REDEMPTION_PHANTOM_TOKEN_TYPES = new Set(require_sdk_market_credit_collateralUtils.NON_STRATEGY_PHANTOM_TOKEN_TYPES);
19
+ const REDEMPTION_PHANTOM_TOKEN_TYPES = new Set(require_sdk_base_token_types.NON_STRATEGY_PHANTOM_TOKEN_TYPES);
20
20
  /**
21
21
  * Whether `token` is the phantom of a redemption in flight, rather than one of
22
22
  * the phantoms a position is simply held in (Convex, Infrared, staking
@@ -41,10 +41,21 @@ var TokensMeta = class extends require_sdk_utils_AddressMap.AddressMap {
41
41
  ...existing,
42
42
  ...v
43
43
  };
44
+ if (v) {
45
+ const pretty = this.#prettyName(address);
46
+ if (pretty) v = {
47
+ ...v,
48
+ symbol: pretty
49
+ };
50
+ }
44
51
  super.upsert(address, v);
45
52
  }
46
53
  /**
47
- * Returns the symbol string for a token.
54
+ * Returns the display symbol for a token.
55
+ *
56
+ * This is not always the on-chain ERC-20 `symbol()`: curated pretty names
57
+ * and redemption phantom tokens (`"source -> target"`) replace it.
58
+ *
48
59
  * @param token - Token address.
49
60
  * @throws If the token is not in the registry.
50
61
  */
@@ -139,11 +150,32 @@ var TokensMeta = class extends require_sdk_utils_AddressMap.AddressMap {
139
150
  }
140
151
  return meta.asset;
141
152
  }
153
+ /**
154
+ * Rewrites display symbols of redemption phantom tokens to
155
+ * `"${source} -> ${target}"`.
156
+ *
157
+ * @param renames - Phantom / source / target address triples.
158
+ **/
159
+ renameRedemptionPhantoms(renames) {
160
+ for (const { phantom, source, target } of renames) {
161
+ const meta = this.get(phantom);
162
+ if (!meta || !this.has(source) || !this.has(target)) continue;
163
+ this.upsert(phantom, {
164
+ ...meta,
165
+ symbol: `${this.symbol(source)} -> ${this.symbol(target)}`
166
+ });
167
+ }
168
+ }
142
169
  get #networkType() {
143
170
  const { chain } = this.#client;
144
171
  if ("network" in chain) return chain.network;
145
172
  throw new Error(`chain ${chain.id} is not a Gearbox SDK chain`);
146
173
  }
174
+ #prettyName(token) {
175
+ const { chain } = this.#client;
176
+ if (!("network" in chain)) return;
177
+ return chain.tokenPrettyNames?.get(token);
178
+ }
147
179
  formatBN(arg0, arg1, arg2) {
148
180
  const token = typeof arg0 === "object" ? arg0.token : arg0;
149
181
  const amount = typeof arg0 === "object" ? arg0.balance : arg1;
@@ -14,6 +14,7 @@ exports.Construct = require_sdk_base_Construct.Construct;
14
14
  exports.ContractParseError = require_sdk_base_BaseContract.ContractParseError;
15
15
  exports.MissingSerializedParamsError = require_sdk_base_errors.MissingSerializedParamsError;
16
16
  exports.MultichainConstruct = require_sdk_base_MultichainConstruct.MultichainConstruct;
17
+ exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = require_sdk_base_token_types.NON_STRATEGY_PHANTOM_TOKEN_TYPES;
17
18
  exports.PHANTOM_TOKEN_CONTRACT_TYPES = require_sdk_base_token_types.PHANTOM_TOKEN_CONTRACT_TYPES;
18
19
  exports.RWA_ON_DEMAND_LP_MONOPOLIZED = require_sdk_base_token_types.RWA_ON_DEMAND_LP_MONOPOLIZED;
19
20
  exports.RWA_UNDERLYING_DEFAULT = require_sdk_base_token_types.RWA_UNDERLYING_DEFAULT;
@@ -13,7 +13,20 @@ const PHANTOM_TOKEN_CONTRACT_TYPES = [
13
13
  const RWA_UNDERLYING_DEFAULT = "RWA_UNDERLYING::DEFAULT";
14
14
  const RWA_UNDERLYING_ON_DEMAND = "RWA_UNDERLYING::ON_DEMAND";
15
15
  const RWA_ON_DEMAND_LP_MONOPOLIZED = "ON_DEMAND_LP::MONOPOLIZED";
16
+ /**
17
+ * Withdrawal and redemption phantom tokens that can never be acquired as a
18
+ * strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
19
+ * rewards) can.
20
+ */
21
+ const NON_STRATEGY_PHANTOM_TOKEN_TYPES = [
22
+ "PHANTOM_TOKEN::INFINIFI_UNWIND",
23
+ "PHANTOM_TOKEN::MELLOW_WITHDRAWAL",
24
+ "PHANTOM_TOKEN::MIDAS_REDEMPTION",
25
+ "PHANTOM_TOKEN::SECURITIZE_RD",
26
+ "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
27
+ ];
16
28
  //#endregion
29
+ exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = NON_STRATEGY_PHANTOM_TOKEN_TYPES;
17
30
  exports.PHANTOM_TOKEN_CONTRACT_TYPES = PHANTOM_TOKEN_CONTRACT_TYPES;
18
31
  exports.RWA_ON_DEMAND_LP_MONOPOLIZED = RWA_ON_DEMAND_LP_MONOPOLIZED;
19
32
  exports.RWA_UNDERLYING_DEFAULT = RWA_UNDERLYING_DEFAULT;
@@ -107,7 +107,15 @@ const chains = {
107
107
  "0xb46edf298989F0F106EDD80E4ae8f59a13531dB4",
108
108
  "0xd98e31C67c7C21f233C37c9AC9Ae656dcb0d5d25"
109
109
  ]),
110
- sunsetStrategies: new require_sdk_utils_AddressSet.AddressSet(["0x9fF97B167Dd442bd5f277098bf1154C5807D3566", "0x187C5022002d45107dB72B0b59E72111f69Bd513"]),
110
+ sunsetStrategies: new require_sdk_utils_AddressSet.AddressSet([
111
+ "0x1840056a2bdbe949e017a3716e3fdd4a0d327bf0",
112
+ "0x187C5022002d45107dB72B0b59E72111f69Bd513",
113
+ "0x9fF97B167Dd442bd5f277098bf1154C5807D3566",
114
+ "0xa4c644f3180d10cd3b2121d455a2a88e1bda2928",
115
+ "0xb79d6544839d169869476589d2e54014a074317b",
116
+ "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
117
+ "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7"
118
+ ]),
111
119
  isPublic: true,
112
120
  wellKnownToken: {
113
121
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
@@ -543,16 +551,6 @@ function getLegacyStrategyTarget(creditManager, network) {
543
551
  function getAccountTargetCollateral(creditAccount, network) {
544
552
  return getChain(network).accountTargetCollaterals?.get(creditAccount);
545
553
  }
546
- /**
547
- * Curated display name of a token, or `undefined` when the token has none and
548
- * its ticker symbol should be used instead.
549
- *
550
- * @param token - Token address.
551
- * @param network - Chain id or {@link NetworkType} label.
552
- **/
553
- function getTokenPrettyName(token, network) {
554
- return getChain(network).tokenPrettyNames?.get(token);
555
- }
556
554
  //#endregion
557
555
  exports.NetworkType = NetworkType;
558
556
  exports.SUPPORTED_NETWORKS = SUPPORTED_NETWORKS;
@@ -564,7 +562,6 @@ exports.getChain = getChain;
564
562
  exports.getCuratorName = getCuratorName;
565
563
  exports.getLegacyStrategyTarget = getLegacyStrategyTarget;
566
564
  exports.getNetworkType = getNetworkType;
567
- exports.getTokenPrettyName = getTokenPrettyName;
568
565
  exports.isPublicNetwork = isPublicNetwork;
569
566
  exports.isRWAToken = isRWAToken;
570
567
  exports.isSunsetPool = isSunsetPool;
@@ -12,7 +12,6 @@ exports.getChain = require_sdk_chain_chains.getChain;
12
12
  exports.getCuratorName = require_sdk_chain_chains.getCuratorName;
13
13
  exports.getLegacyStrategyTarget = require_sdk_chain_chains.getLegacyStrategyTarget;
14
14
  exports.getNetworkType = require_sdk_chain_chains.getNetworkType;
15
- exports.getTokenPrettyName = require_sdk_chain_chains.getTokenPrettyName;
16
15
  exports.isPublicNetwork = require_sdk_chain_chains.isPublicNetwork;
17
16
  exports.isRWAToken = require_sdk_chain_chains.isRWAToken;
18
17
  exports.isSunsetPool = require_sdk_chain_chains.isSunsetPool;
@@ -371,7 +371,7 @@ exports.MultichainOpportunitiesService = require_sdk_opportunities_MultichainOpp
371
371
  exports.MultichainPositionsService = require_sdk_positions_MultichainPositionsService.MultichainPositionsService;
372
372
  exports.MultichainSDK = require_sdk_MultichainSDK.MultichainSDK;
373
373
  exports.NATIVE_ADDRESS = require_sdk_constants_addresses.NATIVE_ADDRESS;
374
- exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = require_sdk_market_credit_collateralUtils.NON_STRATEGY_PHANTOM_TOKEN_TYPES;
374
+ exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = require_sdk_base_token_types.NON_STRATEGY_PHANTOM_TOKEN_TYPES;
375
375
  exports.NOT_DEPLOYED = require_sdk_constants_addresses.NOT_DEPLOYED;
376
376
  exports.NO_VERSION = require_sdk_constants_address_provider.NO_VERSION;
377
377
  exports.NetworkType = require_sdk_chain_chains.NetworkType;
@@ -537,7 +537,6 @@ exports.getLegacyStrategyTarget = require_sdk_chain_chains.getLegacyStrategyTarg
537
537
  exports.getNetworkType = require_sdk_chain_chains.getNetworkType;
538
538
  exports.getRawPriceUpdates = require_sdk_market_pricefeeds_getRawPriceUpdates.getRawPriceUpdates;
539
539
  exports.getSimulateWithPriceUpdatesError = require_sdk_utils_viem_simulateWithPriceUpdates.getSimulateWithPriceUpdatesError;
540
- exports.getTokenPrettyName = require_sdk_chain_chains.getTokenPrettyName;
541
540
  exports.getWithdrawalCompressorAddress = require_sdk_accounts_withdrawal_compressor_addresses.getWithdrawalCompressorAddress;
542
541
  exports.halfRAY = require_sdk_constants_math.halfRAY;
543
542
  exports.hasAdapterDeployParamsAbi = require_sdk_market_adapters_abi_utils.hasAdapterDeployParamsAbi;
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_utils_AddressMap = require("../utils/AddressMap.js");
3
3
  const require_sdk_chain_chains = require("../chain/chains.js");
4
+ const require_sdk_constants_math = require("../constants/math.js");
4
5
  require("../utils/index.js");
5
6
  const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
6
7
  require("../base/index.js");
@@ -165,11 +166,16 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
165
166
  quotaAssets() {
166
167
  const oracle = this.priceOracle;
167
168
  const { underlying } = this;
168
- return this.pool.pqk.quotas.entries().map(([token, quota]) => ({
169
+ const quotas = this.pool.pqk.quotas.entries();
170
+ const sumUsed = quotas.reduce((sum, [, quota]) => sum + quota.totalQuoted, 0n);
171
+ const { totalBorrowed } = this.pool.pool;
172
+ return quotas.map(([token, quota]) => ({
169
173
  token: this.tokensMeta.mustGetToken(token),
170
174
  quotaRate: quota.rate,
171
175
  limit: oracle.toAmount(underlying, quota.limit),
172
- used: oracle.toAmount(underlying, quota.totalQuoted)
176
+ used: oracle.toAmount(underlying, quota.totalQuoted),
177
+ allocationShare: sumUsed === 0n ? 0 : Number(quota.totalQuoted * require_sdk_constants_math.PERCENTAGE_FACTOR / sumUsed),
178
+ allocatedDebt: oracle.toAmount(underlying, sumUsed === 0n ? 0n : totalBorrowed * quota.totalQuoted / sumUsed)
173
179
  }));
174
180
  }
175
181
  /**
@@ -224,7 +230,8 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
224
230
  collateralTokens: this.collateralTokens,
225
231
  paused: pool.isPaused,
226
232
  rwa: this.rwa,
227
- sunset: this.sunset
233
+ sunset: this.sunset,
234
+ quotaAssets: this.quotaAssets()
228
235
  };
229
236
  }
230
237
  /**
@@ -233,8 +240,7 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
233
240
  poolOpportunityDetail() {
234
241
  return {
235
242
  ...this.poolOpportunity(),
236
- rateCurve: this.pool.rateCurve,
237
- quotaAssets: this.quotaAssets()
243
+ rateCurve: this.pool.rateCurve
238
244
  };
239
245
  }
240
246
  /**
@@ -221,7 +221,7 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
221
221
  get strategyName() {
222
222
  const collateral = this.strategyTargetCollateral;
223
223
  if (!collateral) return;
224
- return require_sdk_market_strategyName.strategyName(this.tokensMeta.mustGetToken(collateral), this.market.underlyingToken, this.chainId);
224
+ return require_sdk_market_strategyName.strategyName(this.tokensMeta.mustGetToken(collateral), this.market.underlyingToken);
225
225
  }
226
226
  /**
227
227
  * Describes this suite's leveraged strategy as the shared read model does,
@@ -1,21 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../constants/math.js");
3
3
  require("../../constants/index.js");
4
+ const require_sdk_base_token_types = require("../../base/token-types.js");
4
5
  let viem = require("viem");
5
6
  //#region src/sdk/market/credit/collateralUtils.ts
6
- /**
7
- * Withdrawal and redemption phantom tokens that can never be acquired as a
8
- * strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
9
- * rewards) can.
10
- */
11
- const NON_STRATEGY_PHANTOM_TOKEN_TYPES = [
12
- "PHANTOM_TOKEN::INFINIFI_UNWIND",
13
- "PHANTOM_TOKEN::MELLOW_WITHDRAWAL",
14
- "PHANTOM_TOKEN::MIDAS_REDEMPTION",
15
- "PHANTOM_TOKEN::SECURITIZE_RD",
16
- "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
17
- ];
18
- const NON_STRATEGY_PHANTOM_TOKEN_TYPE_SET = new Set(NON_STRATEGY_PHANTOM_TOKEN_TYPES);
7
+ const NON_STRATEGY_PHANTOM_TOKEN_TYPE_SET = new Set(require_sdk_base_token_types.NON_STRATEGY_PHANTOM_TOKEN_TYPES);
19
8
  const RWA_UNDERLYING_PREFIX = "RWA_UNDERLYING::";
20
9
  /**
21
10
  * Whether a collateral token can be the target of a leveraged strategy.
@@ -91,7 +80,6 @@ function dominantCollateral(account, market) {
91
80
  return dominant;
92
81
  }
93
82
  //#endregion
94
- exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = NON_STRATEGY_PHANTOM_TOKEN_TYPES;
95
83
  exports.dominantCollateral = dominantCollateral;
96
84
  exports.isStrategyCollateral = isStrategyCollateral;
97
85
  exports.pickStrategyTargetCollateral = pickStrategyTargetCollateral;
@@ -12,7 +12,6 @@ exports.CreditFacadeV310BaseContract = require_sdk_market_credit_CreditFacadeV31
12
12
  exports.CreditFacadeV310Contract = require_sdk_market_credit_CreditFacadeV310Contract.CreditFacadeV310Contract;
13
13
  exports.CreditManagerV310Contract = require_sdk_market_credit_CreditManagerV310Contract.CreditManagerV310Contract;
14
14
  exports.CreditSuite = require_sdk_market_credit_CreditSuite.CreditSuite;
15
- exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = require_sdk_market_credit_collateralUtils.NON_STRATEGY_PHANTOM_TOKEN_TYPES;
16
15
  exports.creditFacadeV310Abi = require_sdk_market_credit_CreditFacadeV310BaseContract.creditFacadeV310Abi;
17
16
  exports.dominantCollateral = require_sdk_market_credit_collateralUtils.dominantCollateral;
18
17
  exports.expectedBalanceDeltas = require_sdk_market_credit_expectedBalanceDeltas.expectedBalanceDeltas;
@@ -201,7 +201,6 @@ exports.MidasGatewayAdapterContract = require_sdk_market_adapters_contracts_Mida
201
201
  exports.MidasIssuanceVaultAdapterContract = require_sdk_market_adapters_contracts_MidasIssuanceVaultAdapterContract.MidasIssuanceVaultAdapterContract;
202
202
  exports.MidasLiquidatorContract = require_sdk_market_rwa_midas_MidasLiquidatorContract.MidasLiquidatorContract;
203
203
  exports.MidasRedemptionVaultAdapterContract = require_sdk_market_adapters_contracts_MidasRedemptionVaultAdapterContract.MidasRedemptionVaultAdapterContract;
204
- exports.NON_STRATEGY_PHANTOM_TOKEN_TYPES = require_sdk_market_credit_collateralUtils.NON_STRATEGY_PHANTOM_TOKEN_TYPES;
205
204
  exports.PARTIAL_LIQUIDATION_BUFFER_BPS = require_sdk_market_math.PARTIAL_LIQUIDATION_BUFFER_BPS;
206
205
  exports.PHANTOM_TOKEN_MIDAS_REDEMPTION = require_sdk_market_rwa_midas_constants.PHANTOM_TOKEN_MIDAS_REDEMPTION;
207
206
  exports.PHANTOM_TOKEN_SECURITIZE_REDEMPTION = require_sdk_market_rwa_securitize_constants.PHANTOM_TOKEN_SECURITIZE_REDEMPTION;
@@ -1,19 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sdk_chain_chains = require("../chain/chains.js");
3
2
  //#region src/sdk/market/strategyName.ts
4
3
  /**
5
4
  * Display name of a leveraged strategy: the target collateral over the
6
5
  * borrowed underlying, e.g. `"wstETH / WETH"`.
7
6
  *
8
- * A curated pretty name from {@link getTokenPrettyName} wins over the target's
9
- * ticker when one is configured.
7
+ * Uses each token's display {@link Token.symbol}, which may already be a
8
+ * curated pretty name or a `"source -> target"` redemption rewrite.
10
9
  *
11
10
  * @param target - Collateral the position is built around.
12
11
  * @param underlying - Token the position borrows.
13
- * @param network - Chain id or network type label of the market.
14
12
  **/
15
- function strategyName(target, underlying, network) {
16
- return `${require_sdk_chain_chains.getTokenPrettyName(target.address, network) ?? target.symbol} / ${underlying.symbol}`;
13
+ function strategyName(target, underlying) {
14
+ return `${target.symbol} / ${underlying.symbol}`;
17
15
  }
18
16
  //#endregion
19
17
  exports.strategyName = strategyName;
@@ -177,7 +177,7 @@ var PositionsService = class extends require_sdk_base_SDKConstruct.SDKConstruct
177
177
  chainId: this.sdk.chainId,
178
178
  creditManager: ca.creditManager,
179
179
  creditAccount: ca.creditAccount,
180
- name: target ? require_sdk_market_strategyName.strategyName(this.sdk.tokensMeta.mustGetToken(target), token, this.sdk.chainId) : token.symbol,
180
+ name: target ? require_sdk_market_strategyName.strategyName(this.sdk.tokensMeta.mustGetToken(target), token) : token.symbol,
181
181
  targetCollateral: target ? this.sdk.tokensMeta.mustGetToken(target) : null,
182
182
  leverage: require_sdk_market_math.calcPositionLeverage(totalValue, totalDebtValue),
183
183
  borrowApy: require_sdk_market_math.calcBorrowApy(pool.baseInterestRate, suite.creditManager.feeInterest),
@@ -1,9 +1,9 @@
1
- import { ierc20Abi } from "../abi/iERC20.js";
2
1
  import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
3
2
  import { AddressMap } from "../sdk/utils/AddressMap.js";
4
3
  import { AddressSet } from "../sdk/utils/AddressSet.js";
5
4
  import { AssetsMap } from "../sdk/utils/AssetsMap.js";
6
5
  import { childLogger } from "../sdk/utils/childLogger.js";
6
+ import { ierc20Abi } from "../abi/iERC20.js";
7
7
  import "../sdk/constants/addresses.js";
8
8
  import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
9
9
  import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
@@ -1,6 +1,6 @@
1
- import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
2
1
  import { getNetworkType } from "../sdk/chain/chains.js";
3
2
  import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
3
+ import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
4
4
  import "../sdk/index.js";
5
5
  import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
6
6
  import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
@@ -28,11 +28,10 @@ const CHART_RANGES = [
28
28
  **/
29
29
  const POOL_OPPORTUNITY_CHART_METRICS = [
30
30
  "depositApy",
31
- "borrowApy",
31
+ "depositApyAvg7d",
32
32
  "dieselRate",
33
33
  "supplied",
34
- "borrowed",
35
- "availableLiquidity"
34
+ "borrowed"
36
35
  ];
37
36
  /**
38
37
  * Every metric a strategy opportunity can chart.
@@ -41,8 +40,10 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
41
40
  * chart draws; the two USD series are the same prices quoted in dollars.
42
41
  **/
43
42
  const STRATEGY_OPPORTUNITY_CHART_METRICS = [
44
- "netApy",
45
43
  "borrowApy",
44
+ "borrowApyAvg7d",
45
+ "quotaRate",
46
+ "liquidationThreshold",
46
47
  "collateralApy",
47
48
  "tvl",
48
49
  "collateralPrice",
@@ -53,42 +54,32 @@ const STRATEGY_OPPORTUNITY_CHART_METRICS = [
53
54
  * Every metric a pool position can chart.
54
55
  *
55
56
  * Nothing to do with {@link POOL_OPPORTUNITY_CHART_METRICS}: an opportunity charts what the
56
- * pool did, a position charts what one wallet's deposit did in it. `mwr` and
57
- * `twr` are cumulative returns since the position opened money-weighted, so
58
- * sensitive to when deposits and withdrawals landed, and time-weighted, which
59
- * strips that timing out. Both are anchored at inception, so a narrow `range`
60
- * only zooms the visible slice and its first point is rarely zero.
57
+ * pool did, a position charts what one wallet's deposit did in it. `mwr` is the
58
+ * money-weighted return since the position opened, so it is sensitive to when
59
+ * deposits and withdrawals landed. It is anchored at inception, so a narrow
60
+ * `range` only zooms the visible slice and its first point is rarely zero.
61
61
  **/
62
62
  const POOL_POSITION_CHART_METRICS = [
63
- "value",
64
63
  "apy",
65
64
  "pnl",
66
- "mwr",
67
- "twr",
68
- "underlyingPrice"
65
+ "mwr"
69
66
  ];
70
67
  /**
71
68
  * Every metric a strategy position can chart.
72
69
  *
73
- * `twrApy` annualizes `twr` over the position's whole life; the two trailing
74
- * APYs annualize it over a fixed window instead, so they track the current pace
75
- * rather than the lifetime rate and are comparable across positions of
76
- * different ages.
70
+ * `netApy7d` is the trailing seven-day net yield, so it tracks the position's
71
+ * recent pace rather than its lifetime return and is comparable across
72
+ * positions of different ages.
77
73
  **/
78
74
  const STRATEGY_POSITION_CHART_METRICS = [
79
- "totalValueUsd",
80
75
  "totalValueUnderlying",
81
76
  "debt",
82
77
  "healthFactor",
83
- "leverage",
84
78
  "borrowApy",
85
- "underlyingPrice",
79
+ "borrowApyAvg7d",
86
80
  "pnl",
87
81
  "mwr",
88
- "twr",
89
- "twrApy",
90
- "trailingApy7d",
91
- "trailingApy30d"
82
+ "netApy7d"
92
83
  ];
93
84
  /**
94
85
  * Unit of every metric, the one place either side decides it.
@@ -99,31 +90,26 @@ const STRATEGY_POSITION_CHART_METRICS = [
99
90
  **/
100
91
  const CHART_METRIC_UNITS = {
101
92
  depositApy: "bps",
93
+ depositApyAvg7d: "bps",
102
94
  borrowApy: "bps",
103
- netApy: "bps",
95
+ borrowApyAvg7d: "bps",
96
+ quotaRate: "bps",
97
+ liquidationThreshold: "bps",
104
98
  collateralApy: "bps",
105
99
  supplied: "token",
106
100
  borrowed: "token",
107
- availableLiquidity: "token",
108
101
  tvl: "token",
109
102
  dieselRate: "ratio",
110
103
  collateralPrice: "ratio",
111
104
  collateralUsdPrice: "usd",
112
105
  underlyingUsdPrice: "usd",
113
- value: "token",
114
106
  apy: "bps",
115
107
  pnl: "token",
116
108
  mwr: "bps",
117
- twr: "bps",
118
- underlyingPrice: "usd",
119
- totalValueUsd: "usd",
120
109
  totalValueUnderlying: "token",
121
110
  debt: "token",
122
111
  healthFactor: "bps",
123
- leverage: "scalar",
124
- twrApy: "bps",
125
- trailingApy7d: "bps",
126
- trailingApy30d: "bps"
112
+ netApy7d: "bps"
127
113
  };
128
114
  /**
129
115
  * Reason a series could not be produced at all, which is not the same as a