@morpho-org/morpho-sdk 5.4.1 → 5.5.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 (84) hide show
  1. package/README.md +15 -1
  2. package/lib/cjs/abis.d.ts +313 -0
  3. package/lib/cjs/abis.js +167 -1
  4. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  5. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
  6. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  7. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
  8. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  9. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  10. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  11. package/lib/cjs/actions/requirements/getRequirementsApproval.js +3 -2
  12. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  13. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
  14. package/lib/cjs/actions/signatures/index.d.ts +1 -0
  15. package/lib/cjs/actions/signatures/index.js +1 -0
  16. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
  17. package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
  18. package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
  19. package/lib/cjs/actions/vaultV1/index.js +1 -0
  20. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
  21. package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
  22. package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
  23. package/lib/cjs/actions/vaultV2/index.js +1 -0
  24. package/lib/cjs/bundler/actions.d.ts +1 -2
  25. package/lib/cjs/bundler/actions.js +1 -2
  26. package/lib/cjs/entities/blue/blue.d.ts +8 -8
  27. package/lib/cjs/entities/reallocationData.d.ts +1 -2
  28. package/lib/cjs/entities/reallocationData.js +1 -2
  29. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
  30. package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
  31. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
  32. package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
  33. package/lib/cjs/helpers/index.d.ts +1 -0
  34. package/lib/cjs/helpers/index.js +3 -1
  35. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  36. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
  37. package/lib/cjs/helpers/validate.d.ts +1 -1
  38. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  39. package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
  40. package/lib/cjs/types/action.d.ts +21 -1
  41. package/lib/cjs/types/error.d.ts +139 -0
  42. package/lib/cjs/types/error.js +189 -2
  43. package/lib/esm/abis.d.ts +313 -0
  44. package/lib/esm/abis.js +166 -0
  45. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  46. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
  47. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  48. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
  49. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  50. package/lib/esm/actions/requirements/encode/index.js +1 -0
  51. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  52. package/lib/esm/actions/requirements/getRequirementsApproval.js +3 -2
  53. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  54. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
  55. package/lib/esm/actions/signatures/index.d.ts +1 -0
  56. package/lib/esm/actions/signatures/index.js +1 -0
  57. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
  58. package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
  59. package/lib/esm/actions/vaultV1/index.d.ts +1 -0
  60. package/lib/esm/actions/vaultV1/index.js +1 -0
  61. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
  62. package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
  63. package/lib/esm/actions/vaultV2/index.d.ts +1 -0
  64. package/lib/esm/actions/vaultV2/index.js +1 -0
  65. package/lib/esm/bundler/actions.d.ts +1 -2
  66. package/lib/esm/bundler/actions.js +1 -2
  67. package/lib/esm/entities/blue/blue.d.ts +5 -5
  68. package/lib/esm/entities/reallocationData.d.ts +1 -2
  69. package/lib/esm/entities/reallocationData.js +1 -2
  70. package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
  71. package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
  72. package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
  73. package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
  74. package/lib/esm/helpers/index.d.ts +1 -0
  75. package/lib/esm/helpers/index.js +1 -0
  76. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  77. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
  78. package/lib/esm/helpers/validate.d.ts +1 -1
  79. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  80. package/lib/esm/helpers/validateRequirementSpender.js +2 -1
  81. package/lib/esm/types/action.d.ts +21 -1
  82. package/lib/esm/types/error.d.ts +139 -0
  83. package/lib/esm/types/error.js +175 -0
  84. package/package.json +9 -11
@@ -44,6 +44,145 @@ export declare class NonPositiveInputError extends Error {
44
44
  */
45
45
  constructor(field: string, value: bigint);
46
46
  }
