@morpho-org/morpho-sdk 4.1.0 → 5.0.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 (178) hide show
  1. package/README.md +12 -12
  2. package/lib/cjs/actions/blue/borrow.d.ts +12 -2
  3. package/lib/cjs/actions/blue/borrow.js +7 -1
  4. package/lib/cjs/actions/blue/refinance.d.ts +13 -3
  5. package/lib/cjs/actions/blue/refinance.js +8 -2
  6. package/lib/cjs/actions/blue/repay.d.ts +6 -5
  7. package/lib/cjs/actions/blue/repay.js +10 -18
  8. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +15 -6
  9. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +16 -18
  10. package/lib/cjs/actions/blue/supply.d.ts +7 -7
  11. package/lib/cjs/actions/blue/supply.js +10 -20
  12. package/lib/cjs/actions/blue/supplyCollateral.d.ts +8 -8
  13. package/lib/cjs/actions/blue/supplyCollateral.js +11 -21
  14. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +18 -6
  15. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +17 -19
  16. package/lib/cjs/actions/blue/withdraw.d.ts +10 -2
  17. package/lib/cjs/actions/blue/withdraw.js +7 -1
  18. package/lib/cjs/actions/index.d.ts +1 -0
  19. package/lib/cjs/actions/index.js +1 -0
  20. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
  21. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +111 -0
  22. package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
  23. package/lib/cjs/actions/requirements/blue/index.js +17 -0
  24. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
  25. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +89 -0
  26. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
  27. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +17 -5
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +18 -4
  30. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
  31. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +10 -14
  32. package/lib/cjs/actions/requirements/encode/index.d.ts +2 -1
  33. package/lib/cjs/actions/requirements/encode/index.js +2 -1
  34. package/lib/cjs/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
  35. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +151 -0
  36. package/lib/{esm/actions/requirements/getRequirementsPermit.d.ts → cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
  37. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +50 -0
  38. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
  39. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +74 -0
  40. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +3 -0
  41. package/lib/cjs/actions/requirements/generalAdapter/index.js +19 -0
  42. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  43. package/lib/cjs/actions/requirements/getRequirementsApproval.js +3 -2
  44. package/lib/cjs/actions/requirements/index.d.ts +2 -5
  45. package/lib/cjs/actions/requirements/index.js +2 -5
  46. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
  47. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +48 -0
  48. package/lib/{esm/actions/requirements/getRequirementsAction.d.ts → cjs/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
  49. package/lib/cjs/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +26 -13
  50. package/lib/cjs/actions/signatures/index.d.ts +2 -0
  51. package/lib/cjs/actions/signatures/index.js +18 -0
  52. package/lib/cjs/actions/vaultV1/deposit.d.ts +6 -8
  53. package/lib/cjs/actions/vaultV1/deposit.js +11 -21
  54. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +6 -6
  55. package/lib/cjs/actions/vaultV1/migrateToV2.js +12 -20
  56. package/lib/cjs/actions/vaultV2/deposit.d.ts +6 -8
  57. package/lib/cjs/actions/vaultV2/deposit.js +11 -21
  58. package/lib/cjs/addresses.d.ts +2 -2
  59. package/lib/cjs/addresses.js +2 -1
  60. package/lib/cjs/bundler/actions.d.ts +44 -4
  61. package/lib/cjs/bundler/actions.js +75 -2
  62. package/lib/cjs/bundler/types.d.ts +6 -0
  63. package/lib/cjs/constants.d.ts +2 -2
  64. package/lib/cjs/constants.js +3 -3
  65. package/lib/cjs/entities/blue/blue.d.ts +58 -33
  66. package/lib/cjs/entities/blue/blue.js +171 -125
  67. package/lib/cjs/entities/reallocationData.d.ts +12 -12
  68. package/lib/cjs/entities/reallocationData.js +19 -19
  69. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -9
  70. package/lib/cjs/entities/vaultV1/vaultV1.js +44 -34
  71. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +6 -6
  72. package/lib/cjs/entities/vaultV2/vaultV2.js +21 -16
  73. package/lib/cjs/errors.d.ts +3 -2
  74. package/lib/cjs/errors.js +5 -2
  75. package/lib/cjs/helpers/validate.d.ts +2 -2
  76. package/lib/cjs/helpers/validate.js +1 -1
  77. package/lib/cjs/types/action.d.ts +113 -9
  78. package/lib/cjs/types/action.js +79 -5
  79. package/lib/cjs/types/error.d.ts +73 -0
  80. package/lib/cjs/types/error.js +89 -4
  81. package/lib/cjs/types.d.ts +2 -1
  82. package/lib/cjs/utils.d.ts +1 -1
  83. package/lib/cjs/utils.js +2 -3
  84. package/lib/esm/actions/blue/borrow.d.ts +12 -2
  85. package/lib/esm/actions/blue/borrow.js +7 -1
  86. package/lib/esm/actions/blue/refinance.d.ts +13 -3
  87. package/lib/esm/actions/blue/refinance.js +8 -2
  88. package/lib/esm/actions/blue/repay.d.ts +6 -5
  89. package/lib/esm/actions/blue/repay.js +10 -18
  90. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +15 -6
  91. package/lib/esm/actions/blue/repayWithdrawCollateral.js +16 -18
  92. package/lib/esm/actions/blue/supply.d.ts +7 -7
  93. package/lib/esm/actions/blue/supply.js +10 -20
  94. package/lib/esm/actions/blue/supplyCollateral.d.ts +8 -8
  95. package/lib/esm/actions/blue/supplyCollateral.js +11 -21
  96. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +18 -6
  97. package/lib/esm/actions/blue/supplyCollateralBorrow.js +17 -19
  98. package/lib/esm/actions/blue/withdraw.d.ts +10 -2
  99. package/lib/esm/actions/blue/withdraw.js +7 -1
  100. package/lib/esm/actions/index.d.ts +1 -0
  101. package/lib/esm/actions/index.js +1 -0
  102. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
  103. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +107 -0
  104. package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
  105. package/lib/esm/actions/requirements/blue/index.js +1 -0
  106. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
  107. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +85 -0
  108. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
  109. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +19 -7
  110. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
  111. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +20 -6
  112. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
  113. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +8 -12
  114. package/lib/esm/actions/requirements/encode/index.d.ts +2 -1
  115. package/lib/esm/actions/requirements/encode/index.js +2 -1
  116. package/lib/esm/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
  117. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +147 -0
  118. package/lib/{cjs/actions/requirements/getRequirementsPermit.d.ts → esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
  119. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +46 -0
  120. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
  121. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +70 -0
  122. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +3 -0
  123. package/lib/esm/actions/requirements/generalAdapter/index.js +3 -0
  124. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  125. package/lib/esm/actions/requirements/getRequirementsApproval.js +3 -2
  126. package/lib/esm/actions/requirements/index.d.ts +2 -5
  127. package/lib/esm/actions/requirements/index.js +2 -5
  128. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
  129. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +44 -0
  130. package/lib/{cjs/actions/requirements/getRequirementsAction.d.ts → esm/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
  131. package/lib/esm/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +24 -11
  132. package/lib/esm/actions/signatures/index.d.ts +2 -0
  133. package/lib/esm/actions/signatures/index.js +2 -0
  134. package/lib/esm/actions/vaultV1/deposit.d.ts +6 -8
  135. package/lib/esm/actions/vaultV1/deposit.js +11 -21
  136. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +6 -6
  137. package/lib/esm/actions/vaultV1/migrateToV2.js +12 -20
  138. package/lib/esm/actions/vaultV2/deposit.d.ts +6 -8
  139. package/lib/esm/actions/vaultV2/deposit.js +11 -21
  140. package/lib/esm/addresses.d.ts +2 -2
  141. package/lib/esm/addresses.js +1 -1
  142. package/lib/esm/bundler/actions.d.ts +44 -4
  143. package/lib/esm/bundler/actions.js +77 -4
  144. package/lib/esm/bundler/types.d.ts +6 -0
  145. package/lib/esm/constants.d.ts +2 -2
  146. package/lib/esm/constants.js +2 -2
  147. package/lib/esm/entities/blue/blue.d.ts +58 -33
  148. package/lib/esm/entities/blue/blue.js +173 -127
  149. package/lib/esm/entities/reallocationData.d.ts +12 -12
  150. package/lib/esm/entities/reallocationData.js +18 -18
  151. package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -9
  152. package/lib/esm/entities/vaultV1/vaultV1.js +46 -36
  153. package/lib/esm/entities/vaultV2/vaultV2.d.ts +6 -6
  154. package/lib/esm/entities/vaultV2/vaultV2.js +23 -18
  155. package/lib/esm/errors.d.ts +3 -2
  156. package/lib/esm/errors.js +2 -1
  157. package/lib/esm/helpers/validate.d.ts +2 -2
  158. package/lib/esm/helpers/validate.js +1 -1
  159. package/lib/esm/types/action.d.ts +113 -9
  160. package/lib/esm/types/action.js +75 -4
  161. package/lib/esm/types/error.d.ts +73 -0
  162. package/lib/esm/types/error.js +84 -2
  163. package/lib/esm/types.d.ts +2 -1
  164. package/lib/esm/utils.d.ts +1 -1
  165. package/lib/esm/utils.js +1 -1
  166. package/package.json +6 -6
  167. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
  168. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +0 -71
  169. package/lib/cjs/actions/requirements/getRequirements.js +0 -112
  170. package/lib/cjs/actions/requirements/getRequirementsPermit.js +0 -57
  171. package/lib/cjs/actions/requirements/getRequirementsPermit2.d.ts +0 -63
  172. package/lib/cjs/actions/requirements/getRequirementsPermit2.js +0 -85
  173. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
  174. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +0 -67
  175. package/lib/esm/actions/requirements/getRequirements.js +0 -108
  176. package/lib/esm/actions/requirements/getRequirementsPermit.js +0 -53
  177. package/lib/esm/actions/requirements/getRequirementsPermit2.d.ts +0 -63
  178. package/lib/esm/actions/requirements/getRequirementsPermit2.js +0 -81
@@ -49,7 +49,75 @@ export var BundlerErrors;
49
49
  }
50
50
  }
51
51
  BundlerErrors.UnexpectedAction = UnexpectedAction;
52
+ /**
53
+ * Thrown when a Morpho authorization signature names a forbidden `authorized` account
54
+ * (for example Bundler3 itself), which would grant operator rights to an unintended address.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { BundlerErrors } from "@morpho-org/morpho-sdk";
59
+ *
60
+ * if (error instanceof BundlerErrors.UnexpectedSignature) {
61
+ * // Re-sign the authorization targeting GeneralAdapter1.
62
+ * }
63
+ * ```
64
+ */
65
+ class UnexpectedSignature extends Error {
66
+ /**
67
+ * @param authorized - The forbidden `authorized` address carried by the signature.
68
+ */
69
+ constructor(authorized) {
70
+ super(`unexpected signature authorizing "${authorized}"`);
71
+ }
72
+ }
73
+ BundlerErrors.UnexpectedSignature = UnexpectedSignature;
52
74
  })(BundlerErrors || (BundlerErrors = {}));
