@1delta/margin-fetcher 0.0.277 → 0.0.278

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/index.js CHANGED
@@ -38403,6 +38403,8 @@ var LST_REGISTRY = {
38403
38403
  symbol: "SolvBTC",
38404
38404
  brand: "Solv",
38405
38405
  decimals: 18,
38406
+ underlyingDecimals: 8,
38407
+ // WBTC underlying is 8-dec; share is 18-dec
38406
38408
  reader: "offChain",
38407
38409
  isErc4626: false,
38408
38410
  isRebasing: false,
@@ -38421,6 +38423,8 @@ var LST_REGISTRY = {
38421
38423
  symbol: "xSolvBTC",
38422
38424
  brand: "Solv",
38423
38425
  decimals: 18,
38426
+ underlyingDecimals: 8,
38427
+ // WBTC underlying is 8-dec; share is 18-dec
38424
38428
  reader: "offChain",
38425
38429
  isErc4626: false,
38426
38430
  isRebasing: false,
@@ -38439,6 +38443,8 @@ var LST_REGISTRY = {
38439
38443
  symbol: "BTC+",
38440
38444
  brand: "Solv",
38441
38445
  decimals: 18,
38446
+ underlyingDecimals: 8,
38447
+ // WBTC underlying is 8-dec; share is 18-dec
38442
38448
  reader: "offChain",
38443
38449
  isErc4626: false,
38444
38450
  isRebasing: false,
@@ -39067,6 +39073,8 @@ var LST_REGISTRY = {
39067
39073
  symbol: "pumpBTC",
39068
39074
  brand: "PumpBTC",
39069
39075
  decimals: 8,
39076
+ underlyingDecimals: 18,
39077
+ // SolvBTC.CORE underlying is 18-dec; share is 8-dec
39070
39078
  reader: "offChain",
39071
39079
  isErc4626: false,
39072
39080
  isRebasing: false,
@@ -39181,6 +39189,7 @@ var Erc4626PreviewRedeemAbi = [
39181
39189
 
39182
39190
  // src/vaults/lst/readers/shared.ts
39183
39191
  var ONE_E187 = 10n ** 18n;
39192
+ var rescaleDecimals = (v, fromDec, toDec) => toDec >= fromDec ? v * 10n ** BigInt(toDec - fromDec) : v / 10n ** BigInt(fromDec - toDec);
39184
39193
  var MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
39185
39194
  var Multicall3BalanceAbi = [
39186
39195
  {
@@ -39763,15 +39772,23 @@ var readerMantleMEth = (entry) => {
39763
39772
  };
39764
39773
 
39765
39774
  // src/vaults/lst/readers/offChain.ts
39766
- var readerOffChain = (entry) => ({
39767
- calls: [{ address: entry.address, name: "totalSupply", params: [] }],
39768
- abis: [TotalSupplyAbi],
39769
- parse: ([supply]) => {
39770
- const totalSupply = toBigInt10(supply);
39771
- if (totalSupply === void 0) return void 0;
39772
- return { totalAssets: totalSupply, totalSupply, exchangeRate: ONE_E187 };
39773
- }
39774
- });
39775
+ var readerOffChain = (entry) => {
39776
+ const shareDec = entry.decimals;
39777
+ const underlyingDec = entry.underlyingDecimals ?? entry.decimals;
39778
+ return {
39779
+ calls: [{ address: entry.address, name: "totalSupply", params: [] }],
39780
+ abis: [TotalSupplyAbi],
39781
+ parse: ([supply]) => {
39782
+ const totalSupply = toBigInt10(supply);
39783
+ if (totalSupply === void 0) return void 0;
39784
+ return {
39785
+ totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
39786
+ totalSupply,
39787
+ exchangeRate: ONE_E187
39788
+ };
39789
+ }
39790
+ };
39791
+ };
39775
39792
 
39776
39793
  // src/vaults/lst/abis/renzo.ts
39777
39794
  var RenzoRestakeManagerAbi = [
@@ -40172,6 +40189,8 @@ var VedaAccountantGetRateAbi = [
40172
40189
  // src/vaults/lst/readers/veda.ts
40173
40190
  var readerVedaAccountant = (entry) => {
40174
40191
  const accountant = entry.readerExtras?.vedaAccountant;
40192
+ const shareDec = entry.decimals;
40193
+ const underlyingDec = entry.underlyingDecimals ?? entry.decimals;
40175
40194
  if (!accountant) {
40176
40195
  return {
40177
40196
  calls: [{ address: entry.address, name: "totalSupply", params: [] }],
@@ -40179,11 +40198,15 @@ var readerVedaAccountant = (entry) => {
40179
40198
  parse: ([supply]) => {
40180
40199
  const totalSupply = toBigInt10(supply);
40181
40200
  if (totalSupply === void 0) return void 0;
40182
- return { totalAssets: totalSupply, totalSupply, exchangeRate: ONE_E187 };
40201
+ return {
40202
+ totalAssets: rescaleDecimals(totalSupply, shareDec, underlyingDec),
40203
+ totalSupply,
40204
+ exchangeRate: ONE_E187
40205
+ };
40183
40206
  }
40184
40207
  };
40185
40208
  }
40186
- const scale = 10n ** BigInt(18 - entry.decimals);
40209
+ const scale = 10n ** BigInt(18 - underlyingDec);
40187
40210
  return {
40188
40211
  calls: [
40189
40212
  { address: entry.address, name: "totalSupply", params: [] },
@@ -40196,7 +40219,11 @@ var readerVedaAccountant = (entry) => {
40196
40219
  if (totalSupply === void 0 || rawRate === void 0) return void 0;
40197
40220
  const exchangeRate = rawRate * scale;
40198
40221
  return {
40199
- totalAssets: totalSupply * exchangeRate / ONE_E187,
40222
+ totalAssets: rescaleDecimals(
40223
+ totalSupply * exchangeRate / ONE_E187,
40224
+ shareDec,
40225
+ underlyingDec
40226
+ ),
40200
40227
  totalSupply,
40201
40228
  exchangeRate
40202
40229
  };
@@ -40546,11 +40573,14 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
40546
40573
  const supplyRate = aprByAddress[addressLc] ?? 0;
40547
40574
  const rewardsRate = 0;
40548
40575
  const depositRate = supplyRate + rewardsRate;
40549
- const decimalsFactor = 10 ** entry.decimals;
40550
- const totalAssetsFormatted = Number(state.totalAssets) / decimalsFactor;
40576
+ const shareDec = entry.decimals;
40577
+ const underlyingDec = entry.underlyingDecimals ?? entry.decimals;
40578
+ const shareUnit = 10n ** BigInt(shareDec);
40579
+ const underlyingUnit = 10n ** BigInt(underlyingDec);
40580
+ const totalAssetsFormatted = Number(state.totalAssets) / 10 ** underlyingDec;
40551
40581
  const totalAssetsUsd = priceUsd !== void 0 ? totalAssetsFormatted * priceUsd : 0;
40552
- const convertToAssets = state.exchangeRate;
40553
- const convertToShares = state.exchangeRate > 0n ? ONE_E188 * ONE_E188 / state.exchangeRate : 0n;
40582
+ const convertToAssets = state.exchangeRate * underlyingUnit / ONE_E188;
40583
+ const convertToShares = state.exchangeRate > 0n ? ONE_E188 * shareUnit / state.exchangeRate : 0n;
40554
40584
  let liquidityRaw;
40555
40585
  if (state.liquidity !== void 0) {
40556
40586
  liquidityRaw = state.liquidity;
@@ -40558,7 +40588,7 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
40558
40588
  const idle = idleByAddress.get(addressLc);
40559
40589
  liquidityRaw = idle !== void 0 ? idle > state.totalAssets ? state.totalAssets : idle : 0n;
40560
40590
  }
40561
- const liquidityFormatted = Number(liquidityRaw) / decimalsFactor;
40591
+ const liquidityFormatted = Number(liquidityRaw) / 10 ** underlyingDec;
40562
40592
  const liquidityUsd = priceUsd !== void 0 ? liquidityFormatted * priceUsd : 0;
40563
40593
  const displayName = composeVaultDisplayName(
40564
40594
  entry.brand,
@@ -40578,6 +40608,7 @@ var fetchLstShareTokens = async (chainId, multicallRetry, prices = {}, tokenList
40578
40608
  brand: entry.brand,
40579
40609
  curatorName: entry.brand,
40580
40610
  decimals: entry.decimals,
40611
+ assetDecimals: underlyingDec,
40581
40612
  totalAssets: state.totalAssets.toString(),
40582
40613
  totalSupply: state.totalSupply.toString(),
40583
40614
  convertToShares: convertToShares.toString(),
@@ -44024,6 +44055,7 @@ var fetchSavingsVaults = async (chainId, multicallRetry, prices = {}, tokenList
44024
44055
  brand: entry.brand,
44025
44056
  curatorName: entry.brand,
44026
44057
  decimals: entry.decimals,
44058
+ assetDecimals: underlyingDec,
44027
44059
  totalAssets: state.totalAssets.toString(),
44028
44060
  totalSupply: state.totalSupply.toString(),
44029
44061
  convertToShares: convertToShares.toString(),