47
+ /** Thrown when an in-kind redemption does not include any Morpho Blue market parameters. */
48
+ export declare class EmptyMarketParamsListError extends Error {
49
+ constructor();
50
+ }
51
+ /** Thrown when an in-kind redemption deadline has already passed. */
52
+ export declare class ExpiredDeadlineError extends Error {
53
+ readonly deadline: bigint;
54
+ readonly timestamp: bigint;
55
+ /**
56
+ * @param deadline - Expired deadline supplied by the caller.
57
+ * @param timestamp - Current timestamp used for validation.
58
+ */
59
+ constructor(deadline: bigint, timestamp: bigint);
60
+ }
61
+ /** Thrown when Vault V2 in-kind redemption is attempted with anything other than one adapter. */
62
+ export declare class InKindRedeemRequiresSingleAdapterError extends Error {
63
+ readonly vault: Address;
64
+ readonly adapters: number;
65
+ /**
66
+ * @param vault - Vault V2 address.
67
+ * @param adapters - Number of adapters in the supplied vault snapshot.
68
+ */
69
+ constructor(vault: Address, adapters: number);
70
+ }
71
+ /** Thrown when a requested in-kind redemption adapter is not part of the Vault V2 snapshot. */
72
+ export declare class AdapterNotPartOfVaultError extends Error {
73
+ readonly vault: Address;
74
+ readonly adapter: Address;
75
+ /**
76
+ * @param vault - Vault V2 address.
77
+ * @param adapter - Adapter rejected by the vault snapshot.
78
+ */
79
+ constructor(vault: Address, adapter: Address);
80
+ }
81
+ /** Thrown when the Vault V2 adapter cannot expose MorphoMarketV1AdapterV2 market shares. */
82
+ export declare class UnsupportedInKindAdapterError extends Error {
83
+ readonly adapter: Address;
84
+ /**
85
+ * @param adapter - Unsupported Vault V2 adapter address.
86
+ */
87
+ constructor(adapter: Address);
88
+ }
89
+ /** Thrown when a Vault V2 in-kind redemption rounds to no deallocated assets. */
90
+ export declare class InKindRedeemZeroDeallocationError extends Error {
91
+ /**
92
+ * @param params - Values that caused the exit to round to zero deallocated assets.
93
+ * @param params.vault - Vault V2 address with no idle assets available for the exit.
94
+ * @param params.amount - Positive penalty-inclusive amount requested by the caller.
95
+ * @param params.penalty - WAD-scaled force-deallocation penalty applied by the adapter.
96
+ */
97
+ readonly vault: Address;
98
+ readonly amount: bigint;
99
+ readonly penalty: bigint;
100
+ constructor(params: {
101
+ readonly vault: Address;
102
+ readonly amount: bigint;
103
+ readonly penalty: bigint;
104
+ });
105
+ }
106
+ /** Thrown when the ordered market list cannot cover the requested in-kind redemption. */
107
+ export declare class InKindRedeemCoverageError extends Error {
108
+ /**
109
+ * @param params - Coverage values used to explain the rejected exit.
110
+ * @param params.required - Assets that must be deallocated from listed markets.
111
+ * @param params.covered - Assets covered by the supplied market list.
112
+ * @param params.maxExitAssets - Largest penalty-inclusive exit supported by the list.
113
+ */
114
+ readonly required: bigint;
115
+ readonly covered: bigint;
116
+ readonly maxExitAssets: bigint;
117
+ constructor(params: {
118
+ readonly required: bigint;
119
+ readonly covered: bigint;
120
+ readonly maxExitAssets: bigint;
121
+ });
122
+ }
123
+ /** Thrown when Morpho Blue lacks the physical loan-token balance needed during an exit callback. */
124
+ export declare class InsufficientBlueBalanceForInKindRedeemError extends Error {
125
+ /**
126
+ * @param params - Morpho Blue balance values used to explain the rejected exit.
127
+ * @param params.asset - Loan token required by the exit.
128
+ * @param params.available - Current token balance held by Morpho Blue.
129
+ * @param params.required - Peak token balance required by the exit.
130
+ */
131
+ readonly asset: Address;
132
+ readonly available: bigint;
133
+ readonly required: bigint;
134
+ constructor(params: {
135
+ readonly asset: Address;
136
+ readonly available: bigint;
137
+ readonly required: bigint;
138
+ });
139
+ }
140
+ /** Thrown when a MetaMorpho vault is connected to a different Morpho deployment. */
141
+ export declare class VaultMorphoMismatchError extends Error {
142
+ /**
143
+ * @param params - Vault and Morpho addresses used to explain the mismatch.
144
+ * @param params.vault - MetaMorpho vault address.
145
+ * @param params.expected - Morpho Blue address expected for the target chain.
146
+ * @param params.actual - Morpho address returned by the vault.
147
+ */
148
+ readonly vault: Address;
149
+ readonly expected: Address;
150
+ readonly actual: Address;
151
+ constructor(params: {
152
+ readonly vault: Address;
153
+ readonly expected: Address;
154
+ readonly actual: Address;
155
+ });
156
+ }
157
+ /** Thrown when a Vault V1 is Morpho Blue's fee recipient and cannot safely redeem in kind. */
158
+ export declare class VaultIsBlueFeeRecipientError extends Error {
159
+ readonly vault: Address;
160
+ readonly blue: Address;
161
+ /**
162
+ * @param vault - Unsupported Vault V1 address.
163
+ * @param blue - Morpho Blue deployment whose fees accrue to the vault.
164
+ */
165
+ constructor(vault: Address, blue: Address);
166
+ }
167
+ /** Thrown when a vault-shares requirement cannot be safely encoded as an ERC-2612 permit. */
168
+ export declare class VaultExitBundlesV1PermitMismatchError extends Error {
169
+ /**
170
+ * @param params - Permit mismatch values used to explain the rejection.
171
+ * @param params.field - Permit field that does not match the exit.
172
+ * @param params.expected - Value required by the exit.
173
+ * @param params.actual - Value supplied by the signature.
174
+ * @param params.cause - Original parser failure when signature decoding is wrapped.
175
+ */
176
+ readonly field: "type" | "asset" | "signature";
177
+ readonly expected: string;
178
+ readonly actual: string;
179
+ constructor(params: {
180
+ readonly field: "type" | "asset" | "signature";
181
+ readonly expected: string;
182
+ readonly actual: string;
183
+ readonly cause?: unknown;
184
+ });
185
+ }
47
186
  /** @deprecated Use {@link NonPositiveInputError}. */