75
+ /**
76
+ * Thrown when `buildTx` receives more than one requirement signature of the same kind.
77
+ *
78
+ * A bundled path consumes at most one permit and one authorization signature; passing several of
79
+ * the same kind is ambiguous and would silently drop all but the first, so it is rejected instead.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import { AmbiguousRequirementSignaturesError } from "@morpho-org/morpho-sdk";
84
+ *
85
+ * if (error instanceof AmbiguousRequirementSignaturesError) {
86
+ * // Pass a single permit (and at most one authorization) signature to buildTx.
87
+ * }
88
+ * ```
89
+ */
90
+ export class AmbiguousRequirementSignaturesError extends Error {
91
+ /**
92
+ * @param kind - The over-supplied signature kind (`"permit"` or `"authorization"`).
93
+ * @param count - How many signatures of that kind were received.
94
+ */
95
+ constructor(kind, count) {
96
+ super(`Expected at most one ${kind} signature but received ${count}. Pass a single ${kind} signature to buildTx.`);
97
+ }
98
+ }
99
+ /**
100
+ * Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume
101
+ * (for example an authorization signature on a plain supply path). Surfacing it prevents a signed
102
+ * authorization or permit from being silently ignored.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { UnexpectedRequirementSignatureError } from "@morpho-org/morpho-sdk";
107
+ *
108
+ * if (error instanceof UnexpectedRequirementSignatureError) {
109
+ * // Remove the signature this operation does not use from the buildTx array.
110
+ * }
111
+ * ```
112
+ */
113
+ export class UnexpectedRequirementSignatureError extends Error {
114
+ /**
115
+ * @param kind - The unexpected signature kind (`"permit"` or `"authorization"`).
116
+ */
117
+ constructor(kind) {
118
+ super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
119
+ }
120
+ }
53
121
  /** Thrown when an asset amount is required to be positive but is zero or negative. */
