@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.
- package/lib/cjs/abis.d.ts +2816 -0
- package/lib/cjs/abis.js +1951 -0
- package/lib/cjs/actions/index.d.ts +3 -0
- package/lib/cjs/actions/marketV1/borrow.js +7 -10
- package/lib/cjs/actions/marketV1/buildReallocationActions.d.ts +2 -3
- package/lib/cjs/actions/marketV1/buildReallocationActions.js +1 -2
- package/lib/cjs/actions/marketV1/index.d.ts +2 -0
- package/lib/cjs/actions/marketV1/index.js +2 -0
- package/lib/cjs/actions/marketV1/repay.d.ts +2 -0
- package/lib/cjs/actions/marketV1/repay.js +7 -8
- package/lib/cjs/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
- package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +9 -10
- package/lib/cjs/actions/marketV1/supply.d.ts +69 -0
- package/lib/cjs/actions/marketV1/supply.js +128 -0
- package/lib/cjs/actions/marketV1/supplyCollateral.d.ts +3 -1
- package/lib/cjs/actions/marketV1/supplyCollateral.js +12 -13
- package/lib/cjs/actions/marketV1/supplyCollateralBorrow.d.ts +3 -1
- package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +14 -15
- package/lib/cjs/actions/marketV1/withdraw.d.ts +83 -0
- package/lib/cjs/actions/marketV1/withdraw.js +110 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -2
- package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -0
- package/lib/cjs/actions/vaultV1/deposit.js +13 -14
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +11 -9
- package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -0
- package/lib/cjs/actions/vaultV2/deposit.js +13 -14
- package/lib/cjs/addresses.d.ts +2 -0
- package/lib/cjs/addresses.js +18 -0
- package/lib/cjs/augment/AccrualPosition.d.ts +9 -0
- package/lib/cjs/augment/AccrualPosition.js +8 -0
- package/lib/cjs/augment/AccrualVault.d.ts +8 -0
- package/lib/cjs/augment/AccrualVault.js +7 -0
- package/lib/cjs/augment/Holding.d.ts +8 -0
- package/lib/cjs/augment/Holding.js +7 -0
- package/lib/cjs/augment/Market.d.ts +8 -0
- package/lib/cjs/augment/Market.js +7 -0
- package/lib/cjs/augment/MarketParams.d.ts +8 -0
- package/lib/cjs/augment/MarketParams.js +7 -0
- package/lib/cjs/augment/Position.d.ts +8 -0
- package/lib/cjs/augment/Position.js +7 -0
- package/lib/cjs/augment/Token.d.ts +8 -0
- package/lib/cjs/augment/Token.js +7 -0
- package/lib/cjs/augment/User.d.ts +8 -0
- package/lib/cjs/augment/User.js +7 -0
- package/lib/cjs/augment/Vault.d.ts +8 -0
- package/lib/cjs/augment/Vault.js +7 -0
- package/lib/cjs/augment/VaultConfig.d.ts +8 -0
- package/lib/cjs/augment/VaultConfig.js +7 -0
- package/lib/cjs/augment/VaultMarketAllocation.d.ts +8 -0
- package/lib/cjs/augment/VaultMarketAllocation.js +7 -0
- package/lib/cjs/augment/VaultMarketConfig.d.ts +8 -0
- package/lib/cjs/augment/VaultMarketConfig.js +7 -0
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +8 -0
- package/lib/cjs/augment/VaultUser.d.ts +8 -0
- package/lib/cjs/augment/VaultUser.js +7 -0
- package/lib/cjs/augment.d.ts +14 -0
- package/lib/cjs/augment.js +16 -0
- package/lib/cjs/bundler/actions.d.ts +637 -0
- package/lib/cjs/bundler/actions.js +1088 -0
- package/lib/cjs/bundler/index.d.ts +2 -0
- package/lib/cjs/bundler/index.js +18 -0
- package/lib/cjs/bundler/types.d.ts +200 -0
- package/lib/cjs/bundler/types.js +2 -0
- package/lib/cjs/constants.d.ts +3 -0
- package/lib/cjs/constants.js +32 -0
- package/lib/cjs/entities/index.d.ts +6 -3
- package/lib/cjs/entities/index.js +41 -17
- package/lib/cjs/entities/marketV1/marketV1.d.ts +161 -24
- package/lib/cjs/entities/marketV1/marketV1.js +166 -19
- package/lib/cjs/entities/reallocationData.d.ts +193 -0
- package/lib/cjs/entities/reallocationData.js +406 -0
- package/lib/cjs/errors.d.ts +2 -0
- package/lib/cjs/errors.js +18 -0
- package/lib/cjs/fetch.d.ts +1 -0
- package/lib/cjs/fetch.js +30 -0
- package/lib/cjs/format.d.ts +2 -0
- package/lib/cjs/format.js +22 -0
- package/lib/cjs/helpers/computeReallocations.d.ts +63 -12
- package/lib/cjs/helpers/computeReallocations.js +160 -41
- package/lib/cjs/helpers/constant.d.ts +17 -0
- package/lib/cjs/helpers/constant.js +30 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +14 -2
- package/lib/cjs/helpers/slippage.d.ts +57 -0
- package/lib/cjs/helpers/slippage.js +82 -0
- package/lib/cjs/helpers/validate.d.ts +40 -7
- package/lib/cjs/helpers/validate.js +67 -12
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/types/action.d.ts +27 -6
- package/lib/cjs/types/client.d.ts +1 -1
- package/lib/cjs/types/error.d.ts +155 -7
- package/lib/cjs/types/error.js +202 -11
- package/lib/cjs/types/sharedLiquidity.d.ts +43 -3
- package/lib/cjs/types.d.ts +3 -0
- package/lib/cjs/types.js +17 -0
- package/lib/cjs/utils.d.ts +9 -0
- package/lib/cjs/utils.js +65 -0
- package/lib/esm/abis.d.ts +2816 -0
- package/lib/esm/abis.js +1922 -0
- package/lib/esm/actions/index.d.ts +3 -0
- package/lib/esm/actions/marketV1/borrow.js +2 -5
- package/lib/esm/actions/marketV1/buildReallocationActions.d.ts +2 -3
- package/lib/esm/actions/marketV1/buildReallocationActions.js +1 -2
- package/lib/esm/actions/marketV1/index.d.ts +2 -0
- package/lib/esm/actions/marketV1/index.js +2 -0
- package/lib/esm/actions/marketV1/repay.d.ts +2 -0
- package/lib/esm/actions/marketV1/repay.js +4 -5
- package/lib/esm/actions/marketV1/repayWithdrawCollateral.d.ts +2 -0
- package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +4 -5
- package/lib/esm/actions/marketV1/supply.d.ts +69 -0
- package/lib/esm/actions/marketV1/supply.js +124 -0
- package/lib/esm/actions/marketV1/supplyCollateral.d.ts +3 -1
- package/lib/esm/actions/marketV1/supplyCollateral.js +7 -8
- package/lib/esm/actions/marketV1/supplyCollateralBorrow.d.ts +3 -1
- package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +7 -8
- package/lib/esm/actions/marketV1/withdraw.d.ts +83 -0
- package/lib/esm/actions/marketV1/withdraw.js +106 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsAction.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.js +1 -1
- package/lib/esm/actions/vaultV1/deposit.d.ts +2 -0
- package/lib/esm/actions/vaultV1/deposit.js +3 -4
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +3 -1
- package/lib/esm/actions/vaultV2/deposit.d.ts +2 -0
- package/lib/esm/actions/vaultV2/deposit.js +3 -4
- package/lib/esm/addresses.d.ts +2 -0
- package/lib/esm/addresses.js +1 -0
- package/lib/esm/augment/AccrualPosition.d.ts +9 -0
- package/lib/esm/augment/AccrualPosition.js +5 -0
- package/lib/esm/augment/AccrualVault.d.ts +8 -0
- package/lib/esm/augment/AccrualVault.js +4 -0
- package/lib/esm/augment/Holding.d.ts +8 -0
- package/lib/esm/augment/Holding.js +4 -0
- package/lib/esm/augment/Market.d.ts +8 -0
- package/lib/esm/augment/Market.js +4 -0
- package/lib/esm/augment/MarketParams.d.ts +8 -0
- package/lib/esm/augment/MarketParams.js +4 -0
- package/lib/esm/augment/Position.d.ts +8 -0
- package/lib/esm/augment/Position.js +4 -0
- package/lib/esm/augment/Token.d.ts +8 -0
- package/lib/esm/augment/Token.js +4 -0
- package/lib/esm/augment/User.d.ts +8 -0
- package/lib/esm/augment/User.js +4 -0
- package/lib/esm/augment/Vault.d.ts +8 -0
- package/lib/esm/augment/Vault.js +4 -0
- package/lib/esm/augment/VaultConfig.d.ts +8 -0
- package/lib/esm/augment/VaultConfig.js +4 -0
- package/lib/esm/augment/VaultMarketAllocation.d.ts +8 -0
- package/lib/esm/augment/VaultMarketAllocation.js +4 -0
- package/lib/esm/augment/VaultMarketConfig.d.ts +8 -0
- package/lib/esm/augment/VaultMarketConfig.js +4 -0
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +8 -0
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +5 -0
- package/lib/esm/augment/VaultUser.d.ts +8 -0
- package/lib/esm/augment/VaultUser.js +4 -0
- package/lib/esm/augment.d.ts +14 -0
- package/lib/esm/augment.js +14 -0
- package/lib/esm/bundler/actions.d.ts +637 -0
- package/lib/esm/bundler/actions.js +1085 -0
- package/lib/esm/bundler/index.d.ts +2 -0
- package/lib/esm/bundler/index.js +2 -0
- package/lib/esm/bundler/types.d.ts +200 -0
- package/lib/esm/bundler/types.js +1 -0
- package/lib/esm/constants.d.ts +3 -0
- package/lib/esm/constants.js +3 -0
- package/lib/esm/entities/index.d.ts +6 -3
- package/lib/esm/entities/index.js +5 -3
- package/lib/esm/entities/marketV1/marketV1.d.ts +161 -24
- package/lib/esm/entities/marketV1/marketV1.js +170 -23
- package/lib/esm/entities/reallocationData.d.ts +193 -0
- package/lib/esm/entities/reallocationData.js +402 -0
- package/lib/esm/errors.d.ts +2 -0
- package/lib/esm/errors.js +1 -0
- package/lib/esm/fetch.d.ts +1 -0
- package/lib/esm/fetch.js +1 -0
- package/lib/esm/format.d.ts +2 -0
- package/lib/esm/format.js +1 -0
- package/lib/esm/helpers/computeReallocations.d.ts +63 -12
- package/lib/esm/helpers/computeReallocations.js +160 -41
- package/lib/esm/helpers/constant.d.ts +17 -0
- package/lib/esm/helpers/constant.js +30 -1
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/slippage.d.ts +57 -0
- package/lib/esm/helpers/slippage.js +80 -0
- package/lib/esm/helpers/validate.d.ts +40 -7
- package/lib/esm/helpers/validate.js +63 -11
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/types/action.d.ts +27 -6
- package/lib/esm/types/client.d.ts +1 -1
- package/lib/esm/types/error.d.ts +155 -7
- package/lib/esm/types/error.js +185 -9
- package/lib/esm/types/sharedLiquidity.d.ts +43 -3
- package/lib/esm/types.d.ts +3 -0
- package/lib/esm/types.js +1 -0
- package/lib/esm/utils.d.ts +9 -0
- package/lib/esm/utils.js +7 -0
- package/package.json +128 -17
- package/src/index.ts +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./actions.js"), exports);
|
|
18
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { InputMarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Morpho authorization payload signed by a user for Bundler3-mediated Morpho
|
|
5
|
+
* Blue execution.
|
|
6
|
+
*/
|
|
7
|
+
export interface Authorization {
|
|
8
|
+
/** Address granting or revoking authorization. */
|
|
9
|
+
readonly authorizer: Address;
|
|
10
|
+
/** Address receiving authorization. */
|
|
11
|
+
readonly authorized: Address;
|
|
12
|
+
/** Whether authorization is granted (`true`) or revoked (`false`). */
|
|
13
|
+
readonly isAuthorized: boolean;
|
|
14
|
+
/** Morpho authorization nonce consumed by the signature. */
|
|
15
|
+
readonly nonce: bigint;
|
|
16
|
+
/** Signature deadline timestamp in seconds. */
|
|
17
|
+
readonly deadline: bigint;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Public allocator withdrawal input used by a `reallocateTo` Bundler3 action.
|
|
21
|
+
*/
|
|
22
|
+
export interface InputReallocation {
|
|
23
|
+
/** Market to withdraw liquidity from. */
|
|
24
|
+
readonly marketParams: InputMarketParams;
|
|
25
|
+
/** Amount of loan assets to withdraw from the market. */
|
|
26
|
+
readonly amount: bigint;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Permit2 single-permit token allowance details.
|
|
30
|
+
*/
|
|
31
|
+
export interface Permit2PermitSingleDetails {
|
|
32
|
+
/** ERC20 token approved through Permit2. */
|
|
33
|
+
readonly token: Address;
|
|
34
|
+
/** Allowance amount approved through Permit2. */
|
|
35
|
+
readonly amount: bigint;
|
|
36
|
+
/** Permit2 allowance expiration timestamp in seconds. */
|
|
37
|
+
readonly expiration: number;
|
|
38
|
+
/** Permit2 nonce consumed by the signature. */
|
|
39
|
+
readonly nonce: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Permit2 single-permit payload signed by the token owner.
|
|
43
|
+
*/
|
|
44
|
+
export interface Permit2PermitSingle {
|
|
45
|
+
/** Token, amount, expiration, and nonce being approved. */
|
|
46
|
+
readonly details: Permit2PermitSingleDetails;
|
|
47
|
+
/** Deadline timestamp for consuming the Permit2 signature. */
|
|
48
|
+
readonly sigDeadline: bigint;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Argument tuples for Bundler3 actions supported by `morpho-sdk`.
|
|
52
|
+
*/
|
|
53
|
+
export interface ActionArgs {
|
|
54
|
+
/** Native-token transfer from `owner` to `recipient` for `amount`; `skipRevert` controls Bundler3 revert handling. */
|
|
55
|
+
readonly nativeTransfer: [
|
|
56
|
+
owner: Address,
|
|
57
|
+
recipient: Address,
|
|
58
|
+
amount: bigint,
|
|
59
|
+
skipRevert?: boolean
|
|
60
|
+
];
|
|
61
|
+
/** ERC20 transfer from `adapter` to `recipient` for `amount` of `asset`; `skipRevert` controls Bundler3 revert handling. */
|
|
62
|
+
readonly erc20Transfer: [
|
|
63
|
+
asset: Address,
|
|
64
|
+
recipient: Address,
|
|
65
|
+
amount: bigint,
|
|
66
|
+
adapter: Address,
|
|
67
|
+
skipRevert?: boolean
|
|
68
|
+
];
|
|
69
|
+
/** GeneralAdapter1 ERC20 `transferFrom` of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
70
|
+
readonly erc20TransferFrom: [
|
|
71
|
+
asset: Address,
|
|
72
|
+
amount: bigint,
|
|
73
|
+
recipient: Address,
|
|
74
|
+
skipRevert?: boolean
|
|
75
|
+
];
|
|
76
|
+
/** ERC-2612 permit from `owner` for `asset`, `amount`, `deadline`, and `signature`; `skipRevert` controls Bundler3 revert handling. */
|
|
77
|
+
readonly permit: [
|
|
78
|
+
owner: Address,
|
|
79
|
+
asset: Address,
|
|
80
|
+
amount: bigint,
|
|
81
|
+
deadline: bigint,
|
|
82
|
+
signature: Hex | null,
|
|
83
|
+
skipRevert?: boolean
|
|
84
|
+
];
|
|
85
|
+
/** Permit2 approval from `owner` for `permitSingle` and `signature`; `skipRevert` controls Bundler3 revert handling. */
|
|
86
|
+
readonly approve2: [
|
|
87
|
+
owner: Address,
|
|
88
|
+
permitSingle: Permit2PermitSingle,
|
|
89
|
+
signature: Hex | null,
|
|
90
|
+
skipRevert?: boolean
|
|
91
|
+
];
|
|
92
|
+
/** GeneralAdapter1 Permit2 transfer of `asset` and `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
93
|
+
readonly transferFrom2: [
|
|
94
|
+
asset: Address,
|
|
95
|
+
amount: bigint,
|
|
96
|
+
recipient: Address,
|
|
97
|
+
skipRevert?: boolean
|
|
98
|
+
];
|
|
99
|
+
/** ERC4626 deposit into `erc4626` for `assets`, `maxSharePrice`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
100
|
+
readonly erc4626Deposit: [
|
|
101
|
+
erc4626: Address,
|
|
102
|
+
assets: bigint,
|
|
103
|
+
maxSharePrice: bigint,
|
|
104
|
+
receiver: Address,
|
|
105
|
+
skipRevert?: boolean
|
|
106
|
+
];
|
|
107
|
+
/** ERC4626 redeem from `erc4626` for `shares`, `minSharePrice`, `receiver`, and `owner`; `skipRevert` controls Bundler3 revert handling. */
|
|
108
|
+
readonly erc4626Redeem: [
|
|
109
|
+
erc4626: Address,
|
|
110
|
+
shares: bigint,
|
|
111
|
+
minSharePrice: bigint,
|
|
112
|
+
receiver: Address,
|
|
113
|
+
owner: Address,
|
|
114
|
+
skipRevert?: boolean
|
|
115
|
+
];
|
|
116
|
+
/** Morpho Blue supply-collateral call for `market`, `assets`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
117
|
+
readonly morphoSupplyCollateral: [
|
|
118
|
+
market: InputMarketParams,
|
|
119
|
+
assets: bigint,
|
|
120
|
+
onBehalf: Address,
|
|
121
|
+
onMorphoSupplyCollateral: Action[],
|
|
122
|
+
skipRevert?: boolean
|
|
123
|
+
];
|
|
124
|
+
/** Morpho Blue supply call for `market`, `assets` or `shares`, `slippageAmount`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
125
|
+
readonly morphoSupply: [
|
|
126
|
+
market: InputMarketParams,
|
|
127
|
+
assets: bigint,
|
|
128
|
+
shares: bigint,
|
|
129
|
+
slippageAmount: bigint,
|
|
130
|
+
onBehalf: Address,
|
|
131
|
+
onMorphoSupply: Action[],
|
|
132
|
+
skipRevert?: boolean
|
|
133
|
+
];
|
|
134
|
+
/** Morpho Blue borrow call for `market`, `assets` or `shares`, `slippageAmount`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
135
|
+
readonly morphoBorrow: [
|
|
136
|
+
market: InputMarketParams,
|
|
137
|
+
assets: bigint,
|
|
138
|
+
shares: bigint,
|
|
139
|
+
slippageAmount: bigint,
|
|
140
|
+
receiver: Address,
|
|
141
|
+
skipRevert?: boolean
|
|
142
|
+
];
|
|
143
|
+
/** Morpho Blue repay call for `market`, `assets` or `shares`, `slippageAmount`, `onBehalf`, and callback actions; `skipRevert` controls Bundler3 revert handling. */
|
|
144
|
+
readonly morphoRepay: [
|
|
145
|
+
market: InputMarketParams,
|
|
146
|
+
assets: bigint,
|
|
147
|
+
shares: bigint,
|
|
148
|
+
slippageAmount: bigint,
|
|
149
|
+
onBehalf: Address,
|
|
150
|
+
onMorphoRepay: Action[],
|
|
151
|
+
skipRevert?: boolean
|
|
152
|
+
];
|
|
153
|
+
/** Morpho Blue withdraw call for `market`, `assets` or `shares`, `slippageAmount`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
154
|
+
readonly morphoWithdraw: [
|
|
155
|
+
market: InputMarketParams,
|
|
156
|
+
assets: bigint,
|
|
157
|
+
shares: bigint,
|
|
158
|
+
slippageAmount: bigint,
|
|
159
|
+
receiver: Address,
|
|
160
|
+
skipRevert?: boolean
|
|
161
|
+
];
|
|
162
|
+
/** Morpho Blue withdraw-collateral call for `market`, `assets`, and `receiver`; `skipRevert` controls Bundler3 revert handling. */
|
|
163
|
+
readonly morphoWithdrawCollateral: [
|
|
164
|
+
market: InputMarketParams,
|
|
165
|
+
assets: bigint,
|
|
166
|
+
receiver: Address,
|
|
167
|
+
skipRevert?: boolean
|
|
168
|
+
];
|
|
169
|
+
/** PublicAllocator reallocation to `supplyMarket` from `vault` withdrawals while paying `fee`; `skipRevert` controls Bundler3 revert handling. */
|
|
170
|
+
readonly reallocateTo: [
|
|
171
|
+
vault: Address,
|
|
172
|
+
fee: bigint,
|
|
173
|
+
withdrawals: InputReallocation[],
|
|
174
|
+
supplyMarket: InputMarketParams,
|
|
175
|
+
skipRevert?: boolean
|
|
176
|
+
];
|
|
177
|
+
/** GeneralAdapter1 native wrap of `amount` to `recipient`; `skipRevert` controls Bundler3 revert handling. */
|
|
178
|
+
readonly wrapNative: [
|
|
179
|
+
amount: bigint,
|
|
180
|
+
recipient: Address,
|
|
181
|
+
skipRevert?: boolean
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Supported Bundler3 action discriminator.
|
|
186
|
+
*/
|
|
187
|
+
export type ActionType = keyof ActionArgs;
|
|
188
|
+
/**
|
|
189
|
+
* Supported Bundler3 action object map keyed by action discriminator.
|
|
190
|
+
*/
|
|
191
|
+
export type Actions = {
|
|
192
|
+
readonly [T in ActionType]: {
|
|
193
|
+
readonly type: T;
|
|
194
|
+
readonly args: ActionArgs[T];
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Discriminated union of Bundler3 actions supported by `morpho-sdk`.
|
|
199
|
+
*/
|
|
200
|
+
export type Action = Actions[ActionType];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ChainId, ChainUtils, DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, isMarketId, LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, CDN_BASE_URL, DOCS_BASE_URL, MORPHO_DOMAIN, OPTIMIZERS_API_BASE_URL, OPTIMIZERS_BASE_URL, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
3
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.OPTIMIZERS_BASE_URL = exports.OPTIMIZERS_API_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.CDN_BASE_URL = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.TransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.LIQUIDATION_CURSOR = exports.isMarketId = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = exports.ChainUtils = exports.ChainId = void 0;
|
|
4
|
+
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
Object.defineProperty(exports, "ChainId", { enumerable: true, get: function () { return blue_sdk_1.ChainId; } });
|
|
6
|
+
Object.defineProperty(exports, "ChainUtils", { enumerable: true, get: function () { return blue_sdk_1.ChainUtils; } });
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE; } });
|
|
8
|
+
Object.defineProperty(exports, "EIP_712_FIELDS", { enumerable: true, get: function () { return blue_sdk_1.EIP_712_FIELDS; } });
|
|
9
|
+
Object.defineProperty(exports, "isMarketId", { enumerable: true, get: function () { return blue_sdk_1.isMarketId; } });
|
|
10
|
+
Object.defineProperty(exports, "LIQUIDATION_CURSOR", { enumerable: true, get: function () { return blue_sdk_1.LIQUIDATION_CURSOR; } });
|
|
11
|
+
Object.defineProperty(exports, "MAX_LIQUIDATION_INCENTIVE_FACTOR", { enumerable: true, get: function () { return blue_sdk_1.MAX_LIQUIDATION_INCENTIVE_FACTOR; } });
|
|
12
|
+
Object.defineProperty(exports, "ORACLE_PRICE_SCALE", { enumerable: true, get: function () { return blue_sdk_1.ORACLE_PRICE_SCALE; } });
|
|
13
|
+
Object.defineProperty(exports, "SECONDS_PER_YEAR", { enumerable: true, get: function () { return blue_sdk_1.SECONDS_PER_YEAR; } });
|
|
14
|
+
Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return blue_sdk_1.TransactionType; } });
|
|
15
|
+
var morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
16
|
+
Object.defineProperty(exports, "BLUE_API_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.BLUE_API_BASE_URL; } });
|
|
17
|
+
Object.defineProperty(exports, "BLUE_API_GRAPHQL_URL", { enumerable: true, get: function () { return morpho_ts_1.BLUE_API_GRAPHQL_URL; } });
|
|
18
|
+
Object.defineProperty(exports, "CDN_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.CDN_BASE_URL; } });
|
|
19
|
+
Object.defineProperty(exports, "DOCS_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.DOCS_BASE_URL; } });
|
|
20
|
+
Object.defineProperty(exports, "MORPHO_DOMAIN", { enumerable: true, get: function () { return morpho_ts_1.MORPHO_DOMAIN; } });
|
|
21
|
+
Object.defineProperty(exports, "OPTIMIZERS_API_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.OPTIMIZERS_API_BASE_URL; } });
|
|
22
|
+
Object.defineProperty(exports, "OPTIMIZERS_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.OPTIMIZERS_BASE_URL; } });
|
|
23
|
+
Object.defineProperty(exports, "REWARDS_BASE_URL", { enumerable: true, get: function () { return morpho_ts_1.REWARDS_BASE_URL; } });
|
|
24
|
+
Object.defineProperty(exports, "ZERO_ADDRESS", { enumerable: true, get: function () { return morpho_ts_1.ZERO_ADDRESS; } });
|
|
25
|
+
var constant_js_1 = require("./helpers/constant.js");
|
|
26
|
+
Object.defineProperty(exports, "APPROVE_ONLY_ONCE_TOKENS", { enumerable: true, get: function () { return constant_js_1.APPROVE_ONLY_ONCE_TOKENS; } });
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_LLTV_BUFFER", { enumerable: true, get: function () { return constant_js_1.DEFAULT_LLTV_BUFFER; } });
|
|
28
|
+
Object.defineProperty(exports, "DEFAULT_SUPPLY_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_SUPPLY_TARGET_UTILIZATION; } });
|
|
29
|
+
Object.defineProperty(exports, "DEFAULT_WITHDRAWAL_TARGET_UTILIZATION", { enumerable: true, get: function () { return constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION; } });
|
|
30
|
+
Object.defineProperty(exports, "MAX_ABSOLUTE_SHARE_PRICE", { enumerable: true, get: function () { return constant_js_1.MAX_ABSOLUTE_SHARE_PRICE; } });
|
|
31
|
+
Object.defineProperty(exports, "MAX_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return constant_js_1.MAX_SLIPPAGE_TOLERANCE; } });
|
|
32
|
+
Object.defineProperty(exports, "MAX_TOKEN_APPROVALS", { enumerable: true, get: function () { return constant_js_1.MAX_TOKEN_APPROVALS; } });
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
3
|
+
export { MorphoMarketV1 } from "./marketV1/index.js";
|
|
4
|
+
export { type InputReallocationData, ReallocationData, } from "./reallocationData.js";
|
|
5
|
+
export { MorphoVaultV1 } from "./vaultV1/index.js";
|
|
6
|
+
export { MorphoVaultV2 } from "./vaultV2/index.js";
|
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.ReallocationData = exports.MorphoMarketV1 = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketPublicAllocatorConfig = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.Token = exports.PreLiquidationPosition = exports.PreLiquidationParams = exports.Position = exports.MarketParams = exports.Market = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = void 0;
|
|
4
|
+
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
6
|
+
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
7
|
+
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
8
|
+
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
9
|
+
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
10
|
+
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
11
|
+
Object.defineProperty(exports, "AssetBalances", { enumerable: true, get: function () { return blue_sdk_1.AssetBalances; } });
|
|
12
|
+
Object.defineProperty(exports, "ConstantWrappedToken", { enumerable: true, get: function () { return blue_sdk_1.ConstantWrappedToken; } });
|
|
13
|
+
Object.defineProperty(exports, "Eip5267Domain", { enumerable: true, get: function () { return blue_sdk_1.Eip5267Domain; } });
|
|
14
|
+
Object.defineProperty(exports, "ExchangeRateWrappedToken", { enumerable: true, get: function () { return blue_sdk_1.ExchangeRateWrappedToken; } });
|
|
15
|
+
Object.defineProperty(exports, "Holding", { enumerable: true, get: function () { return blue_sdk_1.Holding; } });
|
|
16
|
+
Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
|
|
17
|
+
Object.defineProperty(exports, "MarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
|
|
18
|
+
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
|
|
19
|
+
Object.defineProperty(exports, "PreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
|
|
20
|
+
Object.defineProperty(exports, "PreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
|
|
21
|
+
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
|
|
22
|
+
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return blue_sdk_1.User; } });
|
|
23
|
+
Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return blue_sdk_1.Vault; } });
|
|
24
|
+
Object.defineProperty(exports, "VaultConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultConfig; } });
|
|
25
|
+
Object.defineProperty(exports, "VaultMarketAllocation", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketAllocation; } });
|
|
26
|
+
Object.defineProperty(exports, "VaultMarketConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketConfig; } });
|
|
27
|
+
Object.defineProperty(exports, "VaultMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketPublicAllocatorConfig; } });
|
|
28
|
+
Object.defineProperty(exports, "VaultToken", { enumerable: true, get: function () { return blue_sdk_1.VaultToken; } });
|
|
29
|
+
Object.defineProperty(exports, "VaultUser", { enumerable: true, get: function () { return blue_sdk_1.VaultUser; } });
|
|
30
|
+
Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2; } });
|
|
31
|
+
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
32
|
+
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
33
|
+
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
34
|
+
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
35
|
+
Object.defineProperty(exports, "WrappedToken", { enumerable: true, get: function () { return blue_sdk_1.WrappedToken; } });
|
|
36
|
+
var index_js_1 = require("./marketV1/index.js");
|
|
37
|
+
Object.defineProperty(exports, "MorphoMarketV1", { enumerable: true, get: function () { return index_js_1.MorphoMarketV1; } });
|
|
38
|
+
var reallocationData_js_1 = require("./reallocationData.js");
|
|
39
|
+
Object.defineProperty(exports, "ReallocationData", { enumerable: true, get: function () { return reallocationData_js_1.ReallocationData; } });
|
|
40
|
+
var index_js_2 = require("./vaultV1/index.js");
|
|
41
|
+
Object.defineProperty(exports, "MorphoVaultV1", { enumerable: true, get: function () { return index_js_2.MorphoVaultV1; } });
|
|
42
|
+
var index_js_3 = require("./vaultV2/index.js");
|
|
43
|
+
Object.defineProperty(exports, "MorphoVaultV2", { enumerable: true, get: function () { return index_js_3.MorphoVaultV2; } });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type AccrualPosition, type Market, type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import { type MinimalBlock, SimulationState } from "@morpho-org/simulation-sdk";
|
|
3
2
|
import type { Address } from "viem";
|
|
4
3
|
import type { FetchParameters } from "../../types/data.js";
|
|
5
|
-
import { type DepositAmountArgs, type ERC20ApprovalAction, type MarketV1BorrowAction, type MarketV1RepayAction, type MarketV1RepayWithdrawCollateralAction, type MarketV1SupplyCollateralAction, type MarketV1SupplyCollateralBorrowAction, type MarketV1WithdrawCollateralAction, type MorphoAuthorizationAction, type MorphoClientType, type ReallocationComputeOptions, type RepayAmountArgs, type Requirement, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
4
|
+
import { type AssetsOrSharesArgs, type DepositAmountArgs, type ERC20ApprovalAction, type MarketV1BorrowAction, type MarketV1RepayAction, type MarketV1RepayWithdrawCollateralAction, type MarketV1SupplyAction, type MarketV1SupplyCollateralAction, type MarketV1SupplyCollateralBorrowAction, type MarketV1WithdrawAction, type MarketV1WithdrawCollateralAction, type MorphoAuthorizationAction, type MorphoClientType, type ReallocationComputeOptions, type RepayAmountArgs, type Requirement, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
5
|
+
import { ReallocationData } from "../reallocationData.js";
|
|
6
6
|
export interface MarketV1Actions {
|
|
7
7
|
/**
|
|
8
8
|
* Fetches the latest market data with accrued interest.
|
|
@@ -37,6 +37,61 @@ export interface MarketV1Actions {
|
|
|
37
37
|
useSimplePermit?: boolean;
|
|
38
38
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Prepares a loan-asset supply transaction.
|
|
42
|
+
*
|
|
43
|
+
* Routed through bundler via GeneralAdapter1. Computes `maxSharePrice` from market supply
|
|
44
|
+
* state and `slippageTolerance` to protect against share-price inflation.
|
|
45
|
+
* `getRequirements` returns ERC20 approval or permit for `GeneralAdapter1` on the loan token.
|
|
46
|
+
* When `nativeAmount` is provided, native token is wrapped; the loan token must be wNative.
|
|
47
|
+
*
|
|
48
|
+
* No Morpho authorization required (supplier is crediting, not withdrawing).
|
|
49
|
+
*
|
|
50
|
+
* @param params - Supply parameters.
|
|
51
|
+
* @returns Object with `buildTx` and `getRequirements`.
|
|
52
|
+
*/
|
|
53
|
+
supply: (params: {
|
|
54
|
+
userAddress: Address;
|
|
55
|
+
marketData: Market;
|
|
56
|
+
slippageTolerance?: bigint;
|
|
57
|
+
} & DepositAmountArgs) => {
|
|
58
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<MarketV1SupplyAction>>;
|
|
59
|
+
getRequirements: (params?: {
|
|
60
|
+
useSimplePermit?: boolean;
|
|
61
|
+
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Prepares a loan-asset withdraw transaction.
|
|
65
|
+
*
|
|
66
|
+
* Routed through bundler3 via `morphoWithdraw`. Supports two modes via {@link AssetsOrSharesArgs}:
|
|
67
|
+
* - **By assets** (`{ assets }`): withdraws an exact asset amount.
|
|
68
|
+
* - **By shares** (`{ shares }`): burns an exact share count (full close, immune to interest accrual).
|
|
69
|
+
*
|
|
70
|
+
* Computes `minSharePrice` from market supply state and `slippageTolerance`.
|
|
71
|
+
*
|
|
72
|
+
* When `reallocations` is provided, `reallocateTo` actions are prepended to the bundle,
|
|
73
|
+
* moving liquidity from other markets via the PublicAllocator before withdrawing — used to
|
|
74
|
+
* unblock withdraws that exceed on-market liquidity.
|
|
75
|
+
*
|
|
76
|
+
* `getRequirements` returns `morpho.setAuthorization(generalAdapter1, true)` if GA1 is not
|
|
77
|
+
* yet authorized on Morpho (returns `[]` when already authorized), since the bundler calls
|
|
78
|
+
* `withdraw(...,onBehalf=user,...)`.
|
|
79
|
+
*
|
|
80
|
+
* **Stale `positionData` may cause unexpected supply share calculations.**
|
|
81
|
+
*
|
|
82
|
+
* @param params - Withdraw parameters including pre-fetched `positionData`.
|
|
83
|
+
* @returns Object with `buildTx` and `getRequirements`.
|
|
84
|
+
*/
|
|
85
|
+
withdraw: (params: {
|
|
86
|
+
userAddress: Address;
|
|
87
|
+
receiver?: Address;
|
|
88
|
+
positionData: AccrualPosition;
|
|
89
|
+
slippageTolerance?: bigint;
|
|
90
|
+
reallocations?: readonly VaultReallocation[];
|
|
91
|
+
} & AssetsOrSharesArgs) => {
|
|
92
|
+
buildTx: () => Readonly<Transaction<MarketV1WithdrawAction>>;
|
|
93
|
+
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
94
|
+
};
|
|
40
95
|
/**
|
|
41
96
|
* Prepares a borrow transaction.
|
|
42
97
|
*
|
|
@@ -173,7 +228,7 @@ export interface MarketV1Actions {
|
|
|
173
228
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>> | Requirement)[]>;
|
|
174
229
|
};
|
|
175
230
|
/**
|
|
176
|
-
* Fetches all on-chain data needed to construct a {@link
|
|
231
|
+
* Fetches all on-chain data needed to construct a {@link ReallocationData}
|
|
177
232
|
* for computing vault reallocations via the public allocator.
|
|
178
233
|
*
|
|
179
234
|
* The target market is refetched internally at `block.number` so the
|
|
@@ -182,7 +237,7 @@ export interface MarketV1Actions {
|
|
|
182
237
|
* inject unnecessary `reallocateTo` actions (and their PublicAllocator
|
|
183
238
|
* fees) into the resulting bundle.
|
|
184
239
|
*
|
|
185
|
-
* The returned
|
|
240
|
+
* The returned reallocation data can be passed to {@link getReallocations}
|
|
186
241
|
* to compute the `VaultReallocation[]` array for `borrow()` or
|
|
187
242
|
* `supplyCollateralBorrow()`.
|
|
188
243
|
*
|
|
@@ -190,31 +245,54 @@ export interface MarketV1Actions {
|
|
|
190
245
|
*
|
|
191
246
|
* @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
|
|
192
247
|
* @param params.block - The block to fetch data at (number and timestamp).
|
|
193
|
-
* @returns A
|
|
248
|
+
* @returns A ReallocationData instance populated with all required data.
|
|
249
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
194
250
|
*/
|
|
195
251
|
getReallocationData: (params: {
|
|
196
252
|
vaultAddresses: readonly Address[];
|
|
197
|
-
block:
|
|
198
|
-
|
|
253
|
+
block: {
|
|
254
|
+
readonly number: bigint;
|
|
255
|
+
readonly timestamp: bigint;
|
|
256
|
+
};
|
|
257
|
+
}) => Promise<ReallocationData>;
|
|
199
258
|
/**
|
|
200
|
-
* Computes vault reallocations for a borrow on this market.
|
|
259
|
+
* Computes vault reallocations for a borrow or withdraw on this market.
|
|
201
260
|
*
|
|
202
|
-
* Uses the shared
|
|
203
|
-
*
|
|
204
|
-
*
|
|
261
|
+
* Uses the shared-liquidity algorithm to determine which vaults should reallocate liquidity to
|
|
262
|
+
* this market via the PublicAllocator, based on the post-operation utilization target.
|
|
263
|
+
*
|
|
264
|
+
* Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow",
|
|
265
|
+
* amount }`) or `{ operation: "withdraw", amount }` for a loan-asset withdraw.
|
|
205
266
|
*
|
|
206
267
|
* @param params.reallocationData - The current on-chain state (from {@link getReallocationData}).
|
|
207
|
-
* @param params.
|
|
268
|
+
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
269
|
+
* Defaults to `"borrow"` when `borrowAmount` is provided.
|
|
270
|
+
* @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
|
|
271
|
+
* @param params.borrowAmount - {@deprecated} Equivalent to `{ operation: "borrow", amount }`. Use the
|
|
272
|
+
* `operation` + `amount` form on new code.
|
|
208
273
|
* @param params.options - Optional reallocation computation options
|
|
209
|
-
* (utilization targets, reallocatable vaults filter, etc.).
|
|
210
|
-
*
|
|
211
|
-
*
|
|
274
|
+
* (timestamp, utilization targets, reallocatable vaults filter, etc.).
|
|
275
|
+
* Pass the fetched block timestamp to compute reallocations at the same block.
|
|
276
|
+
* @returns Array of vault reallocations ready to pass to `borrow()`, `supplyCollateralBorrow()`,
|
|
277
|
+
* or `withdraw()`. Empty array if no reallocation is needed.
|
|
278
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
279
|
+
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
|
|
280
|
+
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
281
|
+
* @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
|
|
212
282
|
*/
|
|
213
283
|
getReallocations: (params: {
|
|
214
|
-
reallocationData:
|
|
215
|
-
borrowAmount: bigint;
|
|
284
|
+
reallocationData: ReallocationData;
|
|
216
285
|
options?: ReallocationComputeOptions;
|
|
217
|
-
}
|
|
286
|
+
} & ({
|
|
287
|
+
operation: "borrow" | "withdraw";
|
|
288
|
+
amount: bigint;
|
|
289
|
+
borrowAmount?: never;
|
|
290
|
+
} | {
|
|
291
|
+
/** @deprecated Pass `{ operation: "borrow", amount }` instead. */
|
|
292
|
+
borrowAmount: bigint;
|
|
293
|
+
operation?: never;
|
|
294
|
+
amount?: never;
|
|
295
|
+
})) => readonly VaultReallocation[];
|
|
218
296
|
}
|
|
219
297
|
export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
220
298
|
private readonly client;
|
|
@@ -223,6 +301,26 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
223
301
|
constructor(client: MorphoClientType, marketParams: MarketParams, chainId: number);
|
|
224
302
|
getMarketData(parameters?: FetchParameters): Promise<Market>;
|
|
225
303
|
getPositionData(userAddress: Address, parameters?: FetchParameters): Promise<AccrualPosition>;
|
|
304
|
+
supply({ amount, userAddress, nativeAmount, marketData, slippageTolerance, }: {
|
|
305
|
+
userAddress: Address;
|
|
306
|
+
marketData: Market;
|
|
307
|
+
slippageTolerance?: bigint;
|
|
308
|
+
} & DepositAmountArgs): {
|
|
309
|
+
getRequirements: (params?: {
|
|
310
|
+
useSimplePermit?: boolean;
|
|
311
|
+
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
312
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<MarketV1SupplyAction>>;
|
|
313
|
+
};
|
|
314
|
+
withdraw(params: {
|
|
315
|
+
userAddress: Address;
|
|
316
|
+
receiver?: Address;
|
|
317
|
+
positionData: AccrualPosition;
|
|
318
|
+
slippageTolerance?: bigint;
|
|
319
|
+
reallocations?: readonly VaultReallocation[];
|
|
320
|
+
} & AssetsOrSharesArgs): {
|
|
321
|
+
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
322
|
+
buildTx: () => Readonly<Transaction<MarketV1WithdrawAction>>;
|
|
323
|
+
};
|
|
226
324
|
supplyCollateral({ amount, userAddress, nativeAmount, }: {
|
|
227
325
|
userAddress: Address;
|
|
228
326
|
} & DepositAmountArgs): {
|
|
@@ -281,13 +379,52 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
281
379
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>>)[]>;
|
|
282
380
|
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<MarketV1SupplyCollateralBorrowAction>>;
|
|
283
381
|
};
|
|
382
|
+
/**
|
|
383
|
+
* Fetches all on-chain inputs needed to compute public allocator reallocations.
|
|
384
|
+
*
|
|
385
|
+
* @param params - Reallocation data fetch parameters.
|
|
386
|
+
* @param params.vaultAddresses - Vaults to inspect for source-market liquidity.
|
|
387
|
+
* @param params.block - Block number and timestamp used for consistent RPC reads.
|
|
388
|
+
* @returns Reallocation data ready for {@link getReallocations}.
|
|
389
|
+
* @throws {ChainIdMismatchError} when the client chain does not match this market.
|
|
390
|
+
*/
|
|
284
391
|
getReallocationData({ vaultAddresses, block, }: {
|
|
285
392
|
vaultAddresses: readonly Address[];
|
|
286
|
-
block:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
393
|
+
block: {
|
|
394
|
+
readonly number: bigint;
|
|
395
|
+
readonly timestamp: bigint;
|
|
396
|
+
};
|
|
397
|
+
}): Promise<ReallocationData>;
|
|
398
|
+
/**
|
|
399
|
+
* Computes public allocator reallocations for a borrow or withdraw on this market.
|
|
400
|
+
*
|
|
401
|
+
* Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow", amount }`)
|
|
402
|
+
* or `{ operation, amount }` for a borrow or loan-asset withdraw.
|
|
403
|
+
*
|
|
404
|
+
* @param params - Reallocation computation parameters.
|
|
405
|
+
* @param params.reallocationData - State returned by {@link getReallocationData}.
|
|
406
|
+
* @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
|
|
407
|
+
* @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
|
|
408
|
+
* @param params.borrowAmount - {@deprecated Pass `{ operation: "borrow", amount }` instead.}
|
|
409
|
+
* @param params.options - Optional allocator and utilization options.
|
|
410
|
+
* @returns Vault reallocations ready to pass to `borrow`, `supplyCollateralBorrow`, or `withdraw`.
|
|
411
|
+
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
412
|
+
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
|
|
413
|
+
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
|
|
414
|
+
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
415
|
+
* @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
|
|
416
|
+
*/
|
|
417
|
+
getReallocations(params: {
|
|
418
|
+
reallocationData: ReallocationData;
|
|
291
419
|
options?: ReallocationComputeOptions;
|
|
292
|
-
}
|
|
420
|
+
} & ({
|
|
421
|
+
operation: "borrow" | "withdraw";
|
|
422
|
+
amount: bigint;
|
|
423
|
+
borrowAmount?: never;
|
|
424
|
+
} | {
|
|
425
|
+
/** @deprecated Pass `{ operation: "borrow", amount }` instead. */
|
|
426
|
+
borrowAmount: bigint;
|
|
427
|
+
operation?: never;
|
|
428
|
+
amount?: never;
|
|
429
|
+
})): readonly VaultReallocation[];
|
|
293
430
|
}
|