@morpho-org/calldata-verifier 0.3.0 → 0.3.1-next.0

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/README.md CHANGED
@@ -19,7 +19,7 @@ Use [`@morpho-org/evm-simulation`](../evm-simulation) for execution-dependent ch
19
19
  - Whether the caller-supplied Vault `asset` matches the actual `vault.asset()`. Read `vault.asset()` at the pinned block and compare it with `asset`. For deposits and standard withdrawals or redemptions, typed-input simulation can establish an exact match if you pass a canonical ERC-20 address as the token override (`assetPaid` for deposits, `assetReceived` for exits). Simulation also accepts `ethAddress` for a vault whose asset is the chain's wrapped-native token, so use the pinned read if your source might supply a native alias. Force withdrawals, force redemptions, and in-kind redemptions do not support typed inputs; use the pinned read for those. Quote-only limits can accept a token override without comparing it with `vault.asset()`.
20
20
  - Whether existing onchain allowances suffice and whether a call succeeds or reverts.
21
21
  - Blue ERC-20 repay by shares or for all debt: before signing, compare the decoded `maxRepayAssets`, which is `args[3]` of the verified `blueBundlesV1RepayAndWithdrawCollateral` call, against an independently chosen funding cap. Apply this check whenever that call's `value` is zero, including for requests that allowed native funding, because such requests don't have to use it. Simulating net spend does not bound the upfront pull because unused funds can be refunded.
22
- - Blue public-allocator reallocations: the verifier checks zero penalty, the destination market and loan token, positive amounts, and route structure and uniqueness. Simulation checks whether a reallocation is needed and whether its source and amount are appropriate.
22
+ - Blue public-allocator reallocations: the verifier checks each leg in calldata order for zero penalty, the destination market and loan token, a positive amount, and nonzero vault and destination adapter addresses. Market-funded legs require a nonzero source adapter and may revisit a route. Idle-funded legs require a zero source adapter and must be unique per vault and destination adapter. Adapter eligibility, whether a reallocation is needed, and whether its source and amount are appropriate require onchain checks.
23
23
  - Blue embedded Morpho authorizations: the verifier checks signature structure. The bundle supplies the transaction sender and its own address as the authorizer and authorized spender; signature validity, nonce and expiry are execution checks.
24
24
  - Midnight full direct repays, and units-target lends, market repays and `midnight.take_lend` takes: compare the decoded `maxBuyerAssets` against an independently chosen upfront funding cap before signing. For full direct repays, this applies to ERC-20, native, and auto funding: when ETH is sent, the bundle wraps it to the signer's balance and then pulls the encoded `maxBuyerAssets` from that wrapped-native balance. `max_native_assets` caps only the ETH sent, not the token pull. For the units-target cases, you can instead set a `max_assets` guard to enforce the upfront funding cap. Simulation's `assetsPaid` measures net spend after refunds, not the upfront pull.
25
25
  - Midnight buy bundles for lend, market repay, and `midnight.take_lend`: the verifier does not bound the encoded `maxContinuousFee`. Compare it with an independently chosen ceiling. To check the market's actual fee against that ceiling, read Midnight's `continuousFee(marketId)` at the simulation block or use a simulation `assertBefore` view call.
package/lib/cjs/blue.js CHANGED
@@ -61,28 +61,27 @@ function requireMarket(params, { chainId, selector, call, field = "market", }) {
61
61
  }
62
62
  function requireReallocations(entries, { params, call }) {
63
63
  const expected = marketId(params);
64
- const used = new Set();
64
+ const idleDestinations = new Set();
65
65
  for (const entry of entries) {
66
- const source = marketId(entry.sourceMarketParams);
67
66
  const destination = `${entry.vault}:${entry.adapter}`;
68
- const route = entry.fromIdle
69
- ? destination
70
- : `${destination}:${entry.sourceAdapter}:${source}`;
71
67
  if (entry.penalty !== 0n) {
72
68
  throw new errors_js_1.CalldataFeeError("reallocations.penalty", call.id);
73
69
  }
74
70
  if (entry.assets === 0n ||
75
- used.has(route) ||
76
71
  (0, checks_js_1.sameAddress)(entry.vault, viem_1.zeroAddress) ||
77
72
  (0, checks_js_1.sameAddress)(entry.adapter, viem_1.zeroAddress) ||
78
73
  marketId(entry.marketParams) !== expected ||
79
74
  !(0, checks_js_1.sameAddress)(entry.sourceMarketParams.loanToken, params.loanToken) ||
80
75
  (entry.fromIdle
81
- ? !(0, checks_js_1.sameAddress)(entry.sourceAdapter, viem_1.zeroAddress)
82
- : (0, checks_js_1.sameAddress)(entry.sourceAdapter, viem_1.zeroAddress) || source === expected)) {
76
+ ? !(0, checks_js_1.sameAddress)(entry.sourceAdapter, viem_1.zeroAddress) ||
77
+ idleDestinations.has(destination)
78
+ : (0, checks_js_1.sameAddress)(entry.sourceAdapter, viem_1.zeroAddress) ||
79
+ marketId(entry.sourceMarketParams) === expected)) {
83
80
  throw new errors_js_1.CalldataCallError("reallocations", call.id);
84
81
  }
85
- used.add(route);
82
+ if (entry.fromIdle) {
83
+ idleDestinations.add(destination);
84
+ }
86
85
  }
