@1delta/margin-fetcher 5.0.108 → 5.0.109

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
@@ -55662,6 +55662,108 @@ var onycFetcher = {
55662
55662
  }
55663
55663
  };
55664
55664
 
55665
+ // src/yields/intrinsic/fetchers/sanctum.ts
55666
+ var KAMINO_STAKING_YIELDS = "https://api.kamino.finance/staking-yields/tokens";
55667
+ var INF_MINT = "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm";
55668
+ var INF_LLAMA_POOL = "3075a746-bdd1-4aac-bcd5-b035abee2622";
55669
+ var INF_KEY = "Infinity::INF::solana";
55670
+ var INF_EPOCHS = 10;
55671
+ var MAX_PLAUSIBLE_APY = 0.3;
55672
+ function meanEpochApy(rows, n = INF_EPOCHS) {
55673
+ if (!Array.isArray(rows)) return void 0;
55674
+ const ok2 = rows.map((r) => ({ epoch: Number(r?.epoch), apy: Number(r?.apy) })).filter(
55675
+ (r) => Number.isFinite(r.epoch) && Number.isFinite(r.apy) && r.apy > 0 && r.apy < MAX_PLAUSIBLE_APY
55676
+ ).sort((a, b) => b.epoch - a.epoch).slice(0, n);
55677
+ if (ok2.length === 0) return void 0;
55678
+ return ok2.reduce((s, r) => s + r.apy, 0) / ok2.length;
55679
+ }
55680
+ async function kaminoInfApy() {
55681
+ const end = /* @__PURE__ */ new Date();
55682
+ const start = new Date(end.getTime() - 30 * 864e5);
55683
+ const d = (x) => x.toISOString().slice(0, 10);
55684
+ const res = await fetch(
55685
+ `${KAMINO_STAKING_YIELDS}/${INF_MINT}/history?start=${d(start)}&end=${d(end)}`,
55686
+ {
55687
+ headers: { accept: "application/json" },
55688
+ signal: AbortSignal.timeout(8e3)
55689
+ }
55690
+ );
55691
+ if (!res.ok) throw new Error(`Kamino staking-yields HTTP ${res.status}`);
55692
+ return meanEpochApy(await res.json());
55693
+ }
55694
+ var infFetcher = {
55695
+ label: "SANCTUM_INF",
55696
+ fetch: async () => {
55697
+ const apy = await kaminoInfApy().catch((e) => {
55698
+ console.warn(`[sanctum] Kamino INF history unavailable: ${e.message}`);
55699
+ return void 0;
55700
+ });
55701
+ if (apy !== void 0) return { [INF_KEY]: apyToAprPercent(apy * 100) };
55702
+ const llama = await fetchDefiLlamaApy(INF_LLAMA_POOL);
55703
+ if (!(llama > 0) || llama >= MAX_PLAUSIBLE_APY * 100) return {};
55704
+ return { [INF_KEY]: apyToAprPercent(llama) };
55705
+ }
55706
+ };
55707
+
55708
+ // src/yields/intrinsic/fetchers/exponentTranching.ts
55709
+ var EXPONENT_APP_API = "https://app.exponent.finance/api/tranching-markets";
55710
+ var EXPONENT_SENIOR_GROUPS = {
55711
+ FvQP1fjox2GPSwkEhENuZisz8UeRURLWf7GYF9n2mURD: "Exponent Senior eHYUSD::srEHYUSD::solana",
55712
+ F17tzaQaFf1x3tC5gQFVvXAF2hcgq1qX6Mc9595zo3FD: "Exponent Senior AUTO::srAUTO::solana",
55713
+ "9J8VvigcjFTkN3jhZH2ieTi2hdGVBVpEXbcA1JDo7QpA": "Exponent Senior ONyc::srONyc::solana",
55714
+ "4tnzVYkaXKwMt7p86wpDzeTyzHSZhj2BvdGwBem7peH5": "Exponent Senior nOPAL::srnOPAL::solana"
55715
+ };
55716
+ var EXPONENT_BASE_GROUPS = {
55717
+ HnnGv3HrSqjRpgdFmx7vQGjntNEoex1SU4e9Lxcxuihz: "Earn Hylo USD::eHYUSD::solana"
55718
+ };
55719
+ var MAX_PLAUSIBLE_APY2 = 0.5;
55720
+ function seniorApy(stats) {
55721
+ const s = stats;
55722
+ for (const k of ["seniorApy30d", "seniorApy7d", "seniorApy1d"]) {
55723
+ const v = Number(s?.[k] ?? NaN);
55724
+ if (s?.[k] != null && Number.isFinite(v) && v > -MAX_PLAUSIBLE_APY2 && v < MAX_PLAUSIBLE_APY2)
55725
+ return v;
55726
+ }
55727
+ return void 0;
55728
+ }
55729
+ var getJson3 = async (url) => {
55730
+ const res = await fetch(url, {
55731
+ headers: { accept: "application/json" },
55732
+ signal: AbortSignal.timeout(8e3)
55733
+ });
55734
+ if (!res.ok) throw new Error(`Exponent HTTP ${res.status} for ${url}`);
55735
+ return res.json();
55736
+ };
55737
+ var exponentSeniorFetcher = {
55738
+ label: "EXPONENT_SENIOR",
55739
+ fetch: async () => {
55740
+ const markets = await getJson3(EXPONENT_APP_API);
55741
+ const wanted = (Array.isArray(markets) ? markets : []).filter(
55742
+ (m) => m.address && m.mintLpSenior && EXPONENT_SENIOR_GROUPS[m.mintLpSenior]
55743
+ );
55744
+ const out = {};
55745
+ for (const m of Array.isArray(markets) ? markets : []) {
55746
+ const group = m.mintBase ? EXPONENT_BASE_GROUPS[m.mintBase] : void 0;
55747
+ const apy = Number(m.underlyingApy7d);
55748
+ if (group && m.underlyingApy7d != null && apy > 0 && apy < MAX_PLAUSIBLE_APY2)
55749
+ out[group] = apyToAprPercent(apy * 100);
55750
+ }
55751
+ await Promise.all(
55752
+ wanted.map(async (m) => {
55753
+ const apy = await getJson3(`${EXPONENT_APP_API}/${m.address}/stats`).then(seniorApy).catch((e) => {
55754
+ console.warn(`[exponent] ${m.address} stats: ${e.message}`);
55755
+ return void 0;
55756
+ });
55757
+ if (apy !== void 0)
55758
+ out[EXPONENT_SENIOR_GROUPS[m.mintLpSenior]] = apyToAprPercent(
55759
+ apy * 100
55760
+ );
55761
+ })
55762
+ );
55763
+ return out;
55764
+ }
55765
+ };
55766
+
55665
55767
  // src/yields/intrinsic/fetchers/superreturn.ts