54
122
  export class NonPositiveAssetAmountError extends Error {
55
123
  constructor(origin) {
@@ -92,6 +160,20 @@ export class ApprovalAmountLessThanSpendAmountError extends Error {
92
160
  super("Approval amount is less than spend amount");
93
161
  }
94
162
  }
163
+ /** Thrown when a requirement encoder targets an unsupported spender. */
164
+ export class UnsupportedErc20ApprovalSpenderError extends Error {
165
+ constructor(params) {
166
+ const supported = (params.supportedSpenders ?? [
167
+ params.generalAdapter1,
168
+ params.permit2,
169
+ params.midnight,
170
+ params.midnightBundles,
171
+ ])
172
+ .filter((address) => address != null)
173
+ .join('", "');
174
+ super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
175
+ }
176
+ }
95
177
  /** Thrown when a slippage tolerance is negative. */
96
178
  export class NegativeSlippageToleranceError extends Error {
97
179
  constructor(slippageTolerance) {
@@ -119,13 +201,13 @@ export class EmptyDeallocationsError extends Error {
119
201
  /** Thrown when a deposit's amount differs from the amount the supplied permit / permit2 signature was issued for. */
120
202
  export class DepositAmountMismatchError extends Error {
121
203
  constructor(depositAmount, signatureAmount) {
122
- super(`Deposit amount ${depositAmount} does not match requirement signature amount ${signatureAmount}`);
204
+ super(`Deposit amount "${depositAmount}" does not match requirement signature amount "${signatureAmount}"`);
123
205
  }
124
206
  }
125
207
  /** Thrown when a deposit's asset differs from the asset the supplied permit / permit2 signature was issued for. */
126
208
  export class DepositAssetMismatchError extends Error {
127
209
  constructor(depositAsset, signatureAsset) {
128
- super(`Deposit asset ${depositAsset} does not match requirement signature asset ${signatureAsset}`);
210
+ super(`Deposit asset "${depositAsset}" does not match requirement signature asset "${signatureAsset}"`);
129
211
  }
130
212
  }
131
213
  /** Thrown when a `permit2` requirement signature is missing the `expiration` field. */
@@ -1,3 +1,4 @@
1
- export type { BigIntish, ChainMetadata, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams, IPermit2Allowance, Loadable, MarketId, MaxBorrowOptions, MaxPositionCapacities, MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
1
+ export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams, IPermit2Allowance, Loadable, MarketId, MaxBorrowOptions, MaxPositionCapacities, MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
2
2
  export type { DeploylessFetchParameters, FetchParameters, } from "@morpho-org/blue-sdk-viem";
3
+ export type { ChainMetadata } from "@morpho-org/morpho-ts";
3
4
  export * from "./types/index.js";
@@ -1,6 +1,6 @@
1
1
  export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
2
2
  export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
3
- export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
3
+ export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
4
4
  export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
5
5
  export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
6
6
  export { computeReallocations } from "./helpers/computeReallocations.js";
package/lib/esm/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
2
- export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
2
+ export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
3
3
  export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
4
4
  export { computeReallocations } from "./helpers/computeReallocations.js";
5
5
  export { addTransactionMetadata } from "./helpers/metadata.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/morpho-sdk",
3
3
  "description": "Abstraction layer for Morpho's complexity.",
4
- "version": "4.1.0",
4
+ "version": "5.0.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Foulks-Plb <https://x.com/FoulkPlb>"
@@ -137,9 +137,9 @@
137
137
  ],
138
138
  "dependencies": {
139
139
  "zod": "^4.4.3",
140
- "@morpho-org/blue-sdk": "^6.2.0",
141
- "@morpho-org/morpho-ts": "^2.6.0",
142
- "@morpho-org/blue-sdk-viem": "^5.1.1"
140
+ "@morpho-org/blue-sdk": "^6.3.0",
141
+ "@morpho-org/blue-sdk-viem": "^5.1.2",
142
+ "@morpho-org/morpho-ts": "^2.7.0"
143
143
  },
144
144
  "peerDependencies": {
145
145
  "viem": "^2.0.0"
@@ -148,8 +148,8 @@
148
148
  "dotenv": "^17.4.2",
149
149
  "fast-check": "^4.8.0",
150
150
  "typescript": "^6.0.3",
151
- "viem": "2.52.2",
152
- "vitest": "^4.1.8",
151
+ "viem": "^2.54.2",
152
+ "vitest": "^4.1.9",
153
153
  "@morpho-org/bundler-sdk-viem": "^5.0.3",
154
154
  "@morpho-org/simulation-sdk": "^4.0.3",
155
155
  "@morpho-org/test": "^2.8.1"
@@ -1,37 +0,0 @@
1
- import type { Client } from "viem";
2
- import { type Address } from "viem";
3
- import { type MorphoAuthorizationAction, type Transaction } from "../../types/index.js";
4
- /**
5
- * Resolves whether `GeneralAdapter1` needs Morpho authorization for the given user, and returns
6
- * the `setAuthorization(generalAdapter1, true)` transaction when it does.
7
- *
8
- * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
9
- * any bundled Blue path that operates on behalf of the user (`borrow`,
10
- * `supplyCollateralBorrow`, `repayWithdrawCollateral`).
11
- *
12
- * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
13
- * @param params.chainId - Target chain id (used to resolve Morpho and `GeneralAdapter1`).
14
- * @param params.userAddress - The user that must authorize `GeneralAdapter1`.
15
- * @returns A deep-frozen `Transaction<MorphoAuthorizationAction>`, or `null` when authorization
16
- * is already in place.
17
- * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
18
- * @example
19
- * ```ts
20
- * import { createPublicClient, http } from "viem";
21
- * import { mainnet } from "viem/chains";
22
- * import { getMorphoAuthorizationRequirement } from "@morpho-org/morpho-sdk";
23
- *
24
- * const client = createPublicClient({ chain: mainnet, transport: http() });
25
- * const tx = await getMorphoAuthorizationRequirement({
26
- * viemClient: client,
27
- * chainId: 1,
28
- * userAddress: borrower,
29
- * });
30
- * // tx is null when already authorized, otherwise satisfies Readonly<Transaction<MorphoAuthorizationAction>>
31
- * ```
32
- */
33
- export declare const getMorphoAuthorizationRequirement: (params: {
34
- viemClient: Client;
35
- chainId: number;
36
- userAddress: Address;
37
- }) => Promise<Readonly<Transaction<MorphoAuthorizationAction>> | null>;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMorphoAuthorizationRequirement = void 0;
4
- const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
- const viem_1 = require("viem");
8
- const index_js_1 = require("../../types/index.js");
9
- /**
10
- * Resolves whether `GeneralAdapter1` needs Morpho authorization for the given user, and returns
11
- * the `setAuthorization(generalAdapter1, true)` transaction when it does.
12
- *
13
- * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
14
- * any bundled Blue path that operates on behalf of the user (`borrow`,
15
- * `supplyCollateralBorrow`, `repayWithdrawCollateral`).
16
- *
17
- * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
18
- * @param params.chainId - Target chain id (used to resolve Morpho and `GeneralAdapter1`).
19
- * @param params.userAddress - The user that must authorize `GeneralAdapter1`.
20
- * @returns A deep-frozen `Transaction<MorphoAuthorizationAction>`, or `null` when authorization
21
- * is already in place.
22
- * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
23
- * @example
24
- * ```ts
25
- * import { createPublicClient, http } from "viem";
26
- * import { mainnet } from "viem/chains";
27
- * import { getMorphoAuthorizationRequirement } from "@morpho-org/morpho-sdk";
28
- *
29
- * const client = createPublicClient({ chain: mainnet, transport: http() });
30
- * const tx = await getMorphoAuthorizationRequirement({
31
- * viemClient: client,
32
- * chainId: 1,
33
- * userAddress: borrower,
34
- * });
35
- * // tx is null when already authorized, otherwise satisfies Readonly<Transaction<MorphoAuthorizationAction>>
36
- * ```
37
- */
38
- const getMorphoAuthorizationRequirement = async (params) => {
39
- const { viemClient, chainId, userAddress } = params;
40
- if (viemClient.chain?.id !== chainId) {
41
- throw new index_js_1.ChainIdMismatchError(viemClient.chain?.id, chainId);
42
- }
43
- const { morpho, bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
44
- const pc = viemClient.extend(viem_1.publicActions);
45
- const isAuthorized = await pc.readContract({
46
- address: morpho,
47
- abi: blue_sdk_viem_1.blueAbi,
48
- functionName: "isAuthorized",
49
- args: [userAddress, generalAdapter1],
50
- });
51
- if (isAuthorized) {
52
- return null;
53
- }
54
- return (0, morpho_ts_1.deepFreeze)({
55
- to: morpho,
56
- data: (0, viem_1.encodeFunctionData)({
57
- abi: blue_sdk_viem_1.blueAbi,
58
- functionName: "setAuthorization",
59
- args: [generalAdapter1, true],
60
- }),
61
- value: 0n,
62
- action: {
63
- type: "morphoAuthorization",
64
- args: {
65
- authorized: generalAdapter1,
66
- isAuthorized: true,
67
- },
68
- },
69
- });
70
- };
71
- exports.getMorphoAuthorizationRequirement = getMorphoAuthorizationRequirement;
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRequirements = void 0;
4
- const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
- const index_js_1 = require("../../types/index.js");
8
- const getRequirementsApproval_js_1 = require("./getRequirementsApproval.js");
9
- const getRequirementsPermit_js_1 = require("./getRequirementsPermit.js");
10
- const getRequirementsPermit2_js_1 = require("./getRequirementsPermit2.js");
11
- /**
12
- * Resolves the approval requirements an integrator must satisfy before a Morpho bundle pulls
13
- * tokens through `GeneralAdapter1`.
14
- *
15
- * Reads the user's current `holding` (allowances + nonces) from the chain, then picks one of
16
- * three flows:
17
- *
18
- * 1. **`supportSignature: false`** — classic ERC-20 `approve` transaction (or no-op when the
19
- * allowance is already large enough).
20
- * 2. **`supportSignature: true` + EIP-2612 supported + `useSimplePermit`** — single permit
21
- * signature against the token itself. DAI is excluded from this branch (its non-standard
22
- * permit signature is incompatible) and falls through to Permit2 even with
23
- * `useSimplePermit: true`.
24
- * 3. **`supportSignature: true`, default** — Permit2 flow: classic approval to the Permit2
25
- * contract (if needed), followed by a Permit2 signature against `GeneralAdapter1`.
26
- *
27
- * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
28
- * @param params - Requirement resolution parameters.
29
- * @param params.address - ERC-20 token address.
30
- * @param params.chainId - Chain id; must match `viemClient.chain.id`.
31
- * @param params.args.amount - Required token amount. Returns `[]` when zero.
32
- * @param params.args.from - Account that will grant the approval.
33
- * @param params.supportSignature - Whether the integrator can collect a signature; controls
34
- * permit / permit2 vs. classic approval.
35
- * @param params.supportDeployless - Whether to fetch holdings via deployless multicall.
36
- * @param params.useSimplePermit - When `supportSignature` is `true`, prefer EIP-2612 permit if
37
- * the token supports it.
38
- * @returns Promise resolving to an array of either deep-frozen approval transactions or
39
- * `Requirement` objects (signature requirements with a `sign()` method). Empty when the
40
- * existing allowance already covers `amount`.
41
- * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`. No other typed
42
- * error is reachable through this entry point: the values passed into
43
- * `getRequirementsApproval` always satisfy `approvalAmount >= spendAmount` (direct path uses
44
- * `approvalAmount === spendAmount === amount`; Permit2 path uses `MAX_UINT_160`), so
45
- * `ApprovalAmountLessThanSpendAmountError` cannot fire from here.
46
- * @example
47
- * ```ts
48
- * import { createPublicClient, http } from "viem";
49
- * import { mainnet } from "viem/chains";
50
- * import { getRequirements } from "@morpho-org/morpho-sdk";
51
- *
52
- * const client = createPublicClient({ chain: mainnet, transport: http() });
53
- * const requirements = await getRequirements(client, {
54
- * address: USDC,
55
- * chainId: 1,
56
- * supportSignature: true,
57
- * args: { amount: 1_000_000n, from: user },
58
- * });
59
- * // requirements satisfies (Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]
60
- * ```
61
- */
62
- const getRequirements = async (viemClient, params) => {
63
- const { address, chainId, supportSignature, args: { amount, from }, } = params;
64
- if (viemClient.chain?.id !== chainId) {
65
- throw new index_js_1.ChainIdMismatchError(viemClient.chain?.id, chainId);
66
- }
67
- if (amount === 0n) {
68
- return [];
69
- }
70
- const { permit2, dai, bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
71
- const { erc20Allowances, erc2612Nonce, permit2BundlerAllowance } = await (0, blue_sdk_viem_1.fetchHolding)(from, address, viemClient, {
72
- deployless: params.supportDeployless,
73
- });
74
- if (supportSignature) {
75
- const { useSimplePermit } = params;
76
- const supportSimplePermit = (0, morpho_ts_1.isDefined)(erc2612Nonce) && address !== dai;
77
- if (supportSimplePermit && useSimplePermit) {
78
- return await (0, getRequirementsPermit_js_1.getRequirementsPermit)(viemClient, {
79
- token: address,
80
- chainId,
81
- args: { amount },
82
- allowancesGeneralAdapter: erc20Allowances["bundler3.generalAdapter1"],
83
- nonce: erc2612Nonce,
84
- supportDeployless: params.supportDeployless,
85
- });
86
- }
87
- if (permit2) {
88
- return (0, getRequirementsPermit2_js_1.getRequirementsPermit2)({
89
- address,
90
- chainId,
91
- permit2,
92
- args: { amount },
93
- allowancesGeneralAdapter: erc20Allowances["bundler3.generalAdapter1"],
94
- allowancesPermit2: erc20Allowances.permit2,
95
- allowanceGeneralAdapterPermit2: permit2BundlerAllowance.amount,
96
- allowanceGeneralAdapterExpiration: permit2BundlerAllowance.expiration,
97
- nonce: permit2BundlerAllowance.nonce,
98
- });
99
- }
100
- }
101
- return (0, getRequirementsApproval_js_1.getRequirementsApproval)({
102
- address,
103
- chainId,
104
- args: {
105
- spendAmount: amount,
106
- approvalAmount: amount,
107
- spender: generalAdapter1,
108
- },
109
- allowances: erc20Allowances["bundler3.generalAdapter1"],
110
- });
111
- };
112
- exports.getRequirements = getRequirements;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRequirementsPermit = void 0;
4
- const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const index_js_1 = require("./encode/index.js");
6
- /**
7
- * Computes the EIP-2612 permit `Requirement` an integrator must sign so that `GeneralAdapter1`
8
- * can pull `amount` of `token`.
9
- *
10
- * Returns an empty array when the existing allowance for `GeneralAdapter1` already covers
11
- * `amount`.
12
- *
13
- * @param viemClient - Connected viem `Client` (used by the returned `Requirement.sign()`).
14
- * @param params.token - ERC-20 token address (must support EIP-2612).
15
- * @param params.chainId - The chain the bundle targets.
16
- * @param params.args.amount - Required token amount.
17
- * @param params.allowancesGeneralAdapter - The user's current allowance of `token` for
18
- * `GeneralAdapter1`.
19
- * @param params.nonce - The user's current EIP-2612 nonce on `token`.
20
- * @param params.supportDeployless - Whether to fetch token metadata via deployless multicall.
21
- * @returns A single-element array containing the `Requirement` to sign, or an empty array when
22
- * the existing allowance already covers `amount`.
23
- * @example
24
- * ```ts
25
- * import { createWalletClient, http } from "viem";
26
- * import { mainnet } from "viem/chains";
27
- * import { getRequirementsPermit } from "@morpho-org/morpho-sdk";
28
- *
29
- * const client = createWalletClient({ chain: mainnet, transport: http() });
30
- * const reqs = await getRequirementsPermit(client, {
31
- * token: USDC, // an ERC-2612-compatible token; DAI is excluded by getRequirements
32
- * chainId: 1,
33
- * args: { amount: 1_000_000n },
34
- * allowancesGeneralAdapter: 0n,
35
- * nonce: 0n,
36
- * });
37
- * // reqs satisfies Requirement[]
38
- * ```
39
- */
40
- const getRequirementsPermit = async (viemClient, params) => {
41
- const { token, chainId, args: { amount }, allowancesGeneralAdapter, nonce, supportDeployless, } = params;
42
- const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
43
- if (allowancesGeneralAdapter < amount) {
44
- return [
45
- await (0, index_js_1.encodeErc20Permit)(viemClient, {
46
- token,
47
- spender: generalAdapter1,
48
- amount,
49
- chainId,
50
- nonce,
51
- supportDeployless,
52
- }),
53
- ];
54
- }
55
- return [];
56
- };
57
- exports.getRequirementsPermit = getRequirementsPermit;
@@ -1,63 +0,0 @@
1
- import { type Address } from "@morpho-org/blue-sdk";
2
- import type { ERC20ApprovalAction, Requirement, Transaction } from "../../types/index.js";
3
- /**
4
- * Computes the Permit2 prerequisites for `GeneralAdapter1` to pull `amount` of `address`.
5
- *
6
- * Returns an empty array when the direct adapter allowance already covers `amount`. Otherwise
7
- * emits two ordered prerequisites:
8
- *
9
- * 1. A classic ERC-20 approval to the Permit2 contract (infinite, if not already in place).
10
- * 2. A Permit2 `Requirement` signed against `GeneralAdapter1` (skipped when the existing
11
- * Permit2-managed allowance covers `amount` and is not about to expire within four hours).
12
- *
13
- * @param params.address - ERC-20 token address.
14
- * @param params.chainId - The chain the bundle targets.
15
- * @param params.permit2 - The Permit2 contract address for the chain.
16
- * @param params.args.amount - Required token amount.
17
- * @param params.allowancesPermit2 - The user's current allowance of `address` for the Permit2
18
- * contract.
19
- * @param params.allowancesGeneralAdapter - The user's current direct allowance of `address` for
20
- * `GeneralAdapter1` (separate from the Permit2-managed allowance).
21
- * @param params.allowanceGeneralAdapterPermit2 - The Permit2-managed allowance for
22
- * `GeneralAdapter1` to spend `address`.
23
- * @param params.allowanceGeneralAdapterExpiration - Expiration timestamp of the Permit2-managed
24
- * allowance.
25
- * @param params.nonce - The user's current Permit2 nonce for `(address, GeneralAdapter1)`.
26
- * @returns Ordered list of approval transactions and/or `Requirement` objects to satisfy before
27
- * bundling.
28
- * @throws {ApprovalAmountLessThanSpendAmountError} from the inner approval helper when its
29
- * bookkeeping invariants break (should not happen with the values this function passes).
30
- * @example
31
- * ```ts
32
- * import { getChainAddresses } from "@morpho-org/blue-sdk";
33
- * import { getRequirementsPermit2 } from "@morpho-org/morpho-sdk";
34
- *
35
- * const { permit2 } = getChainAddresses(1);
36
- * if (!permit2) throw new Error("Permit2 not configured for this chain");
37
- * const requirements = getRequirementsPermit2({
38
- * address: USDC,
39
- * chainId: 1,
40
- * permit2,
41
- * args: { amount: 1_000_000n },
42
- * allowancesPermit2: 0n,
43
- * allowancesGeneralAdapter: 0n,
44
- * allowanceGeneralAdapterPermit2: 0n,
45
- * allowanceGeneralAdapterExpiration: 0n,
46
- * nonce: 0n,
47
- * });
48
- * // requirements satisfies (Readonly<Transaction<ERC20ApprovalAction> | Requirement>)[]
49
- * ```
50
- */
51
- export declare const getRequirementsPermit2: (params: {
52
- address: Address;
53
- chainId: number;
54
- permit2: Address;
55
- args: {
56
- amount: bigint;
57
- };
58
- allowancesPermit2: bigint;
59
- allowancesGeneralAdapter: bigint;
60
- allowanceGeneralAdapterPermit2: bigint;
61
- allowanceGeneralAdapterExpiration: bigint;
62
- nonce: bigint;
63
- }) => Readonly<Transaction<ERC20ApprovalAction> | Requirement>[];
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRequirementsPermit2 = void 0;
4
- const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
- const encodeErc20Permit2_js_1 = require("./encode/encodeErc20Permit2.js");
7
- const getRequirementsApproval_js_1 = require("./getRequirementsApproval.js");
8
- /**
9
- * Computes the Permit2 prerequisites for `GeneralAdapter1` to pull `amount` of `address`.
10
- *
11
- * Returns an empty array when the direct adapter allowance already covers `amount`. Otherwise
12
- * emits two ordered prerequisites:
13
- *
14
- * 1. A classic ERC-20 approval to the Permit2 contract (infinite, if not already in place).
15
- * 2. A Permit2 `Requirement` signed against `GeneralAdapter1` (skipped when the existing
16
- * Permit2-managed allowance covers `amount` and is not about to expire within four hours).
17
- *
18
- * @param params.address - ERC-20 token address.
19
- * @param params.chainId - The chain the bundle targets.
20
- * @param params.permit2 - The Permit2 contract address for the chain.
21
- * @param params.args.amount - Required token amount.
22
- * @param params.allowancesPermit2 - The user's current allowance of `address` for the Permit2
23
- * contract.
24
- * @param params.allowancesGeneralAdapter - The user's current direct allowance of `address` for
25
- * `GeneralAdapter1` (separate from the Permit2-managed allowance).
26
- * @param params.allowanceGeneralAdapterPermit2 - The Permit2-managed allowance for
27
- * `GeneralAdapter1` to spend `address`.
28
- * @param params.allowanceGeneralAdapterExpiration - Expiration timestamp of the Permit2-managed
29
- * allowance.
30
- * @param params.nonce - The user's current Permit2 nonce for `(address, GeneralAdapter1)`.
31
- * @returns Ordered list of approval transactions and/or `Requirement` objects to satisfy before
32
- * bundling.
33
- * @throws {ApprovalAmountLessThanSpendAmountError} from the inner approval helper when its
34
- * bookkeeping invariants break (should not happen with the values this function passes).
35
- * @example
36
- * ```ts
37
- * import { getChainAddresses } from "@morpho-org/blue-sdk";
38
- * import { getRequirementsPermit2 } from "@morpho-org/morpho-sdk";
39
- *
40
- * const { permit2 } = getChainAddresses(1);
41
- * if (!permit2) throw new Error("Permit2 not configured for this chain");
42
- * const requirements = getRequirementsPermit2({
43
- * address: USDC,
44
- * chainId: 1,
45
- * permit2,
46
- * args: { amount: 1_000_000n },
47
- * allowancesPermit2: 0n,
48
- * allowancesGeneralAdapter: 0n,
49
- * allowanceGeneralAdapterPermit2: 0n,
50
- * allowanceGeneralAdapterExpiration: 0n,
51
- * nonce: 0n,
52
- * });
53
- * // requirements satisfies (Readonly<Transaction<ERC20ApprovalAction> | Requirement>)[]
54
- * ```
55
- */
56
- const getRequirementsPermit2 = (params) => {
57
- const { address, chainId, permit2, args: { amount }, allowancesPermit2, allowancesGeneralAdapter, allowanceGeneralAdapterPermit2, allowanceGeneralAdapterExpiration, nonce, } = params;
58
- if (allowancesGeneralAdapter >= amount) {
59
- return [];
60
- }
61
- const requirements = [];
62
- const approvalRequirements = (0, getRequirementsApproval_js_1.getRequirementsApproval)({
63
- address,
64
- chainId,
65
- args: {
66
- approvalAmount: blue_sdk_1.MathLib.MAX_UINT_160, // Always approve infinite.
67
- spendAmount: amount,
68
- spender: permit2,
69
- },
70
- allowances: allowancesPermit2,
71
- });
72
- requirements.push(...approvalRequirements);
73
- if (allowanceGeneralAdapterPermit2 < amount ||
74
- allowanceGeneralAdapterExpiration < morpho_ts_1.Time.timestamp() + morpho_ts_1.Time.s.from.h(4n)) {
75
- requirements.push((0, encodeErc20Permit2_js_1.encodeErc20Permit2)({
76
- token: address,
77
- amount,
78
- chainId,
79
- nonce,
80
- expiration: blue_sdk_1.MathLib.MAX_UINT_48, // Always approve indefinitely.
81
- }));
82
- }
83
- return requirements;
84
- };
85
- exports.getRequirementsPermit2 = getRequirementsPermit2;
@@ -1,37 +0,0 @@
1
- import type { Client } from "viem";
2
- import { type Address } from "viem";
3
- import { type MorphoAuthorizationAction, type Transaction } from "../../types/index.js";
4
- /**
5
- * Resolves whether `GeneralAdapter1` needs Morpho authorization for the given user, and returns
6
- * the `setAuthorization(generalAdapter1, true)` transaction when it does.
7
- *
8
- * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
9
- * any bundled Blue path that operates on behalf of the user (`borrow`,
10
- * `supplyCollateralBorrow`, `repayWithdrawCollateral`).
11
- *
12
- * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
13
- * @param params.chainId - Target chain id (used to resolve Morpho and `GeneralAdapter1`).
14
- * @param params.userAddress - The user that must authorize `GeneralAdapter1`.
15
- * @returns A deep-frozen `Transaction<MorphoAuthorizationAction>`, or `null` when authorization
16
- * is already in place.
17
- * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
18
- * @example
19
- * ```ts
20
- * import { createPublicClient, http } from "viem";
21
- * import { mainnet } from "viem/chains";
22
- * import { getMorphoAuthorizationRequirement } from "@morpho-org/morpho-sdk";
23
- *
24
- * const client = createPublicClient({ chain: mainnet, transport: http() });
25
- * const tx = await getMorphoAuthorizationRequirement({
26
- * viemClient: client,
27
- * chainId: 1,
28
- * userAddress: borrower,
29
- * });
30
- * // tx is null when already authorized, otherwise satisfies Readonly<Transaction<MorphoAuthorizationAction>>
31
- * ```
32
- */
33
- export declare const getMorphoAuthorizationRequirement: (params: {
34
- viemClient: Client;
35
- chainId: number;
36
- userAddress: Address;
37
- }) => Promise<Readonly<Transaction<MorphoAuthorizationAction>> | null>;