87
86
  }
88
87
  function requirePositionAmount(amount, { assets, shares, call, }) {
@@ -1,2 +1,2 @@
1
1
  /** Installed @morpho-org/calldata-verifier package version. */
2
- export declare const version = "0.3.0";
2
+ export declare const version = "0.3.1-next.0";
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = void 0;
5
5
  /** Installed @morpho-org/calldata-verifier package version. */
6
- exports.version = "0.3.0";
6
+ exports.version = "0.3.1-next.0";
package/lib/esm/blue.js CHANGED
@@ -58,28 +58,27 @@ function requireMarket(params, { chainId, selector, call, field = "market", }) {
58
58
  }
59
59
  function requireReallocations(entries, { params, call }) {
60
60
  const expected = marketId(params);
61
- const used = new Set();
61
+ const idleDestinations = new Set();
62
62
  for (const entry of entries) {
63
- const source = marketId(entry.sourceMarketParams);
64
63
  const destination = `${entry.vault}:${entry.adapter}`;
65
- const route = entry.fromIdle
66
- ? destination
67
- : `${destination}:${entry.sourceAdapter}:${source}`;
68
64
  if (entry.penalty !== 0n) {
69
65
  throw new CalldataFeeError("reallocations.penalty", call.id);
70
66
  }
71
67
  if (entry.assets === 0n ||
72
- used.has(route) ||
73
68
  sameAddress(entry.vault, zeroAddress) ||
74
69
  sameAddress(entry.adapter, zeroAddress) ||
75
70
  marketId(entry.marketParams) !== expected ||
76
71
  !sameAddress(entry.sourceMarketParams.loanToken, params.loanToken) ||
77
72
  (entry.fromIdle
78
- ? !sameAddress(entry.sourceAdapter, zeroAddress)
79
- : sameAddress(entry.sourceAdapter, zeroAddress) || source === expected)) {
73
+ ? !sameAddress(entry.sourceAdapter, zeroAddress) ||
74
+ idleDestinations.has(destination)
75
+ : sameAddress(entry.sourceAdapter, zeroAddress) ||
76
+ marketId(entry.sourceMarketParams) === expected)) {
80
77
  throw new CalldataCallError("reallocations", call.id);
81
78
  }
82
- used.add(route);
79
+ if (entry.fromIdle) {
80
+ idleDestinations.add(destination);
81
+ }
83
82
  }
84
83
  }
85
84
  function requirePositionAmount(amount, { assets, shares, call, }) {
@@ -1,2 +1,2 @@
1
1
  /** Installed @morpho-org/calldata-verifier package version. */
2
- export declare const version = "0.3.0";
2
+ export declare const version = "0.3.1-next.0";
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/generate-package-versions.ts. Do not edit.
2
2
  /** Installed @morpho-org/calldata-verifier package version. */
3
- export const version = "0.3.0";
3
+ export const version = "0.3.1-next.0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/calldata-verifier",
3
3
  "description": "Verify Morpho action calldata locally before signing.",
4
- "version": "0.3.0",
4
+ "version": "0.3.1-next.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,10 +27,10 @@
27
27
  "build:esm": "tsc --build tsconfig.build.esm.json && echo '{\"type\":\"module\"}' > lib/esm/package.json"
28
28
  },
29
29
  "dependencies": {
30
- "@morpho-org/blue-sdk-viem": "^7.6.0",
31
- "@morpho-org/midnight-sdk": "^2.10.0",
32
- "@morpho-org/morpho-sdk": "^10.4.0",
33
- "@morpho-org/morpho-ts": "^4.5.1",
30
+ "@morpho-org/blue-sdk-viem": "^7.7.0-next.0",
31
+ "@morpho-org/midnight-sdk": "^2.11.0-next.0",
32
+ "@morpho-org/morpho-sdk": "^10.5.0-next.0",
33
+ "@morpho-org/morpho-ts": "^4.6.0-next.1",
34
34
  "@noble/curves": "1.9.1",
35
35
  "fflate": "0.8.3"
36
36
  },