@morpho-org/morpho-sdk 6.6.0 → 7.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.
- package/MIGRATION-v6-to-v7.md +291 -0
- package/README.md +26 -12
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -2
- package/lib/cjs/actions/bundles/common.d.ts +9 -5
- package/lib/cjs/actions/bundles/common.js +22 -13
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
- package/lib/cjs/actions/midnight/authorization.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
- package/lib/cjs/actions/midnight/index.d.ts +3 -3
- package/lib/cjs/actions/midnight/index.js +3 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
- package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
- package/lib/cjs/actions/midnight/takeLend.js +111 -54
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
- package/lib/cjs/actions/midnight/types.d.ts +7 -26
- package/lib/cjs/actions/midnight/types.js +0 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/midnight/index.js +0 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/entities/index.d.ts +2 -2
- package/lib/cjs/entities/midnight/midnight.d.ts +582 -108
- package/lib/cjs/entities/midnight/midnight.js +981 -509
- package/lib/cjs/entities/midnight/types.d.ts +142 -60
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +2 -1
- package/lib/cjs/entities/vaultV1/vaultV1.js +1 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +2 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -0
- package/lib/cjs/helpers/callback.d.ts +54 -0
- package/lib/cjs/helpers/callback.js +73 -0
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +6 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/cjs/helpers/validate.d.ts +43 -2
- package/lib/cjs/helpers/validate.js +60 -3
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -2
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/types/action.d.ts +117 -89
- package/lib/cjs/types/action.js +1 -19
- package/lib/cjs/types/error.d.ts +126 -40
- package/lib/cjs/types/error.js +154 -49
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +9 -5
- package/lib/esm/actions/bundles/common.js +22 -13
- package/lib/esm/actions/midnight/authorization.d.ts +3 -2
- package/lib/esm/actions/midnight/authorization.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
- package/lib/esm/actions/midnight/index.d.ts +3 -3
- package/lib/esm/actions/midnight/index.js +3 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
- package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/esm/actions/midnight/takeBorrow.js +98 -57
- package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
- package/lib/esm/actions/midnight/takeLend.js +114 -57
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
- package/lib/esm/actions/midnight/types.d.ts +7 -26
- package/lib/esm/actions/midnight/types.js +1 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/esm/actions/requirements/midnight/index.js +0 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/index.d.ts +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +582 -108
- package/lib/esm/entities/midnight/midnight.js +987 -515
- package/lib/esm/entities/midnight/types.d.ts +142 -60
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +2 -1
- package/lib/esm/entities/vaultV1/vaultV1.js +1 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +2 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -0
- package/lib/esm/helpers/callback.d.ts +54 -0
- package/lib/esm/helpers/callback.js +68 -0
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/esm/helpers/validate.d.ts +43 -2
- package/lib/esm/helpers/validate.js +58 -2
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/esm/helpers/validateRequirementSpender.js +4 -5
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/types/action.d.ts +117 -89
- package/lib/esm/types/action.js +1 -18
- package/lib/esm/types/error.d.ts +126 -40
- package/lib/esm/types/error.js +135 -38
- package/package.json +8 -7
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
- package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/esm/actions/midnight/cancelOffer.js +0 -69
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
-
import type { SetterRatifierRatifyRootAction, Transaction } from "../../../types/index.js";
|
|
3
|
-
/** Parameters for {@link getSetterRatifierRatifyRootRequirement}. */
|
|
4
|
-
export interface GetSetterRatifierRatifyRootRequirementParams {
|
|
5
|
-
readonly viemClient: Client;
|
|
6
|
-
readonly chainId: number;
|
|
7
|
-
readonly maker: Address;
|
|
8
|
-
readonly root: Hex;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
12
|
-
*
|
|
13
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
14
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
15
|
-
* the transaction when the maker has already approved the root.
|
|
16
|
-
*
|
|
17
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
18
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
19
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
20
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
21
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
22
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
26
|
-
*
|
|
27
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
28
|
-
* viemClient: client,
|
|
29
|
-
* chainId: 8453,
|
|
30
|
-
* maker: user,
|
|
31
|
-
* root,
|
|
32
|
-
* });
|
|
33
|
-
* if (tx) {
|
|
34
|
-
* await walletClient.sendTransaction({
|
|
35
|
-
* to: tx.to,
|
|
36
|
-
* data: tx.data,
|
|
37
|
-
* value: tx.value,
|
|
38
|
-
* });
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare const getSetterRatifierRatifyRootRequirement: (params: GetSetterRatifierRatifyRootRequirementParams) => Promise<Readonly<Transaction<SetterRatifierRatifyRootAction>> | null>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { setterRatifierAbi } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { encodeFunctionData } from "viem";
|
|
4
|
-
import { readContract } from "viem/actions";
|
|
5
|
-
import { validateChainId } from "../../../helpers/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
8
|
-
*
|
|
9
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
10
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
11
|
-
* the transaction when the maker has already approved the root.
|
|
12
|
-
*
|
|
13
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
14
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
15
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
16
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
17
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
18
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
22
|
-
*
|
|
23
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
24
|
-
* viemClient: client,
|
|
25
|
-
* chainId: 8453,
|
|
26
|
-
* maker: user,
|
|
27
|
-
* root,
|
|
28
|
-
* });
|
|
29
|
-
* if (tx) {
|
|
30
|
-
* await walletClient.sendTransaction({
|
|
31
|
-
* to: tx.to,
|
|
32
|
-
* data: tx.data,
|
|
33
|
-
* value: tx.value,
|
|
34
|
-
* });
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export const getSetterRatifierRatifyRootRequirement = async (params) => {
|
|
39
|
-
validateChainId(params.viemClient.chain?.id, params.chainId);
|
|
40
|
-
const setterRatifier = getChainAddress(params.chainId, "setterRatifier");
|
|
41
|
-
const isRootRatified = await readContract(params.viemClient, {
|
|
42
|
-
address: setterRatifier,
|
|
43
|
-
abi: setterRatifierAbi,
|
|
44
|
-
functionName: "isRootRatified",
|
|
45
|
-
args: [params.maker, params.root],
|
|
46
|
-
});
|
|
47
|
-
if (isRootRatified)
|
|
48
|
-
return null;
|
|
49
|
-
return deepFreeze({
|
|
50
|
-
to: setterRatifier,
|
|
51
|
-
value: 0n,
|
|
52
|
-
data: encodeFunctionData({
|
|
53
|
-
abi: setterRatifierAbi,
|
|
54
|
-
functionName: "setIsRootRatified",
|
|
55
|
-
args: [params.maker, params.root, true],
|
|
56
|
-
}),
|
|
57
|
-
action: {
|
|
58
|
-
type: "setterRatifierRatifyRoot",
|
|
59
|
-
args: {
|
|
60
|
-
maker: params.maker,
|
|
61
|
-
root: params.root,
|
|
62
|
-
isRootRatified: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
};
|