@morpho-org/morpho-sdk 2.1.1 → 3.1.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.
Files changed (206) hide show
  1. package/lib/cjs/abis.d.ts +2816 -0
  2. package/lib/cjs/abis.js +1951 -0
  3. package/lib/cjs/actions/index.d.ts +3 -0
  4. package/lib/cjs/actions/marketV1/borrow.js +7 -10
  5. package/lib/cjs/actions/marketV1/buildReallocationActions.d.ts +2 -3
  6. package/lib/cjs/actions/marketV1/buildReallocationActions.js +1 -2
  7. package/lib/cjs/actions/marketV1/index.d.ts +2 -0
  8. package/lib/cjs/actions/marketV1/index.js +2 -0
  9. package/lib/cjs/actions/marketV1/repay.d.ts +2 -0
  10. package/lib/cjs/actions/marketV1/repay.js +7 -8
  11. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
  12. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +9 -10
  13. package/lib/cjs/actions/marketV1/supply.d.ts +69 -0
  14. package/lib/cjs/actions/marketV1/supply.js +128 -0
  15. package/lib/cjs/actions/marketV1/supplyCollateral.d.ts +3 -1
  16. package/lib/cjs/actions/marketV1/supplyCollateral.js +12 -13
  17. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.d.ts +3 -1
  18. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +14 -15
  19. package/lib/cjs/actions/marketV1/withdraw.d.ts +83 -0
  20. package/lib/cjs/actions/marketV1/withdraw.js +110 -0
  21. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -2
  22. package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +1 -1
  23. package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
  24. package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -0
  25. package/lib/cjs/actions/vaultV1/deposit.js +13 -14
  26. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -0
  27. package/lib/cjs/actions/vaultV1/migrateToV2.js +11 -9
  28. package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -0
  29. package/lib/cjs/actions/vaultV2/deposit.js +13 -14
  30. package/lib/cjs/addresses.d.ts +2 -0
  31. package/lib/cjs/addresses.js +18 -0
  32. package/lib/cjs/augment/AccrualPosition.d.ts +9 -0
  33. package/lib/cjs/augment/AccrualPosition.js +8 -0
  34. package/lib/cjs/augment/AccrualVault.d.ts +8 -0
  35. package/lib/cjs/augment/AccrualVault.js +7 -0
  36. package/lib/cjs/augment/Holding.d.ts +8 -0
  37. package/lib/cjs/augment/Holding.js +7 -0
  38. package/lib/cjs/augment/Market.d.ts +8 -0
  39. package/lib/cjs/augment/Market.js +7 -0
  40. package/lib/cjs/augment/MarketParams.d.ts +8 -0
  41. package/lib/cjs/augment/MarketParams.js +7 -0
  42. package/lib/cjs/augment/Position.d.ts +8 -0
  43. package/lib/cjs/augment/Position.js +7 -0
  44. package/lib/cjs/augment/Token.d.ts +8 -0
  45. package/lib/cjs/augment/Token.js +7 -0
  46. package/lib/cjs/augment/User.d.ts +8 -0
  47. package/lib/cjs/augment/User.js +7 -0
  48. package/lib/cjs/augment/Vault.d.ts +8 -0
  49. package/lib/cjs/augment/Vault.js +7 -0
  50. package/lib/cjs/augment/VaultConfig.d.ts +8 -0
  51. package/lib/cjs/augment/VaultConfig.js +7 -0
  52. package/lib/cjs/augment/VaultMarketAllocation.d.ts +8 -0
  53. package/lib/cjs/augment/VaultMarketAllocation.js +7 -0
  54. package/lib/cjs/augment/VaultMarketConfig.d.ts +8 -0
  55. package/lib/cjs/augment/VaultMarketConfig.js +7 -0
  56. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
  57. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +8 -0
  58. package/lib/cjs/augment/VaultUser.d.ts +8 -0
  59. package/lib/cjs/augment/VaultUser.js +7 -0
  60. package/lib/cjs/augment.d.ts +14 -0
  61. package/lib/cjs/augment.js +16 -0
  62. package/lib/cjs/bundler/actions.d.ts +637 -0
  63. package/lib/cjs/bundler/actions.js +1088 -0
  64. package/lib/cjs/bundler/index.d.ts +2 -0
  65. package/lib/cjs/bundler/index.js +18 -0
  66. package/lib/cjs/bundler/types.d.ts +200 -0
  67. package/lib/cjs/bundler/types.js +2 -0
  68. package/lib/cjs/constants.d.ts +3 -0
  69. package/lib/cjs/constants.js +32 -0
  70. package/lib/cjs/entities/index.d.ts +6 -3
  71. package/lib/cjs/entities/index.js +41 -17
  72. package/lib/cjs/entities/marketV1/marketV1.d.ts +161 -24
  73. package/lib/cjs/entities/marketV1/marketV1.js +166 -19
  74. package/lib/cjs/entities/reallocationData.d.ts +193 -0
  75. package/lib/cjs/entities/reallocationData.js +406 -0
  76. package/lib/cjs/errors.d.ts +2 -0
  77. package/lib/cjs/errors.js +18 -0
  78. package/lib/cjs/fetch.d.ts +1 -0
  79. package/lib/cjs/fetch.js +30 -0
  80. package/lib/cjs/format.d.ts +2 -0
  81. package/lib/cjs/format.js +22 -0
  82. package/lib/cjs/helpers/computeReallocations.d.ts +63 -12
  83. package/lib/cjs/helpers/computeReallocations.js +160 -41
  84. package/lib/cjs/helpers/constant.d.ts +17 -0
  85. package/lib/cjs/helpers/constant.js +30 -1
  86. package/lib/cjs/helpers/index.d.ts +3 -2
  87. package/lib/cjs/helpers/index.js +14 -2
  88. package/lib/cjs/helpers/slippage.d.ts +57 -0
  89. package/lib/cjs/helpers/slippage.js +82 -0
  90. package/lib/cjs/helpers/validate.d.ts +40 -7
  91. package/lib/cjs/helpers/validate.js +67 -12
  92. package/lib/cjs/index.d.ts +0 -1
  93. package/lib/cjs/index.js +0 -1
  94. package/lib/cjs/types/action.d.ts +27 -6
  95. package/lib/cjs/types/client.d.ts +1 -1
  96. package/lib/cjs/types/error.d.ts +155 -7
  97. package/lib/cjs/types/error.js +202 -11
  98. package/lib/cjs/types/sharedLiquidity.d.ts +43 -3
  99. package/lib/cjs/types.d.ts +3 -0
  100. package/lib/cjs/types.js +17 -0
  101. package/lib/cjs/utils.d.ts +9 -0
  102. package/lib/cjs/utils.js +65 -0
  103. package/lib/esm/abis.d.ts +2816 -0
  104. package/lib/esm/abis.js +1922 -0
  105. package/lib/esm/actions/index.d.ts +3 -0
  106. package/lib/esm/actions/marketV1/borrow.js +2 -5
  107. package/lib/esm/actions/marketV1/buildReallocationActions.d.ts +2 -3
  108. package/lib/esm/actions/marketV1/buildReallocationActions.js +1 -2
  109. package/lib/esm/actions/marketV1/index.d.ts +2 -0
  110. package/lib/esm/actions/marketV1/index.js +2 -0
  111. package/lib/esm/actions/marketV1/repay.d.ts +2 -0
  112. package/lib/esm/actions/marketV1/repay.js +4 -5
  113. package/lib/esm/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
  114. package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +4 -5
  115. package/lib/esm/actions/marketV1/supply.d.ts +69 -0
  116. package/lib/esm/actions/marketV1/supply.js +124 -0
  117. package/lib/esm/actions/marketV1/supplyCollateral.d.ts +3 -1
  118. package/lib/esm/actions/marketV1/supplyCollateral.js +7 -8
  119. package/lib/esm/actions/marketV1/supplyCollateralBorrow.d.ts +3 -1
  120. package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +7 -8
  121. package/lib/esm/actions/marketV1/withdraw.d.ts +83 -0
  122. package/lib/esm/actions/marketV1/withdraw.js +106 -0
  123. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +1 -1
  124. package/lib/esm/actions/requirements/getRequirementsAction.d.ts +1 -1
  125. package/lib/esm/actions/requirements/getRequirementsApproval.js +1 -1
  126. package/lib/esm/actions/vaultV1/deposit.d.ts +2 -0
  127. package/lib/esm/actions/vaultV1/deposit.js +3 -4
  128. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -0
  129. package/lib/esm/actions/vaultV1/migrateToV2.js +3 -1
  130. package/lib/esm/actions/vaultV2/deposit.d.ts +2 -0
  131. package/lib/esm/actions/vaultV2/deposit.js +3 -4
  132. package/lib/esm/addresses.d.ts +2 -0
  133. package/lib/esm/addresses.js +1 -0
  134. package/lib/esm/augment/AccrualPosition.d.ts +9 -0
  135. package/lib/esm/augment/AccrualPosition.js +5 -0
  136. package/lib/esm/augment/AccrualVault.d.ts +8 -0
  137. package/lib/esm/augment/AccrualVault.js +4 -0
  138. package/lib/esm/augment/Holding.d.ts +8 -0
  139. package/lib/esm/augment/Holding.js +4 -0
  140. package/lib/esm/augment/Market.d.ts +8 -0
  141. package/lib/esm/augment/Market.js +4 -0
  142. package/lib/esm/augment/MarketParams.d.ts +8 -0
  143. package/lib/esm/augment/MarketParams.js +4 -0
  144. package/lib/esm/augment/Position.d.ts +8 -0
  145. package/lib/esm/augment/Position.js +4 -0
  146. package/lib/esm/augment/Token.d.ts +8 -0
  147. package/lib/esm/augment/Token.js +4 -0
  148. package/lib/esm/augment/User.d.ts +8 -0
  149. package/lib/esm/augment/User.js +4 -0
  150. package/lib/esm/augment/Vault.d.ts +8 -0
  151. package/lib/esm/augment/Vault.js +4 -0
  152. package/lib/esm/augment/VaultConfig.d.ts +8 -0
  153. package/lib/esm/augment/VaultConfig.js +4 -0
  154. package/lib/esm/augment/VaultMarketAllocation.d.ts +8 -0
  155. package/lib/esm/augment/VaultMarketAllocation.js +4 -0
  156. package/lib/esm/augment/VaultMarketConfig.d.ts +8 -0
  157. package/lib/esm/augment/VaultMarketConfig.js +4 -0
  158. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
  159. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +5 -0
  160. package/lib/esm/augment/VaultUser.d.ts +8 -0
  161. package/lib/esm/augment/VaultUser.js +4 -0
  162. package/lib/esm/augment.d.ts +14 -0
  163. package/lib/esm/augment.js +14 -0
  164. package/lib/esm/bundler/actions.d.ts +637 -0
  165. package/lib/esm/bundler/actions.js +1085 -0
  166. package/lib/esm/bundler/index.d.ts +2 -0
  167. package/lib/esm/bundler/index.js +2 -0
  168. package/lib/esm/bundler/types.d.ts +200 -0
  169. package/lib/esm/bundler/types.js +1 -0
  170. package/lib/esm/constants.d.ts +3 -0
  171. package/lib/esm/constants.js +3 -0
  172. package/lib/esm/entities/index.d.ts +6 -3
  173. package/lib/esm/entities/index.js +5 -3
  174. package/lib/esm/entities/marketV1/marketV1.d.ts +161 -24
  175. package/lib/esm/entities/marketV1/marketV1.js +170 -23
  176. package/lib/esm/entities/reallocationData.d.ts +193 -0
  177. package/lib/esm/entities/reallocationData.js +402 -0
  178. package/lib/esm/errors.d.ts +2 -0
  179. package/lib/esm/errors.js +1 -0
  180. package/lib/esm/fetch.d.ts +1 -0
  181. package/lib/esm/fetch.js +1 -0
  182. package/lib/esm/format.d.ts +2 -0
  183. package/lib/esm/format.js +1 -0
  184. package/lib/esm/helpers/computeReallocations.d.ts +63 -12
  185. package/lib/esm/helpers/computeReallocations.js +160 -41
  186. package/lib/esm/helpers/constant.d.ts +17 -0
  187. package/lib/esm/helpers/constant.js +30 -1
  188. package/lib/esm/helpers/index.d.ts +3 -2
  189. package/lib/esm/helpers/index.js +3 -2
  190. package/lib/esm/helpers/slippage.d.ts +57 -0
  191. package/lib/esm/helpers/slippage.js +80 -0
  192. package/lib/esm/helpers/validate.d.ts +40 -7
  193. package/lib/esm/helpers/validate.js +63 -11
  194. package/lib/esm/index.d.ts +0 -1
  195. package/lib/esm/index.js +0 -1
  196. package/lib/esm/types/action.d.ts +27 -6
  197. package/lib/esm/types/client.d.ts +1 -1
  198. package/lib/esm/types/error.d.ts +155 -7
  199. package/lib/esm/types/error.js +185 -9
  200. package/lib/esm/types/sharedLiquidity.d.ts +43 -3
  201. package/lib/esm/types.d.ts +3 -0
  202. package/lib/esm/types.js +1 -0
  203. package/lib/esm/utils.d.ts +9 -0
  204. package/lib/esm/utils.js +7 -0
  205. package/package.json +128 -17
  206. package/src/index.ts +0 -1