48
187
  export declare const NonPositiveAssetAmountError: typeof NonPositiveInputError;
49
188
  /** @deprecated Use {@link NonPositiveInputError}. */
@@ -53,6 +53,181 @@ export class NonPositiveInputError extends Error {
53
53
  this.name = "NonPositiveInputError";
54
54
  }
55
55
  }
56
+ /** Thrown when an in-kind redemption does not include any Morpho Blue market parameters. */
57
+ export class EmptyMarketParamsListError extends Error {
58
+ constructor() {
59
+ super("Market parameters list cannot be empty. Include enough ordered vault markets to cover the in-kind redemption.");
60
+ this.name = "EmptyMarketParamsListError";
61
+ }
62
+ }
63
+ /** Thrown when an in-kind redemption deadline has already passed. */
64
+ export class ExpiredDeadlineError extends Error {
65
+ deadline;
66
+ timestamp;
67
+ /**
68
+ * @param deadline - Expired deadline supplied by the caller.
69
+ * @param timestamp - Current timestamp used for validation.
70
+ */
71
+ constructor(deadline, timestamp) {
72
+ super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the exit.`);
73
+ this.deadline = deadline;
74
+ this.timestamp = timestamp;
75
+ this.name = "ExpiredDeadlineError";
76
+ }
77
+ }
78
+ /** Thrown when Vault V2 in-kind redemption is attempted with anything other than one adapter. */
79
+ export class InKindRedeemRequiresSingleAdapterError extends Error {
80
+ vault;
81
+ adapters;
82
+ /**
83
+ * @param vault - Vault V2 address.
84
+ * @param adapters - Number of adapters in the supplied vault snapshot.
85
+ */
86
+ constructor(vault, adapters) {
87
+ super(`Vault "${vault}" has "${adapters}" adapters. In-kind redemption requires exactly one MorphoMarketV1AdapterV2.`);
88
+ this.vault = vault;
89
+ this.adapters = adapters;
90
+ this.name = "InKindRedeemRequiresSingleAdapterError";
91
+ }
92
+ }
93
+ /** Thrown when a requested in-kind redemption adapter is not part of the Vault V2 snapshot. */
94
+ export class AdapterNotPartOfVaultError extends Error {
95
+ vault;
96
+ adapter;
97
+ /**
98
+ * @param vault - Vault V2 address.
99
+ * @param adapter - Adapter rejected by the vault snapshot.
100
+ */
101
+ constructor(vault, adapter) {
102
+ super(`Adapter "${adapter}" is not part of vault "${vault}". Use the vault's sole configured adapter.`);
103
+ this.vault = vault;
104
+ this.adapter = adapter;
105
+ this.name = "AdapterNotPartOfVaultError";
106
+ }
107
+ }
108
+ /** Thrown when the Vault V2 adapter cannot expose MorphoMarketV1AdapterV2 market shares. */
109
+ export class UnsupportedInKindAdapterError extends Error {
110
+ adapter;
111
+ /**
112
+ * @param adapter - Unsupported Vault V2 adapter address.
113
+ */
114
+ constructor(adapter) {
115
+ super(`Adapter "${adapter}" does not support Vault V2 in-kind redemption. Use a MorphoMarketV1AdapterV2-backed vault.`);
116
+ this.adapter = adapter;
117
+ this.name = "UnsupportedInKindAdapterError";
118
+ }
119
+ }
120
+ /** Thrown when a Vault V2 in-kind redemption rounds to no deallocated assets. */
121
+ export class InKindRedeemZeroDeallocationError extends Error {
122
+ /**
123
+ * @param params - Values that caused the exit to round to zero deallocated assets.
124
+ * @param params.vault - Vault V2 address with no idle assets available for the exit.
125
+ * @param params.amount - Positive penalty-inclusive amount requested by the caller.
126
+ * @param params.penalty - WAD-scaled force-deallocation penalty applied by the adapter.
127
+ */
128
+ vault;
129
+ amount;
130
+ penalty;
131
+ constructor(params) {
132
+ super(`Vault "${params.vault}" has no idle assets, and in-kind redemption amount "${params.amount}" rounds to zero deallocated assets after applying penalty "${params.penalty}". Increase the amount or use another exit path.`);
133
+ this.vault = params.vault;
134
+ this.amount = params.amount;
135
+ this.penalty = params.penalty;
136
+ this.name = "InKindRedeemZeroDeallocationError";
137
+ }
138
+ }
139
+ /** Thrown when the ordered market list cannot cover the requested in-kind redemption. */
140
+ export class InKindRedeemCoverageError extends Error {
141
+ /**
142
+ * @param params - Coverage values used to explain the rejected exit.
143
+ * @param params.required - Assets that must be deallocated from listed markets.
144
+ * @param params.covered - Assets covered by the supplied market list.
145
+ * @param params.maxExitAssets - Largest penalty-inclusive exit supported by the list.
146
+ */
147
+ required;
148
+ covered;
149
+ maxExitAssets;
150
+ constructor(params) {
151
+ super(`In-kind redemption requires "${params.required}" assets but the market list covers "${params.covered}". Reduce the amount to at most "${params.maxExitAssets}" or include more vault markets.`);
152
+ this.required = params.required;
153
+ this.covered = params.covered;
154
+ this.maxExitAssets = params.maxExitAssets;
155
+ this.name = "InKindRedeemCoverageError";
156
+ }
157
+ }
158
+ /** Thrown when Morpho Blue lacks the physical loan-token balance needed during an exit callback. */
159
+ export class InsufficientBlueBalanceForInKindRedeemError extends Error {
160
+ /**
161
+ * @param params - Morpho Blue balance values used to explain the rejected exit.
162
+ * @param params.asset - Loan token required by the exit.
163
+ * @param params.available - Current token balance held by Morpho Blue.
164
+ * @param params.required - Peak token balance required by the exit.
165
+ */
166
+ asset;
167
+ available;
168
+ required;
169
+ constructor(params) {
170
+ super(`Morpho Blue holds "${params.available}" of asset "${params.asset}", but this in-kind redemption requires "${params.required}" during its callback. Reduce the amount or wait for Blue liquidity.`);
171
+ this.asset = params.asset;
172
+ this.available = params.available;
173
+ this.required = params.required;
174
+ this.name = "InsufficientBlueBalanceForInKindRedeemError";
175
+ }
176
+ }
177
+ /** Thrown when a MetaMorpho vault is connected to a different Morpho deployment. */
178
+ export class VaultMorphoMismatchError extends Error {
179
+ /**
180
+ * @param params - Vault and Morpho addresses used to explain the mismatch.
181
+ * @param params.vault - MetaMorpho vault address.
182
+ * @param params.expected - Morpho Blue address expected for the target chain.
183
+ * @param params.actual - Morpho address returned by the vault.
184
+ */
185
+ vault;
186
+ expected;
187
+ actual;
188
+ constructor(params) {
189
+ super(`Vault "${params.vault}" uses Morpho "${params.actual}", expected "${params.expected}". Use vault data from the selected chain.`);
190
+ this.vault = params.vault;
191
+ this.expected = params.expected;
192
+ this.actual = params.actual;
193
+ this.name = "VaultMorphoMismatchError";
194
+ }
195
+ }
196
+ /** Thrown when a Vault V1 is Morpho Blue's fee recipient and cannot safely redeem in kind. */
197
+ export class VaultIsBlueFeeRecipientError extends Error {
198
+ vault;
199
+ blue;
200
+ /**
201
+ * @param vault - Unsupported Vault V1 address.
202
+ * @param blue - Morpho Blue deployment whose fees accrue to the vault.
203
+ */
204
+ constructor(vault, blue) {
205
+ super(`Vault "${vault}" is Morpho Blue "${blue}"'s fee recipient. Use another exit path because VaultExitBundlesV1 cannot safely account for the vault's accrued fee shares.`);
206
+ this.vault = vault;
207
+ this.blue = blue;
208
+ this.name = "VaultIsBlueFeeRecipientError";
209
+ }
210
+ }
211
+ /** Thrown when a vault-shares requirement cannot be safely encoded as an ERC-2612 permit. */
212
+ export class VaultExitBundlesV1PermitMismatchError extends Error {
213
+ /**
214
+ * @param params - Permit mismatch values used to explain the rejection.
215
+ * @param params.field - Permit field that does not match the exit.
216
+ * @param params.expected - Value required by the exit.
217
+ * @param params.actual - Value supplied by the signature.
218
+ * @param params.cause - Original parser failure when signature decoding is wrapped.
219
+ */
220
+ field;
221
+ expected;
222
+ actual;
223
+ constructor(params) {
224
+ super(`VaultExitBundlesV1 permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Rebuild and sign the vault-exit permit.`, { cause: params.cause });
225
+ this.field = params.field;
226
+ this.expected = params.expected;
227
+ this.actual = params.actual;
228
+ this.name = "VaultExitBundlesV1PermitMismatchError";
229
+ }
230
+ }
56
231
  /** @deprecated Use {@link NonPositiveInputError}. */
