@morpho-dev/router 0.0.15 → 0.0.17

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.
@@ -1,4 +1,4 @@
1
- import { Errors, Offer, Format, Mempool } from '@morpho-dev/mempool';
1
+ import { Errors, Offer, Format, LLTV, Maturity, Mempool } from '@morpho-dev/mempool';
2
2
  export * from '@morpho-dev/mempool';
3
3
  import { base, mainnet, optimism, foundry, abstractTestnet, acala, ancient8, ancient8Sepolia, anvil, apexTestnet, arbitrum, arbitrumGoerli, arbitrumNova, assetChainTestnet, astar, astarZkEVM, astarZkyoto, arbitrumSepolia, areonNetwork, areonNetworkTestnet, artelaTestnet, atletaOlympia, aurora, auroraTestnet, auroria, avalanche, avalancheFuji, b3Sepolia, b3, bahamut, baseGoerli, baseSepolia, beam, beamTestnet, bearNetworkChainMainnet, bearNetworkChainTestnet, berachainTestnet, berachainTestnetbArtio, bevmMainnet, bitkub, bitkubTestnet, bitTorrent, bitTorrentTestnet, blast, blastSepolia, bob, bobSepolia, boba, bobaSepolia, botanixTestnet, bronos, bronosTestnet, bsc, bscTestnet, bscGreenfield, btr, btrTestnet, bxn, bxnTestnet, canto, celo, celoAlfajores, chiliz, chips, classic, confluxESpace, confluxESpaceTestnet, coreDao, crab, cronos, cronoszkEVM, cronoszkEVMTestnet, cronosTestnet, crossbell, curtis, cyber, cyberTestnet, darwinia, dchain, dchainTestnet, defichainEvm, defichainEvmTestnet, degen, dfk, dodochainTestnet, dogechain, dreyerxMainnet, dreyerxTestnet, edgeless, edgelessTestnet, edgeware, edgewareTestnet, eon, eos, eosTestnet, etherlink, etherlinkTestnet, evmos, evmosTestnet, ekta, ektaTestnet, fantom, fantomSonicTestnet, fantomTestnet, fibo, filecoin, filecoinCalibration, filecoinHyperspace, flare, flareTestnet, flowPreviewnet, flowMainnet, flowTestnet, fluence, fluenceStage, fluenceTestnet, forma, fraxtal, fraxtalTestnet, funkiMainnet, funkiSepolia, fuse, fuseSparknet, iotex, iotexTestnet, jbc, jbcTestnet, karura, gobi, goerli, gnosis, gnosisChiado, gravity, ham, hardhat, harmonyOne, hashkeyTestnet, haqqMainnet, haqqTestedge2, hedera, hederaTestnet, hederaPreviewnet, holesky, immutableZkEvm, immutableZkEvmTestnet, inEVM, iota, iotaTestnet, kakarotSepolia, kava, kavaTestnet, kcc, klaytn, klaytnBaobab, kaia, kairos, koi, kroma, kromaSepolia, l3x, l3xTestnet, lightlinkPegasus, lightlinkPhoenix, linea, lineaGoerli, lineaSepolia, lineaTestnet, lisk, liskSepolia, localhost, lukso, luksoTestnet, lycan, lyra, mandala, manta, mantaSepoliaTestnet, mantaTestnet, mantle, mantleSepoliaTestnet, mantleTestnet, merlin, metachain, metachainIstanbul, metalL2, meter, meterTestnet, metis, metisGoerli, mev, mevTestnet, mintSepoliaTestnet, mode, modeTestnet, moonbaseAlpha, moonbeam, moonbeamDev, moonriver, morphHolesky, morphSepolia, nautilus, neonDevnet, neonMainnet, nexi, nexilix, oasys, oasisTestnet, okc, optimismGoerli, optimismSepolia, opBNB, opBNBTestnet, oortMainnetDev, otimDevnet, palm, palmTestnet, playfiAlbireo, pgn, pgnTestnet, phoenix, plinga, plumeTestnet, polygon, polygonAmoy, polygonMumbai, polygonZkEvm, polygonZkEvmCardona, polygonZkEvmTestnet, pulsechain, pulsechainV4, qMainnet, qTestnet, real, redbellyTestnet, redstone, reyaNetwork, rollux, rolluxTestnet, ronin, root, rootPorcini, rootstock, rootstockTestnet, rss3, rss3Sepolia, saigon, sapphire, sapphireTestnet, satoshiVM, satoshiVMTestnet, scroll, scrollSepolia, sei, seiDevnet, seiTestnet, sepolia, shapeSepolia, shimmer, shimmerTestnet, skaleBlockBrawlers, skaleCalypso, skaleCalypsoTestnet, skaleCryptoBlades, skaleCryptoColosseum, skaleEuropa, skaleEuropaTestnet, skaleExorde, skaleHumanProtocol, skaleNebula, skaleNebulaTestnet, skaleRazor, skaleTitan, skaleTitanTestnet, sketchpad, soneiumMinato, songbird, songbirdTestnet, sophonTestnet, spicy, shardeumSphinx, shibarium, shibariumTestnet, storyTestnet, stratis, syscoin, syscoinTestnet, taraxa, taiko, taikoHekla, taikoJolnir, taikoKatla, taikoTestnetSepolia, taraxaTestnet, telcoinTestnet, telos, telosTestnet, tenet, thaiChain, thunderTestnet, tron, unreal, vechain, wanchain, wanchainTestnet, wemix, wemixTestnet, xLayerTestnet, x1Testnet, xLayer, xai, xaiTestnet, xdc, xdcTestnet, xrSepolia, yooldoVerse, yooldoVerseTestnet, zetachain, zetachainAthensTestnet, zhejiang, zilliqa, zilliqaTestnet, zkFair, zkFairTestnet, zkLinkNova, zkLinkNovaSepoliaTestnet, zksync, zksyncInMemoryNode, zksyncLocalNode, zksyncSepoliaTestnet, zora, zoraSepolia, zoraTestnet, zircuitTestnet } from 'viem/chains';
