@morpho-dev/router 0.7.1 → 0.7.2

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.
@@ -98,6 +98,61 @@ const MetaMorpho = parseAbi([
98
98
  //#region src/core/Abi/MetaMorphoFactory.ts
99
99
  const MetaMorphoFactory = parseAbi(["event CreateMetaMorpho(address indexed metaMorpho,address indexed caller,address initialOwner,uint256 initialTimelock,address indexed asset,string name,string symbol,bytes32 salt)", "function isMetaMorpho(address) view returns (bool)"]);
100
100
 
101
+ //#endregion
102
+ //#region src/core/Abi/MorphoV2.ts
103
+ const MorphoV2 = parseAbi([
104
+ "constructor()",
105
+ "function collateralOf(bytes32 id, address user, address collateralToken) view returns (uint256)",
106
+ "function consume(bytes32 group, uint256 amount)",
107
+ "function consumed(address user, bytes32 group) view returns (uint256)",
108
+ "function debtOf(bytes32 id, address user) view returns (uint256)",
109
+ "function defaultFees(address loanToken, uint256 index) view returns (uint16)",
110
+ "function feeSetter() view returns (address)",
111
+ "function fees(bytes32 id) view returns (uint16[6])",
112
+ "function flashLoan(address token, uint256 assets, address callback, bytes data)",
113
+ "function isHealthy((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, bytes32 id, address borrower) view returns (bool)",
114
+ "function liquidate((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, (uint256 collateralIndex, uint256 repaid, uint256 seized)[] seizures, address borrower, bytes data) returns ((uint256 collateralIndex, uint256 repaid, uint256 seized)[])",
115
+ "function multicall(bytes[] calls)",
116
+ "function obligationCreated(bytes32 id) view returns (bool)",
117
+ "function obligationState(bytes32 id) view returns (uint128 totalUnits, uint128 totalShares, uint256 withdrawable, bool created)",
118
+ "function owner() view returns (address)",
119
+ "function repay((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, uint256 obligationUnits, address onBehalf)",
120
+ "function session(address user) view returns (bytes32)",
121
+ "function setDefaultTradingFee(address loanToken, uint256 index, uint256 newTradingFee)",
122
+ "function setFeeSetter(address newFeeSetter)",
123
+ "function setObligationTradingFee(bytes32 id, uint256 index, uint256 newTradingFee)",
124
+ "function setOwner(address newOwner)",
125
+ "function setTradingFeeRecipient(address recipient)",
126
+ "function sharesOf(bytes32 id, address user) view returns (uint256)",
127
+ "function shuffleSession()",
128
+ "function supplyCollateral((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, address collateral, uint256 assets, address onBehalf)",
129
+ "function take(uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, address taker, ((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, bool buy, address maker, uint256 assets, uint256 obligationUnits, uint256 obligationShares, uint256 start, uint256 expiry, uint256 tick, bytes32 group, bytes32 session, address callback, bytes callbackData) offer, (uint8 v, bytes32 r, bytes32 s) sig, bytes32 root, bytes32[] proof, address takerCallback, bytes takerCallbackData) returns (uint256, uint256, uint256, uint256)",
130
+ "function totalShares(bytes32 id) view returns (uint256)",
131
+ "function totalUnits(bytes32 id) view returns (uint256)",
132
+ "function touchObligation((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation) returns (bytes32)",
133
+ "function tradingFee(bytes32 id, uint256 timeToMaturity) view returns (uint256)",
134
+ "function tradingFeeRecipient() view returns (address)",
135
+ "function withdraw((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, uint256 obligationUnits, uint256 shares, address onBehalf) returns (uint256, uint256)",
136
+ "function withdrawCollateral((address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation, address collateral, uint256 assets, address onBehalf)",
137
+ "function withdrawable(bytes32 id) view returns (uint256)",
138
+ "event Constructor(address indexed owner)",
139
+ "event Consume(address indexed user, bytes32 indexed group, uint256 amount)",
140
+ "event FlashLoan(address indexed caller, address indexed token, uint256 assets)",
141
+ "event Liquidate(address indexed caller, bytes32 indexed id, (uint256 collateralIndex, uint256 repaid, uint256 seized)[] seizures, address indexed borrower, uint256 totalRepaid, uint256 badDebt)",
142
+ "event ObligationCreated(bytes32 indexed id, (address loanToken, (address token, uint256 lltv, address oracle)[] collaterals, uint256 maturity) obligation)",
143
+ "event Repay(address indexed caller, bytes32 indexed id, uint256 obligationUnits, address indexed onBehalf)",
144
+ "event SetDefaultTradingFee(address indexed loanToken, uint256 indexed index, uint256 newTradingFee)",
145
+ "event SetFeeSetter(address indexed feeSetter)",
146
+ "event SetObligationTradingFee(bytes32 indexed id, uint256 indexed index, uint256 newTradingFee)",
147
+ "event SetOwner(address indexed owner)",
148
+ "event SetTradingFeeRecipient(address indexed recipient)",
149
+ "event ShuffleSession(address indexed user, bytes32 session)",
150
+ "event SupplyCollateral(address caller, bytes32 indexed id, address indexed collateral, uint256 assets, address indexed onBehalf)",
151
+ "event Take(address caller, bytes32 indexed id, address indexed maker, address indexed taker, bool offerIsBuy, uint256 buyerAssets, uint256 sellerAssets, uint256 obligationUnits, uint256 obligationShares, bool buyerIsLender, bool sellerIsBorrower, bytes32 group, uint256 consumed)",
152
+ "event Withdraw(address indexed caller, bytes32 indexed id, uint256 obligationUnits, uint256 shares, address indexed onBehalf)",
153
+ "event WithdrawCollateral(address caller, bytes32 indexed id, address indexed collateral, uint256 assets, address indexed onBehalf)"
154
+ ]);
155
+
101
156
  //#endregion
102
157
  //#region src/core/Abi/index.ts
103
158
  var Abi_exports = /* @__PURE__ */ __exportAll({
@@ -105,6 +160,7 @@ var Abi_exports = /* @__PURE__ */ __exportAll({
105
160
  MetaMorpho: () => MetaMorpho,
106
161
  MetaMorphoFactory: () => MetaMorphoFactory,
107
162
  Morpho: () => Morpho,
163
+ MorphoV2: () => MorphoV2,
108
164
  Oracle: () => Oracle
109
165
  });
110
166
  const Oracle = [{
@@ -510,8 +566,8 @@ const chains$1 = {
510
566
  name: "ethereum-virtual-testnet",
511
567
  custom: {
512
568
  morpho: {
513
- address: "0x11a002d45db720ed47a80d2f3489cba5b833eaf5",
514
- blockCreated: 0
569
+ address: "0x634b095371e4e45feed94c1a45c37798e173ea50",
570
+ blockCreated: 23226700
515
571
  },
516
572
  morphoBlue: {
517
573
  address: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
@@ -2734,6 +2790,16 @@ const BrandTypeId = Symbol.for("mempool/Brand");
2734
2790
  //#endregion
2735
2791
  //#region src/api/Schema/OfferResponse.ts
2736
2792
  var OfferResponse_exports = /* @__PURE__ */ __exportAll({ from: () => from$2 });
2793
+ function normalizeChainId(chainId) {
2794
+ const parsedChainId = Number(chainId);
2795
+ if (!Number.isInteger(parsedChainId) || parsedChainId <= 0) throw new Error(`Invalid chain id: ${String(chainId)}`);
2796
+ return parsedChainId;
2797
+ }
2798
+ function normalizeBlockNumber(blockNumber) {
2799
+ const parsedBlockNumber = Number(blockNumber);
2800
+ if (!Number.isInteger(parsedBlockNumber) || parsedBlockNumber < 0) throw new Error(`Invalid block number: ${String(blockNumber)}`);
2801
+ return parsedBlockNumber;
2802
+ }
2737
2803
  /**
2738
2804
  * Creates an `OfferResponse` matching the Solidity Offer struct layout.
2739
2805
  * @constructor
@@ -2741,6 +2807,8 @@ var OfferResponse_exports = /* @__PURE__ */ __exportAll({ from: () => from$2 });
2741
2807
  * @returns The created `OfferResponse`. {@link OfferResponse}
2742
2808
  */
2743
2809
  function from$2(input) {
2810
+ const chainId = normalizeChainId(input.chainId);
2811
+ const blockNumber = normalizeBlockNumber(input.blockNumber);
2744
2812
  const base = {
2745
2813
  offer: {
2746
2814
  obligation: {
@@ -2767,15 +2835,15 @@ function from$2(input) {
2767
2835
  },
2768
2836
  offer_hash: input.hash,
2769
2837
  obligation_id: id({
2770
- chainId: input.chainId,
2838
+ chainId,
2771
2839
  loanToken: input.loanToken,
2772
2840
  collaterals: [...input.collaterals],
2773
2841
  maturity: input.maturity
2774
2842
  }),
2775
- chain_id: input.chainId,
2843
+ chain_id: chainId,
2776
2844
  consumed: input.consumed.toString(),
2777
2845
  takeable: input.takeable.toString(),
2778
- block_number: input.blockNumber
2846
+ block_number: blockNumber
2779
2847
  };
2780
2848
  if (!input.proof || !input.root || !input.signature) return {
2781
2849
  ...base,