@morpho-org/bundler-sdk-viem 3.0.0-next.1 → 3.0.0-next.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.
Files changed (2) hide show
  1. package/lib/actions.js +14 -20
  2. package/package.json +11 -11
package/lib/actions.js CHANGED
@@ -393,13 +393,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
393
393
  }
394
394
  case "Blue_Supply": {
395
395
  const { id, assets = 0n, shares = 0n, onBehalf, slippage = 0n, } = operation.args;
396
- const { params, totalSupplyAssets, totalSupplyShares } = dataBefore.getMarket(id);
397
- const maxSharePrice = (totalSupplyAssets * MathLib.wToRay(MathLib.WAD + slippage)) /
398
- totalSupplyShares;
396
+ const market = dataBefore.getMarket(id);
397
+ const maxSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD + slippage));
399
398
  actions.push({
400
399
  type: "morphoSupply",
401
400
  args: [
402
- params,
401
+ market.params,
403
402
  assets,
404
403
  shares,
405
404
  maxSharePrice,
@@ -411,35 +410,32 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
411
410
  }
412
411
  case "Blue_Withdraw": {
413
412
  const { id, assets = 0n, shares = 0n, receiver, slippage = 0n, } = operation.args;
414
- const { params, totalSupplyAssets, totalSupplyShares } = dataBefore.getMarket(id);
415
- const minSharePrice = (totalSupplyAssets * MathLib.wToRay(MathLib.WAD - slippage)) /
416
- totalSupplyShares;
413
+ const market = dataBefore.getMarket(id);
414
+ const minSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD - slippage));
417
415
  actions.push({
418
416
  type: "morphoWithdraw",
419
- args: [params, assets, shares, minSharePrice, receiver],
417
+ args: [market.params, assets, shares, minSharePrice, receiver],
420
418
  });
421
419
  break;
422
420
  }
423
421
  case "Blue_Borrow": {
424
422
  const { id, assets = 0n, shares = 0n, receiver, slippage = 0n, } = operation.args;
425
- const { params, totalBorrowAssets, totalBorrowShares } = dataBefore.getMarket(id);
426
- const minSharePrice = (totalBorrowAssets * MathLib.wToRay(MathLib.WAD - slippage)) /
427
- totalBorrowShares;
423
+ const market = dataBefore.getMarket(id);
424
+ const minSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD - slippage));
428
425
  actions.push({
429
426
  type: "morphoBorrow",
430
- args: [params, assets, shares, minSharePrice, receiver],
427
+ args: [market.params, assets, shares, minSharePrice, receiver],
431
428
  });
432
429
  break;
433
430
  }
434
431
  case "Blue_Repay": {
435
432
  const { id, assets = 0n, shares = 0n, onBehalf, slippage = 0n, } = operation.args;
436
- const { params, totalBorrowAssets, totalBorrowShares } = dataBefore.getMarket(id);
437
- const maxSharePrice = (totalBorrowAssets * MathLib.wToRay(MathLib.WAD + slippage)) /
438
- totalBorrowShares;
433
+ const market = dataBefore.getMarket(id);
434
+ const maxSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD + slippage));
439
435
  actions.push({
440
436
  type: "morphoRepay",
441
437
  args: [
442
- params,
438
+ market.params,
443
439
  assets,
444
440
  shares,
445
441
  maxSharePrice,
@@ -480,8 +476,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
480
476
  case "MetaMorpho_Deposit": {
481
477
  const { assets = 0n, shares = 0n, owner, slippage = 0n } = operation.args;
482
478
  const vault = dataBefore.getVault(address);
483
- const maxSharePrice = (vault.totalAssets * MathLib.wToRay(MathLib.WAD + slippage)) /
484
- vault.totalSupply;
479
+ const maxSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD + slippage));
485
480
  if (shares === 0n)
486
481
  actions.push({
487
482
  type: "erc4626Deposit",
@@ -497,8 +492,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
497
492
  case "MetaMorpho_Withdraw": {
498
493
  const { assets = 0n, shares = 0n, owner, receiver, slippage = 0n, } = operation.args;
499
494
  const vault = dataBefore.getVault(address);
500
- const minSharePrice = (vault.totalAssets * MathLib.wToRay(MathLib.WAD - slippage)) /
501
- vault.totalSupply;
495
+ const minSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD - slippage));
502
496
  if (assets > 0n)
503
497
  actions.push({
504
498
  type: "erc4626Withdraw",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/bundler-sdk-viem",
3
3
  "description": "Viem-based extension of `@morpho-org/simulation-sdk` that exports utilities to transform simple interactions on Morpho (such as `Blue_Borrow`) and Morpho Vaults (such as `MetaMorpho_Deposit`) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain.",
4
- "version": "3.0.0-next.1",
4
+ "version": "3.0.0-next.2",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -20,10 +20,10 @@
20
20
  ],
21
21
  "peerDependencies": {
22
22
  "viem": "^2.0.0",
23
- "@morpho-org/blue-sdk-viem": "^3.0.0-next.1",
24
- "@morpho-org/simulation-sdk": "^3.0.0-next.1",
25
- "@morpho-org/blue-sdk": "^3.0.0-next.3",
26
- "@morpho-org/morpho-ts": "^2.1.0"
23
+ "@morpho-org/blue-sdk": "^2.3.1",
24
+ "@morpho-org/morpho-ts": "^2.1.0",
25
+ "@morpho-org/simulation-sdk": "^2.1.3",
26
+ "@morpho-org/blue-sdk-viem": "^2.2.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@tanstack/query-core": "^5.62.16",
@@ -35,14 +35,14 @@
35
35
  "typescript": "^5.7.2",
36
36
  "viem": "^2.23.0",
37
37
  "vitest": "^3.0.5",
38
- "@morpho-org/blue-sdk": "^3.0.0-next.3",
39
- "@morpho-org/blue-sdk-viem": "^3.0.0-next.1",
40
- "@morpho-org/morpho-test": "^2.2.1",
38
+ "@morpho-org/blue-sdk": "^2.3.1",
41
39
  "@morpho-org/morpho-ts": "^2.1.0",
42
- "@morpho-org/simulation-sdk": "^3.0.0-next.1",
40
+ "@morpho-org/simulation-sdk": "^2.1.3",
41
+ "@morpho-org/morpho-test": "^2.2.1",
42
+ "@morpho-org/blue-sdk-viem": "^2.2.2",
43
43
  "@morpho-org/simulation-sdk-wagmi": "^2.0.5",
44
- "@morpho-org/test": "^2.0.6",
45
- "@morpho-org/test-wagmi": "^2.0.4"
44
+ "@morpho-org/test-wagmi": "^2.0.4",
45
+ "@morpho-org/test": "^2.0.6"
46
46
  },
47
47
  "scripts": {
48
48
  "prepublish": "$npm_execpath build",