55666
55768
  var SSUPERUSD_URL = "https://www.superreturn.ai/api/trpc/cmc.getUSDCPrice,rewardBackend.getYield,rewardBackend.getTvlChange?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%221%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%222%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D";
55667
55769
  var ssuperusd = "SuperReturn sSuperUSD::SSUPERUSD";
@@ -55777,7 +55879,7 @@ var getGmxApiHost = (chainId) => GMX_API_HOSTS[chainId];
55777
55879
 
55778
55880
  // src/vaults/gmx/api.ts
55779
55881
  var GMX_DEFAULT_APY_PERIOD = "1d";
55780
- var getJson3 = async (url) => {
55882
+ var getJson4 = async (url) => {
55781
55883
  const res = await fetch(url, {
55782
55884
  method: "GET",
55783
55885
  headers: { Accept: "application/json" }
@@ -55789,12 +55891,12 @@ var fetchGmxRawData = async (chainId, period, apiUrlOverride) => {
55789
55891
  const host = apiUrlOverride ?? getGmxApiHost(chainId);
55790
55892
  if (!host) throw new Error(`GMX not supported on chain ${chainId}`);
55791
55893
  const [apy, marketsRes, glvsRes, tokensRes] = await Promise.all([
55792
- getJson3(`${host}/apy?period=${encodeURIComponent(period)}`),
55793
- getJson3(`${host}/markets`).catch(() => ({
55894
+ getJson4(`${host}/apy?period=${encodeURIComponent(period)}`),
55895
+ getJson4(`${host}/markets`).catch(() => ({
55794
55896
  markets: []
55795
55897
  })),
55796
- getJson3(`${host}/glvs`).catch(() => ({ glvs: [] })),
55797
- getJson3(`${host}/tokens`).catch(() => ({
55898
+ getJson4(`${host}/glvs`).catch(() => ({ glvs: [] })),
55899
+ getJson4(`${host}/tokens`).catch(() => ({
55798
55900
  tokens: []
55799
55901
  }))
55800
55902
  ]);
@@ -56416,6 +56518,13 @@ var LENDING_ONLY_FETCHERS = [
56416
56518
  // ONyc (OnRe reinsurance, Solana): NAV-accruing collateral on Loopscale /
56417
56519
  // Kamino / Jupiter Lend, no vault row.
56418
56520
  onycFetcher,
56521
+ // INF (Sanctum Infinity, Solana): the SOL-value accrual of the multi-LST
56522
+ // pool, collateral on Kamino / Jupiter Lend / Project 0 / Save. Its earn
56523
+ // row lives in margin-fetcher-sol, so it is lending-only here.
56524
+ infFetcher,
56525
+ // Exponent senior tranches (srEHYUSD / srAUTO / srONyc / srnOPAL, Solana):
56526
+ // Loopscale loop collateral, no earn row.
56527
+ exponentSeniorFetcher,
56419
56528
  thbillFetcher,
56420
56529
  // sthusdFetcher / scrvusdFetcher are NOT here (and deliberately not
56421
56530
  // imported): both are vault-wired by their savings rows, so they reach
@@ -65071,7 +65180,7 @@ function rescaleExchangeRate(exchangeRate, shareDecimals) {
65071
65180
  const dec2 = Math.max(0, Math.round(Number(shareDecimals) || 0));
65072
65181
  return (r * 10n ** BigInt(dec2) / 10n ** 18n).toString();
65073
65182
  }
65074
- async function getJson4(url) {
65183
+ async function getJson5(url) {
65075
65184
  const controller = new AbortController();
65076
65185
  const timer = setTimeout(() => controller.abort(), API_TIMEOUT_MS2);
65077
65186
  try {
@@ -65163,7 +65272,7 @@ async function mapWithConcurrency(items, limit, fn) {
65163
65272
  return out;
65164
65273
  }
65165
65274
  async function fetchEulerEarnVaultsFromApi(chainId, prices = {}, tokenList = {}, multicallRetry) {
65166
- const list = await getJson4(
65275
+ const list = await getJson5(
65167
65276
  `${EULER_DATA_API_BASE2}/earn/vaults?chainId=${chainId}&limit=200&visibility=${VISIBILITY_ALL}`
65168
65277
  );
65169
65278
  if (!list) return void 0;
@@ -65180,7 +65289,7 @@ async function fetchEulerEarnVaultsFromApi(chainId, prices = {}, tokenList = {},
65180
65289
  mapWithConcurrency(
65181
65290
  rows,
65182
65291
  DETAIL_CONCURRENCY,
65183
- (row) => getJson4(
65292
+ (row) => getJson5(
65184
65293
  `${EULER_DATA_API_BASE2}/earn/vaults/${chainId}/${row.address}?include=strategies`
65185
65294
  ).then((d) => d?.data)
65186
65295
  ),
@@ -75610,7 +75719,7 @@ function clearPendleMarketsCache() {
75610
75719
  marketsCache = void 0;
75611
75720
  assetsCache = void 0;
75612
75721
  }
75613
- async function getJson5(url, label) {
75722
+ async function getJson6(url, label) {
75614
75723
  const response = await fetch(url, { headers: { Accept: "application/json" } });
75615
75724
  if (!response.ok) {
75616
75725
  throw new Error(
@@ -75631,7 +75740,7 @@ function cache5(slot, build6, store) {
75631
75740
  function fetchPendleApiMarkets() {
75632
75741
  return cache5(
75633
75742
  marketsCache,
75634
- async () => (await getJson5(PENDLE_MARKETS_URL, "markets"))?.markets ?? [],
75743
+ async () => (await getJson6(PENDLE_MARKETS_URL, "markets"))?.markets ?? [],
75635
75744
  (c) => {
75636
75745
  marketsCache = c;
75637
75746
  }
@@ -75642,7 +75751,7 @@ function fetchPendleApiAssets() {
75642
75751
  return cache5(
75643
75752
  assetsCache,
75644
75753
  async () => {
75645
- const json = await getJson5(PENDLE_ASSETS_URL, "assets");
75754
+ const json = await getJson6(PENDLE_ASSETS_URL, "assets");
75646
75755
  const map = /* @__PURE__ */ new Map();
75647
75756
  for (const a of json?.assets ?? []) {
75648
75757
  if (a?.chainId == null || !a?.address) continue;
@@ -84198,7 +84307,13 @@ var SVM_EARN_VAULT_BUILDERS = {
84198
84307
  "savings:Nest": { verbs: ["deposit", "request-withdraw"] },
84199
84308
  // PRIME / AUTO: the vault-stake pool's own stake / redeem, same
84200
84309
  // transaction; wYLDS in (or USDC, minted 1:1 first), wYLDS out
84201
- "savings:Hastra": { verbs: ["deposit", "withdraw"], payAsset: true }
84310
+ "savings:Hastra": { verbs: ["deposit", "withdraw"], payAsset: true },
84311
+ // INF: Sanctum Infinity's own add / remove liquidity against wSOL
84312
+ "savings:Sanctum": {
84313
+ verbs: ["deposit", "withdraw"],
84314
+ nativeDeposit: true,
84315
+ nativeWithdraw: true
84316
+ }
84202
84317
  };
84203
84318
  var UNBUILT_REASONS = {
84204
84319
  exponent: "Exponent PTs are not tradable through this API yet",