@@ -1,3 +1,6 @@
1
+ export type { MarketV1Actions } from "../entities/marketV1/index.js";
2
+ export type { VaultV1Actions } from "../entities/vaultV1/index.js";
3
+ export type { VaultV2Actions } from "../entities/vaultV2/index.js";
1
4
  export * from "./marketV1/index.js";
2
5
  export * from "./requirements/index.js";
3
6
  export * from "./vaultV1/index.js";
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marketV1Borrow = void 0;
4
- const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
5
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
- const index_js_1 = require("../../helpers/index.js");
7
- const index_js_2 = require("../../types/index.js");
5
+ const index_js_1 = require("../../bundler/index.js");
6
+ const index_js_2 = require("../../helpers/index.js");
7
+ const index_js_3 = require("../../types/index.js");
8
8
  const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
9
9
  /**
10
10
  * Prepares a borrow transaction for a Morpho Blue market.
@@ -57,10 +57,10 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
57
57
  */
58
58
  const marketV1Borrow = ({ market: { chainId, marketParams }, args: { amount, receiver, minSharePrice, reallocations }, metadata, }) => {
59
59
  if (amount <= 0n) {
60
- throw new index_js_2.NonPositiveBorrowAmountError(marketParams.id);
60
+ throw new index_js_3.NonPositiveBorrowAmountError(marketParams.id);
61
61
  }
62
62
  if (minSharePrice < 0n) {
63
- throw new index_js_2.NonPositiveMinBorrowSharePriceError(marketParams.id);
63
+ throw new index_js_3.NonPositiveMinBorrowSharePriceError(marketParams.id);
64
64
  }
65
65
  const actions = [];
66
66
  let reallocationFee = 0n;
@@ -73,12 +73,9 @@ const marketV1Borrow = ({ market: { chainId, marketParams }, args: { amount, rec
73
73
  type: "morphoBorrow",
74
74
  args: [marketParams, amount, 0n, minSharePrice, receiver, false],
75
75
  });
76
- let tx = {
77
- ...bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions),
78
- value: reallocationFee,
79
- };
76
+ let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
80
77
  if (metadata) {
81
- tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
78
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
82
79
  }
83
80
  return (0, morpho_ts_1.deepFreeze)({
84
81
  ...tx,
@@ -1,5 +1,5 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
- import type { Action } from "@morpho-org/bundler-sdk-viem";
2
+ import type { Action } from "../../bundler/index.js";
3
3
  import type { VaultReallocation } from "../../types/index.js";
4
4
  /**
5
5
  * Builds reallocation bundler actions and computes the total fee.
@@ -12,8 +12,7 @@ import type { VaultReallocation } from "../../types/index.js";
12
12
  *
13
13
  * @param reallocations - The vault reallocations to encode.
14
14
  * @param targetMarketParams - The target market params the freed liquidity is destined for.
15
- * @returns The encoded `reallocateTo` actions and the summed reallocation fee (in native, used
16
- * as `tx.value` in the parent bundle).
15
+ * @returns The encoded `reallocateTo` actions and the summed reallocation fee in native tokens.
17
16
  * @throws {NegativeReallocationFeeError} when any reallocation fee is negative.
18
17
  * @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
19
18
  * @throws {NonPositiveReallocationAmountError} when any withdrawal amount is non-positive.
@@ -13,8 +13,7 @@ const index_js_1 = require("../../helpers/index.js");
13
13
  *
14
14
  * @param reallocations - The vault reallocations to encode.
15
15
  * @param targetMarketParams - The target market params the freed liquidity is destined for.
16
- * @returns The encoded `reallocateTo` actions and the summed reallocation fee (in native, used
17
- * as `tx.value` in the parent bundle).
16
+ * @returns The encoded `reallocateTo` actions and the summed reallocation fee in native tokens.
18
17
  * @throws {NegativeReallocationFeeError} when any reallocation fee is negative.
19
18
  * @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
20
19
  * @throws {NonPositiveReallocationAmountError} when any withdrawal amount is non-positive.
@@ -1,6 +1,8 @@
1
1
  export * from "./borrow.js";
2
2
  export * from "./repay.js";
3
3
  export * from "./repayWithdrawCollateral.js";
4
+ export * from "./supply.js";
4
5
  export * from "./supplyCollateral.js";
5
6
  export * from "./supplyCollateralBorrow.js";
7
+ export * from "./withdraw.js";
6
8
  export * from "./withdrawCollateral.js";
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./borrow.js"), exports);
18
18
  __exportStar(require("./repay.js"), exports);
19
19
  __exportStar(require("./repayWithdrawCollateral.js"), exports);
20
+ __exportStar(require("./supply.js"), exports);
20
21
  __exportStar(require("./supplyCollateral.js"), exports);
21
22
  __exportStar(require("./supplyCollateralBorrow.js"), exports);
23
+ __exportStar(require("./withdraw.js"), exports);
22
24
  __exportStar(require("./withdrawCollateral.js"), exports);
@@ -68,6 +68,8 @@ export interface MarketV1RepayParams {
68
68
  * is provided and the signed asset differs from `marketParams.loanToken`.
69
69
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
70
70
  * is provided and the signed amount differs from `args.transferAmount`.
71
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
72
+ * signature is missing its expiration.
71
73
  * @example
72
74
  * ```ts
73
75
  * import { marketV1Repay } from "@morpho-org/morpho-sdk";
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marketV1Repay = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
6
  const viem_1 = require("viem");
8
- const index_js_1 = require("../../helpers/index.js");
7
+ const index_js_1 = require("../../bundler/index.js");
8
+ const index_js_2 = require("../../helpers/index.js");
9
9
  const getRequirementsAction_js_1 = require("../requirements/getRequirementsAction.js");
10
10
  /**
11
11
  * Prepares a repay transaction for a Morpho Blue market.
@@ -47,6 +47,8 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
47
47
  * is provided and the signed asset differs from `marketParams.loanToken`.
48
48
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
49
49
  * is provided and the signed amount differs from `args.transferAmount`.
50
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
51
+ * signature is missing its expiration.
50
52
  * @example
51
53
  * ```ts
52
54
  * import { marketV1Repay } from "@morpho-org/morpho-sdk";
@@ -66,7 +68,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
66
68
  * ```
67
69
  */
68
70
  const marketV1Repay = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
69
- (0, index_js_1.validateRepayParams)({
71
+ (0, index_js_2.validateRepayParams)({
70
72
  assets,
71
73
  shares,
72
74
  transferAmount,
@@ -108,12 +110,9 @@ const marketV1Repay = ({ market: { chainId, marketParams }, args: { assets, shar
108
110
  ],
109
111
  });
110
112
  }
111
- let tx = {
112
- ...bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions),
113
- value: 0n,
114
- };
113
+ let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
115
114
  if (metadata) {
116
- tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
115
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
117
116
  }
118
117
  return (0, morpho_ts_1.deepFreeze)({
119
118
  ...tx,
@@ -81,6 +81,8 @@ export interface MarketV1RepayWithdrawCollateralParams {
81
81
  * is provided and the signed asset differs from `marketParams.loanToken`.
82
82
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
83
83
  * is provided and the signed amount differs from `args.transferAmount`.
84
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
85
+ * signature is missing its expiration.
84
86
  * @example
85
87
  * ```ts
86
88
  * import { marketV1RepayWithdrawCollateral } from "@morpho-org/morpho-sdk";
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marketV1RepayWithdrawCollateral = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
6
  const viem_1 = require("viem");
8
- const index_js_1 = require("../../helpers/index.js");
9
- const index_js_2 = require("../../types/index.js");
7
+ const index_js_1 = require("../../bundler/index.js");
8
+ const index_js_2 = require("../../helpers/index.js");
9
+ const index_js_3 = require("../../types/index.js");
10
10
  const getRequirementsAction_js_1 = require("../requirements/getRequirementsAction.js");
11
11
  /**
12
12
  * Prepares an atomic repay-and-withdraw-collateral transaction for a Morpho Blue market.
@@ -58,6 +58,8 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
58
58
  * is provided and the signed asset differs from `marketParams.loanToken`.
59
59
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
60
60
  * is provided and the signed amount differs from `args.transferAmount`.
61
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
62
+ * signature is missing its expiration.
61
63
  * @example
62
64
  * ```ts
63
65
  * import { marketV1RepayWithdrawCollateral } from "@morpho-org/morpho-sdk";
@@ -78,7 +80,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
78
80
  * ```
79
81
  */
80
82
  const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, withdrawAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
81
- (0, index_js_1.validateRepayParams)({
83
+ (0, index_js_2.validateRepayParams)({
82
84
  assets,
83
85
  shares,
84
86
  transferAmount,
@@ -86,7 +88,7 @@ const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParams }, ar
86
88
  marketId: marketParams.id,
87
89
  });
88
90
  if (withdrawAmount <= 0n) {
89
- throw new index_js_2.NonPositiveWithdrawCollateralAmountError(marketParams.id);
91
+ throw new index_js_3.NonPositiveWithdrawCollateralAmountError(marketParams.id);
90
92
  }
91
93
  const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
92
94
  const actions = [];
@@ -128,12 +130,9 @@ const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParams }, ar
128
130
  type: "morphoWithdrawCollateral",
129
131
  args: [marketParams, withdrawAmount, receiver, false],
130
132
  });
131
- let tx = {
132
- ...bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions),
133
- value: 0n,
134
- };
133
+ let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
135
134
  if (metadata) {
136
- tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
135
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
137
136
  }
138
137
  return (0, morpho_ts_1.deepFreeze)({
139
138
  ...tx,
@@ -0,0 +1,69 @@
1
+ import { type MarketParams } from "@morpho-org/blue-sdk";
2
+ import type { Address } from "viem";
3
+ import { type DepositAmountArgs, type MarketV1SupplyAction, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
4
+ /** Parameters for {@link marketV1Supply}. */
5
+ export interface MarketV1SupplyParams {
6
+ market: {
7
+ readonly chainId: number;
8
+ readonly marketParams: MarketParams;
9
+ };
10
+ args: DepositAmountArgs & {
11
+ onBehalf: Address;
12
+ /** Maximum supply share price (in ray). Slippage protection against inflation attacks. */
13
+ maxSharePrice: bigint;
14
+ requirementSignature?: RequirementSignature;
15
+ };
16
+ metadata?: Metadata;
17
+ }
18
+ /**
19
+ * Prepares a loan-asset supply transaction for a Morpho Blue market.
20
+ *
21
+ * Routed through bundler3 via `GeneralAdapter1`. When `nativeAmount > 0`, native ETH is wrapped
22
+ * via `GeneralAdapter1.wrapNative()` before the supply; the loan token must be the chain's
23
+ * wNative for that path. Uses `maxSharePrice` to protect against share-price inflation between
24
+ * transaction construction and execution.
25
+ *
26
+ * Zero loss: all supplied assets reach Morpho. No dust left in bundler or adapter.
27
+ *
28
+ * @param params.market.chainId - The chain the market lives on.
29
+ * @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
30
+ * @param params.args.amount - Amount of ERC-20 loan asset to supply. At least one of `amount` or
31
+ * `nativeAmount` must be positive. Defaults to `0n`.
32
+ * @param params.args.onBehalf - Address whose Morpho supply position is credited.
33
+ * @param params.args.maxSharePrice - Maximum acceptable supply share price (in ray). Slippage
34
+ * protection.
35
+ * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
36
+ * supply. Requires the loan token to be the chain's wNative.
37
+ * @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval. When
38
+ * absent, the bundle uses a plain `erc20TransferFrom` and assumes the user has already
39
+ * approved `GeneralAdapter1`.
40
+ * @param params.metadata - Optional analytics metadata attached to the bundle.
41
+ * @returns A deep-frozen `Transaction<MarketV1SupplyAction>` with `to`, `value`, `data`, and the
42
+ * typed `action` discriminator the simulation layer consumes.
43
+ * @throws {NegativeSupplyAmountError} when `amount < 0n`.
44
+ * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
45
+ * @throws {ZeroSupplyAmountError} when both `amount` and `nativeAmount` resolve to zero.
46
+ * @throws {NegativeSupplyMaxSharePriceError} when `maxSharePrice < 0n`.
47
+ * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
48
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the loan token is not
49
+ * the chain's wNative.
50
+ * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
51
+ * is provided and the signed asset differs from `marketParams.loanToken`.
52
+ * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
53
+ * is provided and the signed amount differs from `args.amount`.
54
+ * @example
55
+ * ```ts
56
+ * import { marketV1Supply } from "@morpho-org/morpho-sdk";
57
+ *
58
+ * const tx = marketV1Supply({
59
+ * market: { chainId: 1, marketParams },
60
+ * args: {
61
+ * amount: 1_000_000_000n,
62
+ * onBehalf: supplier,
63
+ * maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
64
+ * },
65
+ * });
66
+ * // tx satisfies Readonly<Transaction<MarketV1SupplyAction>>
67
+ * ```
68
+ */
69
+ export declare const marketV1Supply: ({ market: { chainId, marketParams }, args: { amount, onBehalf, maxSharePrice, requirementSignature, nativeAmount, }, metadata, }: MarketV1SupplyParams) => Readonly<Transaction<MarketV1SupplyAction>>;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.marketV1Supply = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ const index_js_1 = require("../../bundler/index.js");
7
+ const index_js_2 = require("../../helpers/index.js");
8
+ const index_js_3 = require("../../types/index.js");
9
+ const getRequirementsAction_js_1 = require("../requirements/getRequirementsAction.js");
10
+ /**
11
+ * Prepares a loan-asset supply transaction for a Morpho Blue market.
12
+ *
13
+ * Routed through bundler3 via `GeneralAdapter1`. When `nativeAmount > 0`, native ETH is wrapped
14
+ * via `GeneralAdapter1.wrapNative()` before the supply; the loan token must be the chain's
15
+ * wNative for that path. Uses `maxSharePrice` to protect against share-price inflation between
16
+ * transaction construction and execution.
17
+ *
18
+ * Zero loss: all supplied assets reach Morpho. No dust left in bundler or adapter.
19
+ *
20
+ * @param params.market.chainId - The chain the market lives on.
21
+ * @param params.market.marketParams - Market params (loanToken, collateralToken, oracle, irm, lltv).
22
+ * @param params.args.amount - Amount of ERC-20 loan asset to supply. At least one of `amount` or
23
+ * `nativeAmount` must be positive. Defaults to `0n`.
24
+ * @param params.args.onBehalf - Address whose Morpho supply position is credited.
25
+ * @param params.args.maxSharePrice - Maximum acceptable supply share price (in ray). Slippage
26
+ * protection.
27
+ * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
28
+ * supply. Requires the loan token to be the chain's wNative.
29
+ * @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval. When
30
+ * absent, the bundle uses a plain `erc20TransferFrom` and assumes the user has already
31
+ * approved `GeneralAdapter1`.
32
+ * @param params.metadata - Optional analytics metadata attached to the bundle.
33
+ * @returns A deep-frozen `Transaction<MarketV1SupplyAction>` with `to`, `value`, `data`, and the
34
+ * typed `action` discriminator the simulation layer consumes.
35
+ * @throws {NegativeSupplyAmountError} when `amount < 0n`.
36
+ * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
37
+ * @throws {ZeroSupplyAmountError} when both `amount` and `nativeAmount` resolve to zero.
38
+ * @throws {NegativeSupplyMaxSharePriceError} when `maxSharePrice < 0n`.
39
+ * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
40
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the loan token is not
41
+ * the chain's wNative.
42
+ * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
43
+ * is provided and the signed asset differs from `marketParams.loanToken`.
44
+ * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
45
+ * is provided and the signed amount differs from `args.amount`.
46
+ * @example
47
+ * ```ts
48
+ * import { marketV1Supply } from "@morpho-org/morpho-sdk";
49
+ *
50
+ * const tx = marketV1Supply({
51
+ * market: { chainId: 1, marketParams },
52
+ * args: {
53
+ * amount: 1_000_000_000n,
54
+ * onBehalf: supplier,
55
+ * maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
56
+ * },
57
+ * });
58
+ * // tx satisfies Readonly<Transaction<MarketV1SupplyAction>>
59
+ * ```
60
+ */
61
+ const marketV1Supply = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, maxSharePrice, requirementSignature, nativeAmount, }, metadata, }) => {
62
+ if (amount < 0n) {
63
+ throw new index_js_3.NegativeSupplyAmountError(marketParams.id);
64
+ }
65
+ if (nativeAmount !== undefined && nativeAmount < 0n) {
66
+ throw new index_js_3.NegativeNativeAmountError(nativeAmount);
67
+ }
68
+ if (maxSharePrice < 0n) {
69
+ throw new index_js_3.NegativeSupplyMaxSharePriceError(marketParams.id);
70
+ }
71
+ const totalAssets = amount + (nativeAmount ?? 0n);
72
+ if (totalAssets === 0n) {
73
+ throw new index_js_3.ZeroSupplyAmountError(marketParams.id);
74
+ }
75
+ const { bundler3: { generalAdapter1, bundler3 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
76
+ const actions = [];
77
+ if (nativeAmount !== undefined && nativeAmount > 0n) {
78
+ (0, index_js_2.validateNativeAsset)(chainId, marketParams.loanToken);
79
+ actions.push({
80
+ type: "nativeTransfer",
81
+ args: [bundler3, generalAdapter1, nativeAmount, false],
82
+ }, {
83
+ type: "wrapNative",
84
+ args: [nativeAmount, generalAdapter1, false],
85
+ });
86
+ }
87
+ if (amount > 0n) {
88
+ if (requirementSignature) {
89
+ actions.push(...(0, getRequirementsAction_js_1.getRequirementsAction)({
90
+ asset: marketParams.loanToken,
91
+ amount,
92
+ recipient: generalAdapter1,
93
+ requirementSignature,
94
+ }));
95
+ }
96
+ else {
97
+ actions.push({
98
+ type: "erc20TransferFrom",
99
+ args: [marketParams.loanToken, amount, generalAdapter1, false],
100
+ });
101
+ }
102
+ }
103
+ actions.push({
104
+ type: "morphoSupply",
105
+ args: [marketParams, totalAssets, 0n, maxSharePrice, onBehalf, [], false],
106
+ });
107
+ let tx = {
108
+ ...index_js_1.BundlerAction.encodeBundle(chainId, actions),
109
+ value: nativeAmount ?? 0n,
110
+ };
111
+ if (metadata) {
112
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
113
+ }
114
+ return (0, morpho_ts_1.deepFreeze)({
115
+ ...tx,
116
+ action: {
117
+ type: "marketV1Supply",
118
+ args: {
119
+ market: marketParams.id,
120
+ amount: totalAssets,
121
+ onBehalf,
122
+ maxSharePrice,
123
+ nativeAmount,
124
+ },
125
+ },
126
+ });
127
+ };
128
+ exports.marketV1Supply = marketV1Supply;
@@ -39,12 +39,14 @@ export interface MarketV1SupplyCollateralParams {
39
39
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
40
40
  * @throws {ZeroCollateralAmountError} when both `amount` and `nativeAmount` resolve to zero.
41
41
  * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
42
- * @throws {NativeAmountOnNonWNativeCollateralError} when `nativeAmount > 0n` but the collateral
42
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the collateral
43
43
  * token is not the chain's wNative.
44
44
  * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
45
45
  * is provided and the signed asset differs from `marketParams.collateralToken`.
46
46
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
47
47
  * is provided and the signed amount differs from `args.amount`.
48
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
49
+ * signature is missing its expiration.
48
50
  * @example
49
51
  * ```ts
50
52
  * import { marketV1SupplyCollateral } from "@morpho-org/morpho-sdk";
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marketV1SupplyCollateral = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
- const index_js_1 = require("../../helpers/index.js");
8
- const index_js_2 = require("../../types/index.js");
6
+ const index_js_1 = require("../../bundler/index.js");
7
+ const index_js_2 = require("../../helpers/index.js");
8
+ const index_js_3 = require("../../types/index.js");
9
9
  const getRequirementsAction_js_1 = require("../requirements/getRequirementsAction.js");
10
10
  /**
11
11
  * Prepares a supply-collateral transaction for a Morpho Blue market.
@@ -33,12 +33,14 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
33
33
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
34
34
  * @throws {ZeroCollateralAmountError} when both `amount` and `nativeAmount` resolve to zero.
35
35
  * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
36
- * @throws {NativeAmountOnNonWNativeCollateralError} when `nativeAmount > 0n` but the collateral
36
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the collateral
37
37
  * token is not the chain's wNative.
38
38
  * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
39
39
  * is provided and the signed asset differs from `marketParams.collateralToken`.
40
40
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
41
41
  * is provided and the signed amount differs from `args.amount`.
42
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
43
+ * signature is missing its expiration.
42
44
  * @example
43
45
  * ```ts
44
46
  * import { marketV1SupplyCollateral } from "@morpho-org/morpho-sdk";
@@ -52,19 +54,19 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
52
54
  */
53
55
  const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, requirementSignature, nativeAmount }, metadata, }) => {
54
56
  if (amount < 0n) {
55
- throw new index_js_2.NonPositiveAssetAmountError(marketParams.collateralToken);
57
+ throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
56
58
  }
57
59
  if (nativeAmount !== undefined && nativeAmount < 0n) {
58
- throw new index_js_2.NegativeNativeAmountError(nativeAmount);
60
+ throw new index_js_3.NegativeNativeAmountError(nativeAmount);
59
61
  }
60
62
  const totalCollateral = amount + (nativeAmount ?? 0n);
61
63
  if (totalCollateral === 0n) {
62
- throw new index_js_2.ZeroCollateralAmountError(marketParams.id);
64
+ throw new index_js_3.ZeroCollateralAmountError(marketParams.id);
63
65
  }
64
66
  const { bundler3: { generalAdapter1, bundler3 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
65
67
  const actions = [];
66
68
  if (nativeAmount !== undefined && nativeAmount > 0n) {
67
- (0, index_js_1.validateNativeCollateral)(chainId, marketParams.collateralToken);
69
+ (0, index_js_2.validateNativeAsset)(chainId, marketParams.collateralToken);
68
70
  actions.push({
69
71
  type: "nativeTransfer",
70
72
  args: [bundler3, generalAdapter1, nativeAmount, false],
@@ -93,12 +95,9 @@ const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { a
93
95
  type: "morphoSupplyCollateral",
94
96
  args: [marketParams, totalCollateral, onBehalf, [], false],
95
97
  });
96
- let tx = {
97
- ...bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions),
98
- value: nativeAmount ?? 0n,
99
- };
98
+ let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
100
99
  if (metadata) {
101
- tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
100
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
102
101
  }
103
102
  return (0, morpho_ts_1.deepFreeze)({
104
103
  ...tx,
@@ -55,12 +55,14 @@ export interface MarketV1SupplyCollateralBorrowParams {
55
55
  * @throws {NonPositiveMinBorrowSharePriceError} when `minSharePrice < 0n`.
56
56
  * @throws {ZeroCollateralAmountError} when both `amount` and `nativeAmount` resolve to zero.
57
57
  * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
58
- * @throws {NativeAmountOnNonWNativeCollateralError} when `nativeAmount > 0n` but the collateral
58
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the collateral
59
59
  * token is not the chain's wNative.
60
60
  * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
61
61
  * is provided and the signed asset differs from `marketParams.collateralToken`.
62
62
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
63
63
  * is provided and the signed amount differs from `args.amount`.
64
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
65
+ * signature is missing its expiration.
64
66
  * @throws {NegativeReallocationFeeError} from `buildReallocationActions` when
65
67
  * `reallocations` is non-empty and any `reallocation.fee < 0n`.
66
68
  * @throws {EmptyReallocationWithdrawalsError} from `buildReallocationActions` when any
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marketV1SupplyCollateralBorrow = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
- const index_js_1 = require("../../helpers/index.js");
8
- const index_js_2 = require("../../types/index.js");
6
+ const index_js_1 = require("../../bundler/index.js");
7
+ const index_js_2 = require("../../helpers/index.js");
8
+ const index_js_3 = require("../../types/index.js");
9
9
  const getRequirementsAction_js_1 = require("../requirements/getRequirementsAction.js");
10
10
  const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
11
11
  /**
@@ -44,12 +44,14 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
44
44
  * @throws {NonPositiveMinBorrowSharePriceError} when `minSharePrice < 0n`.
45
45
  * @throws {ZeroCollateralAmountError} when both `amount` and `nativeAmount` resolve to zero.
46
46
  * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
47
- * @throws {NativeAmountOnNonWNativeCollateralError} when `nativeAmount > 0n` but the collateral
47
+ * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the collateral
48
48
  * token is not the chain's wNative.
49
49
  * @throws {DepositAssetMismatchError} from `getRequirementsAction` when `requirementSignature`
50
50
  * is provided and the signed asset differs from `marketParams.collateralToken`.
51
51
  * @throws {DepositAmountMismatchError} from `getRequirementsAction` when `requirementSignature`
52
52
  * is provided and the signed amount differs from `args.amount`.
53
+ * @throws {Permit2ExpirationMissingError} from `getRequirementsAction` when a Permit2 requirement
54
+ * signature is missing its expiration.
53
55
  * @throws {NegativeReallocationFeeError} from `buildReallocationActions` when
54
56
  * `reallocations` is non-empty and any `reallocation.fee < 0n`.
55
57
  * @throws {EmptyReallocationWithdrawalsError} from `buildReallocationActions` when any
@@ -79,25 +81,25 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
79
81
  */
80
82
  const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, args: { amount = 0n, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }) => {
81
83
  if (amount < 0n) {
82
- throw new index_js_2.NonPositiveAssetAmountError(marketParams.collateralToken);
84
+ throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
83
85
  }
84
86
  if (nativeAmount !== undefined && nativeAmount < 0n) {
85
- throw new index_js_2.NegativeNativeAmountError(nativeAmount);
87
+ throw new index_js_3.NegativeNativeAmountError(nativeAmount);
86
88
  }
87
89
  if (borrowAmount <= 0n) {
88
- throw new index_js_2.NonPositiveBorrowAmountError(marketParams.id);
90
+ throw new index_js_3.NonPositiveBorrowAmountError(marketParams.id);
89
91
  }
90
92
  if (minSharePrice < 0n) {
91
- throw new index_js_2.NonPositiveMinBorrowSharePriceError(marketParams.id);
93
+ throw new index_js_3.NonPositiveMinBorrowSharePriceError(marketParams.id);
92
94
  }
93
95
  const totalCollateral = amount + (nativeAmount ?? 0n);
94
96
  if (totalCollateral === 0n) {
95
- throw new index_js_2.ZeroCollateralAmountError(marketParams.id);
97
+ throw new index_js_3.ZeroCollateralAmountError(marketParams.id);
96
98
  }
97
99
  const { bundler3: { generalAdapter1, bundler3 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
98
100
  const actions = [];
99
101
  if (nativeAmount !== undefined && nativeAmount > 0n) {
100
- (0, index_js_1.validateNativeCollateral)(chainId, marketParams.collateralToken);
102
+ (0, index_js_2.validateNativeAsset)(chainId, marketParams.collateralToken);
101
103
  actions.push({
102
104
  type: "nativeTransfer",
103
105
  args: [bundler3, generalAdapter1, nativeAmount, false],
@@ -136,12 +138,9 @@ const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, arg
136
138
  type: "morphoBorrow",
137
139
  args: [marketParams, borrowAmount, 0n, minSharePrice, receiver, false],
138
140
  });
139
- let tx = {
140
- ...bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions),
141
- value: (nativeAmount ?? 0n) + reallocationFee,
142
- };
141
+ let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
143
142
  if (metadata) {
144
- tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
143
+ tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
145
144
  }
146
145
  return (0, morpho_ts_1.deepFreeze)({
147
146
  ...tx,