4
4
  import { z } from 'zod/v4';
@@ -8186,8 +8186,10 @@ var chains = {
8186
8186
  var apiSchema_exports = {};
8187
8187
  __export(apiSchema_exports, {
8188
8188
  OpenApi: () => OpenApi,
8189
+ fromResponse: () => fromResponse,
8189
8190
  parse: () => parse,
8190
- safeParse: () => safeParse
8191
+ safeParse: () => safeParse,
8192
+ toResponse: () => toResponse
8191
8193
  });
8192
8194
 
8193
8195
  // src/RouterOffer.ts
@@ -8832,6 +8834,26 @@ var OpenApi = createDocument({
8832
8834
  paths
8833
8835
  });
8834
8836
 
8837
+ // src/core/apiSchema/utils.ts
8838
+ function toResponse(routerOffer) {
8839
+ const { consumed: consumed2, status, metadata, ...offer } = routerOffer;
8840
+ return {
8841
+ offer,
8842
+ consumed: consumed2,
8843
+ status,
8844
+ metadata
8845
+ };
8846
+ }
8847
+ function fromResponse(offerResponse) {
8848
+ const { offer, consumed: consumed2, status, metadata } = offerResponse;
8849
+ return {
8850
+ ...offer,
8851
+ consumed: consumed2,
8852
+ status,
8853
+ metadata
8854
+ };
8855
+ }
8856
+
8835
8857
  // src/core/index.ts
8836
8858
  var core_exports = {};
8837
8859
  __export(core_exports, {
@@ -8945,9 +8967,10 @@ async function get(config, parameters) {
8945
8967
  url.searchParams.set("limit", parameters.limit.toString());
8946
8968
  }
8947
8969
  const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
8970
+ const routerOffers = offers2.map(Format.fromSnakeCase).map(fromResponse);
8948
8971
  return {
8949
8972
  cursor: returnedCursor,
8950
- offers: offers2.map(fromSnakeCase)
8973
+ offers: routerOffers.map(from).map(toResponse)
8951
8974
  };
8952
8975
  }
8953
8976
  async function match(config, parameters) {
@@ -8986,9 +9009,10 @@ async function match(config, parameters) {
8986
9009
  url.searchParams.set("limit", parameters.limit.toString());
8987
9010
  }
8988
9011
  const { cursor: returnedCursor, data: offers2 } = await getApi(config, url);
9012
+ const routerOffers = offers2.map(Format.fromSnakeCase).map(fromResponse);
8989
9013
  return {
8990
9014
  cursor: returnedCursor,
8991
- offers: offers2.map(fromSnakeCase)
9015
+ offers: routerOffers.map(from).map(toResponse)
8992
9016
  };
8993
9017
  }
8994
9018
  async function getApi(config, url) {
@@ -9545,7 +9569,7 @@ function create2(config) {
9545
9569
  offer.collaterals.push({
9546
9570
  asset: row.collateralAsset,
9547
9571
  oracle: row.collateralOracle,
9548
- lltv: row.collateralLltv
9572
+ lltv: LLTV.from(row.collateralLltv)
9549
9573
  });
9550
9574
  }
9551
9575
  offerMap.set(row.hash, offer);
@@ -9579,7 +9603,7 @@ function create2(config) {
9579
9603
  offering: offerData.offering,
9580
9604
  assets: offerData.assets,
9581
9605
  rate: offerData.rate,
9582
- maturity: offerData.maturity,
9606
+ maturity: Maturity.from(offerData.maturity),
9583
9607
  expiry: offerData.expiry,
9584
9608
  start: offerData.start,
9585
9609
  nonce: offerData.nonce,
@@ -9589,7 +9613,7 @@ function create2(config) {
9589
9613
  collaterals: offerData.collaterals.map((c) => ({
9590
9614
  asset: c.asset,
9591
9615
  oracle: c.oracle,
9592
- lltv: c.lltv
9616
+ lltv: LLTV.from(c.lltv)
9593
9617
  })).sort((a, b) => a.asset.toLowerCase().localeCompare(b.asset.toLowerCase())),
9594
9618
  callback: {
9595
9619
  address: offerData.callbackAddress,
@@ -9784,7 +9808,7 @@ function create2(config) {
9784
9808
  entry.collaterals.push({
9785
9809
  asset: r.collateralAsset,
9786
9810
  oracle: r.collateralOracle,
9787
- lltv: r.collateralLltv
9811
+ lltv: LLTV.from(r.collateralLltv)
9788
9812
  });
9789
9813
  }
9790
9814
  offerMap.set(r.hash, entry);
@@ -9798,7 +9822,7 @@ function create2(config) {
9798
9822
  offering: base2.offering,
9799
9823
  assets: base2.assets,
9800
9824
  rate: base2.rate,
9801
- maturity: base2.maturity,
9825
+ maturity: Maturity.from(base2.maturity),
9802
9826
  expiry: base2.expiry,
9803
9827
  start: base2.start,
9804
9828
  nonce: base2.nonce,
@@ -9912,7 +9936,9 @@ async function serve(parameters) {
9912
9936
  }
9913
9937
  });
9914
9938
  return Mempool.success(c, {
9915
- data: offers2.offers.map((offer) => Format.stringifyBigint(Offer.toSnakeCase(offer))),
9939
+ data: offers2.offers.map(
9940
+ (offer) => Format.stringifyBigint(Format.toSnakeCase(toResponse(offer)))
9941
+ ),
9916
9942
  cursor: offers2.nextCursor ?? null
9917
9943
  });
9918
9944
  } catch (err) {
@@ -9938,7 +9964,9 @@ async function serve(parameters) {
9938
9964
  limit: params.limit
9939
9965
  });
9940
9966
  return Mempool.success(c, {
9941
- data: offers2.offers.map((offer) => Format.stringifyBigint(Offer.toSnakeCase(offer))),
9967
+ data: offers2.offers.map(
9968
+ (offer) => Format.stringifyBigint(Format.toSnakeCase(toResponse(offer)))
9969
+ ),
9942
9970
  cursor: offers2.nextCursor ?? null
9943
9971
  });
9944
9972
  } catch (err) {