57
232
  export const NonPositiveAssetAmountError = NonPositiveInputError;
58
233
  /** @deprecated Use {@link NonPositiveInputError}. */
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": "5.4.1",
4
+ "version": "5.5.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Foulks-Plb <https://x.com/FoulkPlb>"
@@ -145,23 +145,21 @@
145
145
  ],
146
146
  "dependencies": {
147
147
  "zod": "^4.4.3",
148
+ "@morpho-org/blue-sdk": "^6.5.0",
148
149
  "@morpho-org/blue-sdk-viem": "^5.2.1",
149
- "@morpho-org/midnight-sdk": "^1.3.0",
150
- "@morpho-org/morpho-ts": "^2.8.0",
151
- "@morpho-org/blue-sdk": "^6.4.0"
150
+ "@morpho-org/morpho-ts": "^2.9.0",
151
+ "@morpho-org/midnight-sdk": "^1.3.0"
152
152
  },
153
153
  "peerDependencies": {
154
154
  "viem": "^2.0.0"
155
155
  },
156
156
  "devDependencies": {
157
157
  "dotenv": "^17.4.2",
158
- "fast-check": "^4.8.0",
159
- "typescript": "^6.0.3",
160
- "viem": "^2.54.2",
161
- "vitest": "^4.1.9",
162
- "@morpho-org/bundler-sdk-viem": "^5.0.3",
163
- "@morpho-org/simulation-sdk": "^4.0.3",
164
- "@morpho-org/test": "^2.8.3"
158
+ "fast-check": "^4.9.0",
159
+ "typescript": "^7.0.2",
160
+ "viem": "^2.55.10",
161
+ "vitest": "^4.1.10",
162
+ "@morpho-org/test": "^2.8.4"
165
163
  },
166
164
  "scripts": {
167
165
  "prepublish": "$npm_execpath build",