@morpho-org/morpho-sdk 3.1.1 → 4.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/README.md +63 -13
- package/lib/cjs/actions/{marketV1 → blue}/borrow.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/borrow.js +8 -8
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/buildReallocationActions.d.ts +1 -1
- package/lib/cjs/actions/{marketV1 → blue}/buildReallocationActions.js +1 -1
- package/lib/cjs/actions/{marketV1 → blue}/index.d.ts +1 -0
- package/lib/cjs/actions/{marketV1 → blue}/index.js +1 -0
- package/lib/cjs/actions/blue/refinance.d.ts +117 -0
- package/lib/cjs/actions/blue/refinance.js +218 -0
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/repay.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/repay.js +8 -8
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/repayWithdrawCollateral.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/repayWithdrawCollateral.js +8 -8
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/supply.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/supply.js +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/supplyCollateral.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/supplyCollateral.js +8 -8
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/supplyCollateralBorrow.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/supplyCollateralBorrow.js +8 -8
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/withdraw.d.ts +11 -11
- package/lib/cjs/actions/{marketV1 → blue}/withdraw.js +10 -10
- package/lib/{esm/actions/marketV1 → cjs/actions/blue}/withdrawCollateral.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/withdrawCollateral.js +8 -8
- package/lib/cjs/actions/index.d.ts +2 -2
- package/lib/cjs/actions/index.js +1 -1
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +1 -1
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +1 -1
- package/lib/cjs/client/index.d.ts +0 -1
- package/lib/cjs/client/index.js +0 -1
- package/lib/cjs/client/morphoViemExtension.d.ts +17 -11
- package/lib/cjs/client/morphoViemExtension.js +55 -10
- package/lib/cjs/entities/{marketV1/marketV1.d.ts → blue/blue.d.ts} +76 -21
- package/lib/cjs/entities/{marketV1/marketV1.js → blue/blue.js} +169 -11
- package/lib/cjs/entities/blue/index.d.ts +1 -0
- package/lib/cjs/entities/{marketV1 → blue}/index.js +1 -1
- package/lib/cjs/entities/index.d.ts +1 -1
- package/lib/cjs/entities/index.js +3 -3
- package/lib/cjs/entities/reallocationData.d.ts +1 -1
- package/lib/cjs/entities/reallocationData.js +1 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -1
- package/lib/cjs/helpers/computeReallocations.d.ts +1 -1
- package/lib/cjs/helpers/computeReallocations.js +1 -1
- package/lib/cjs/helpers/validate.d.ts +2 -2
- package/lib/cjs/helpers/validate.js +2 -2
- package/lib/cjs/types/action.d.ts +21 -9
- package/lib/cjs/types/client.d.ts +5 -4
- package/lib/cjs/types/error.d.ts +57 -0
- package/lib/cjs/types/error.js +82 -1
- package/lib/esm/actions/{marketV1 → blue}/borrow.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/borrow.js +6 -6
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/buildReallocationActions.d.ts +1 -1
- package/lib/esm/actions/{marketV1 → blue}/buildReallocationActions.js +1 -1
- package/lib/esm/actions/{marketV1 → blue}/index.d.ts +1 -0
- package/lib/esm/actions/{marketV1 → blue}/index.js +1 -0
- package/lib/esm/actions/blue/refinance.d.ts +117 -0
- package/lib/esm/actions/blue/refinance.js +214 -0
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/repay.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/repay.js +6 -6
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/repayWithdrawCollateral.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/repayWithdrawCollateral.js +6 -6
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/supply.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/supply.js +6 -6
- package/lib/esm/actions/{marketV1 → blue}/supplyCollateral.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/supplyCollateral.js +6 -6
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/supplyCollateralBorrow.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/supplyCollateralBorrow.js +6 -6
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/withdraw.d.ts +11 -11
- package/lib/esm/actions/{marketV1 → blue}/withdraw.js +8 -8
- package/lib/{cjs/actions/marketV1 → esm/actions/blue}/withdrawCollateral.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/withdrawCollateral.js +6 -6
- package/lib/esm/actions/index.d.ts +2 -2
- package/lib/esm/actions/index.js +1 -1
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +1 -1
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +1 -1
- package/lib/esm/client/index.d.ts +0 -1
- package/lib/esm/client/index.js +0 -1
- package/lib/esm/client/morphoViemExtension.d.ts +17 -11
- package/lib/esm/client/morphoViemExtension.js +55 -10
- package/lib/esm/entities/{marketV1/marketV1.d.ts → blue/blue.d.ts} +76 -21
- package/lib/esm/entities/{marketV1/marketV1.js → blue/blue.js} +170 -12
- package/lib/esm/entities/blue/index.d.ts +1 -0
- package/lib/esm/entities/blue/index.js +1 -0
- package/lib/esm/entities/index.d.ts +1 -1
- package/lib/esm/entities/index.js +1 -1
- package/lib/esm/entities/reallocationData.d.ts +1 -1
- package/lib/esm/entities/reallocationData.js +1 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -1
- package/lib/esm/helpers/computeReallocations.d.ts +1 -1
- package/lib/esm/helpers/computeReallocations.js +1 -1
- package/lib/esm/helpers/validate.d.ts +2 -2
- package/lib/esm/helpers/validate.js +2 -2
- package/lib/esm/types/action.d.ts +21 -9
- package/lib/esm/types/client.d.ts +5 -4
- package/lib/esm/types/error.d.ts +57 -0
- package/lib/esm/types/error.js +72 -0
- package/package.json +6 -6
- package/lib/cjs/client/morphoClient.d.ts +0 -152
- package/lib/cjs/client/morphoClient.js +0 -162
- package/lib/cjs/entities/marketV1/index.d.ts +0 -1
- package/lib/esm/client/morphoClient.d.ts +0 -152
- package/lib/esm/client/morphoClient.js +0 -158
- package/lib/esm/entities/marketV1/index.d.ts +0 -1
- package/lib/esm/entities/marketV1/index.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueRepay = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
@@ -35,7 +35,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
35
35
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
36
36
|
* loan-token transfer.
|
|
37
37
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
38
|
-
* @returns A deep-frozen `Transaction<
|
|
38
|
+
* @returns A deep-frozen `Transaction<BlueRepayAction>` with `to`, `value`, `data`, and the
|
|
39
39
|
* typed `action` discriminator the simulation layer consumes.
|
|
40
40
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
41
41
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -51,9 +51,9 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
51
51
|
* signature is missing its expiration.
|
|
52
52
|
* @example
|
|
53
53
|
* ```ts
|
|
54
|
-
* import {
|
|
54
|
+
* import { blueRepay } from "@morpho-org/morpho-sdk";
|
|
55
55
|
*
|
|
56
|
-
* const tx =
|
|
56
|
+
* const tx = blueRepay({
|
|
57
57
|
* market: { chainId: 1, marketParams },
|
|
58
58
|
* args: {
|
|
59
59
|
* assets: 500_000_000n,
|
|
@@ -64,10 +64,10 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
64
64
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
65
65
|
* },
|
|
66
66
|
* });
|
|
67
|
-
* // tx satisfies Readonly<Transaction<
|
|
67
|
+
* // tx satisfies Readonly<Transaction<BlueRepayAction>>
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
|
-
const
|
|
70
|
+
const blueRepay = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
|
|
71
71
|
(0, index_js_2.validateRepayParams)({
|
|
72
72
|
assets,
|
|
73
73
|
shares,
|
|
@@ -117,7 +117,7 @@ const marketV1Repay = ({ market: { chainId, marketParams }, args: { assets, shar
|
|
|
117
117
|
return (0, morpho_ts_1.deepFreeze)({
|
|
118
118
|
...tx,
|
|
119
119
|
action: {
|
|
120
|
-
type: "
|
|
120
|
+
type: "blueRepay",
|
|
121
121
|
args: {
|
|
122
122
|
market: marketParams.id,
|
|
123
123
|
assets,
|
|
@@ -130,4 +130,4 @@ const marketV1Repay = ({ market: { chainId, marketParams }, args: { assets, shar
|
|
|
130
130
|
},
|
|
131
131
|
});
|
|
132
132
|
};
|
|
133
|
-
exports.
|
|
133
|
+
exports.blueRepay = blueRepay;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueRepayWithdrawCollateralAction, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueRepayWithdrawCollateral}. */
|
|
5
|
+
export interface BlueRepayWithdrawCollateralParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -68,7 +68,7 @@ export interface MarketV1RepayWithdrawCollateralParams {
|
|
|
68
68
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
69
69
|
* loan-token transfer.
|
|
70
70
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
71
|
-
* @returns A deep-frozen `Transaction<
|
|
71
|
+
* @returns A deep-frozen `Transaction<BlueRepayWithdrawCollateralAction>` with `to`,
|
|
72
72
|
* `value`, `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
73
73
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
74
74
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -85,9 +85,9 @@ export interface MarketV1RepayWithdrawCollateralParams {
|
|
|
85
85
|
* signature is missing its expiration.
|
|
86
86
|
* @example
|
|
87
87
|
* ```ts
|
|
88
|
-
* import {
|
|
88
|
+
* import { blueRepayWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
89
89
|
*
|
|
90
|
-
* const tx =
|
|
90
|
+
* const tx = blueRepayWithdrawCollateral({
|
|
91
91
|
* market: { chainId: 1, marketParams },
|
|
92
92
|
* args: {
|
|
93
93
|
* assets: 500_000_000n,
|
|
@@ -99,7 +99,7 @@ export interface MarketV1RepayWithdrawCollateralParams {
|
|
|
99
99
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
100
100
|
* },
|
|
101
101
|
* });
|
|
102
|
-
* // tx satisfies Readonly<Transaction<
|
|
102
|
+
* // tx satisfies Readonly<Transaction<BlueRepayWithdrawCollateralAction>>
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
export declare const
|
|
105
|
+
export declare const blueRepayWithdrawCollateral: ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, withdrawAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }: BlueRepayWithdrawCollateralParams) => Readonly<Transaction<BlueRepayWithdrawCollateralAction>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueRepayWithdrawCollateral = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
@@ -45,7 +45,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
45
45
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
46
46
|
* loan-token transfer.
|
|
47
47
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
48
|
-
* @returns A deep-frozen `Transaction<
|
|
48
|
+
* @returns A deep-frozen `Transaction<BlueRepayWithdrawCollateralAction>` with `to`,
|
|
49
49
|
* `value`, `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
50
50
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
51
51
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -62,9 +62,9 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
62
62
|
* signature is missing its expiration.
|
|
63
63
|
* @example
|
|
64
64
|
* ```ts
|
|
65
|
-
* import {
|
|
65
|
+
* import { blueRepayWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
66
66
|
*
|
|
67
|
-
* const tx =
|
|
67
|
+
* const tx = blueRepayWithdrawCollateral({
|
|
68
68
|
* market: { chainId: 1, marketParams },
|
|
69
69
|
* args: {
|
|
70
70
|
* assets: 500_000_000n,
|
|
@@ -76,10 +76,10 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
76
76
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
77
77
|
* },
|
|
78
78
|
* });
|
|
79
|
-
* // tx satisfies Readonly<Transaction<
|
|
79
|
+
* // tx satisfies Readonly<Transaction<BlueRepayWithdrawCollateralAction>>
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
const
|
|
82
|
+
const blueRepayWithdrawCollateral = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, withdrawAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
|
|
83
83
|
(0, index_js_2.validateRepayParams)({
|
|
84
84
|
assets,
|
|
85
85
|
shares,
|
|
@@ -137,7 +137,7 @@ const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParams }, ar
|
|
|
137
137
|
return (0, morpho_ts_1.deepFreeze)({
|
|
138
138
|
...tx,
|
|
139
139
|
action: {
|
|
140
|
-
type: "
|
|
140
|
+
type: "blueRepayWithdrawCollateral",
|
|
141
141
|
args: {
|
|
142
142
|
market: marketParams.id,
|
|
143
143
|
repayAssets: assets,
|
|
@@ -151,4 +151,4 @@ const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParams }, ar
|
|
|
151
151
|
},
|
|
152
152
|
});
|
|
153
153
|
};
|
|
154
|
-
exports.
|
|
154
|
+
exports.blueRepayWithdrawCollateral = blueRepayWithdrawCollateral;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueSupplyAction, type DepositAmountArgs, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueSupply}. */
|
|
5
|
+
export interface BlueSupplyParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -38,7 +38,7 @@ export interface MarketV1SupplyParams {
|
|
|
38
38
|
* absent, the bundle uses a plain `erc20TransferFrom` and assumes the user has already
|
|
39
39
|
* approved `GeneralAdapter1`.
|
|
40
40
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
41
|
-
* @returns A deep-frozen `Transaction<
|
|
41
|
+
* @returns A deep-frozen `Transaction<BlueSupplyAction>` with `to`, `value`, `data`, and the
|
|
42
42
|
* typed `action` discriminator the simulation layer consumes.
|
|
43
43
|
* @throws {NegativeSupplyAmountError} when `amount < 0n`.
|
|
44
44
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -53,9 +53,9 @@ export interface MarketV1SupplyParams {
|
|
|
53
53
|
* is provided and the signed amount differs from `args.amount`.
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
56
|
-
* import {
|
|
56
|
+
* import { blueSupply } from "@morpho-org/morpho-sdk";
|
|
57
57
|
*
|
|
58
|
-
* const tx =
|
|
58
|
+
* const tx = blueSupply({
|
|
59
59
|
* market: { chainId: 1, marketParams },
|
|
60
60
|
* args: {
|
|
61
61
|
* amount: 1_000_000_000n,
|
|
@@ -63,7 +63,7 @@ export interface MarketV1SupplyParams {
|
|
|
63
63
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
64
64
|
* },
|
|
65
65
|
* });
|
|
66
|
-
* // tx satisfies Readonly<Transaction<
|
|
66
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
export declare const
|
|
69
|
+
export declare const blueSupply: ({ market: { chainId, marketParams }, args: { amount, onBehalf, maxSharePrice, requirementSignature, nativeAmount, }, metadata, }: BlueSupplyParams) => Readonly<Transaction<BlueSupplyAction>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueSupply = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const index_js_1 = require("../../bundler/index.js");
|
|
@@ -30,7 +30,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
30
30
|
* absent, the bundle uses a plain `erc20TransferFrom` and assumes the user has already
|
|
31
31
|
* approved `GeneralAdapter1`.
|
|
32
32
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
33
|
-
* @returns A deep-frozen `Transaction<
|
|
33
|
+
* @returns A deep-frozen `Transaction<BlueSupplyAction>` with `to`, `value`, `data`, and the
|
|
34
34
|
* typed `action` discriminator the simulation layer consumes.
|
|
35
35
|
* @throws {NegativeSupplyAmountError} when `amount < 0n`.
|
|
36
36
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -45,9 +45,9 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
45
45
|
* is provided and the signed amount differs from `args.amount`.
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
|
48
|
-
* import {
|
|
48
|
+
* import { blueSupply } from "@morpho-org/morpho-sdk";
|
|
49
49
|
*
|
|
50
|
-
* const tx =
|
|
50
|
+
* const tx = blueSupply({
|
|
51
51
|
* market: { chainId: 1, marketParams },
|
|
52
52
|
* args: {
|
|
53
53
|
* amount: 1_000_000_000n,
|
|
@@ -55,10 +55,10 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
55
55
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
56
56
|
* },
|
|
57
57
|
* });
|
|
58
|
-
* // tx satisfies Readonly<Transaction<
|
|
58
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
const
|
|
61
|
+
const blueSupply = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, maxSharePrice, requirementSignature, nativeAmount, }, metadata, }) => {
|
|
62
62
|
if (amount < 0n) {
|
|
63
63
|
throw new index_js_3.NegativeSupplyAmountError(marketParams.id);
|
|
64
64
|
}
|
|
@@ -114,7 +114,7 @@ const marketV1Supply = ({ market: { chainId, marketParams }, args: { amount = 0n
|
|
|
114
114
|
return (0, morpho_ts_1.deepFreeze)({
|
|
115
115
|
...tx,
|
|
116
116
|
action: {
|
|
117
|
-
type: "
|
|
117
|
+
type: "blueSupply",
|
|
118
118
|
args: {
|
|
119
119
|
market: marketParams.id,
|
|
120
120
|
amount: totalAssets,
|
|
@@ -125,4 +125,4 @@ const marketV1Supply = ({ market: { chainId, marketParams }, args: { amount = 0n
|
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
|
-
exports.
|
|
128
|
+
exports.blueSupply = blueSupply;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueSupplyCollateralAction, type DepositAmountArgs, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueSupplyCollateral}. */
|
|
5
|
+
export interface BlueSupplyCollateralParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -33,7 +33,7 @@ export interface MarketV1SupplyCollateralParams {
|
|
|
33
33
|
* @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
|
|
34
34
|
* supply. Requires the collateral token to be the chain's wNative.
|
|
35
35
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
36
|
-
* @returns A deep-frozen `Transaction<
|
|
36
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralAction>` with `to`, `value`, `data`,
|
|
37
37
|
* and the typed `action` discriminator the simulation layer consumes.
|
|
38
38
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
39
39
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -49,13 +49,13 @@ export interface MarketV1SupplyCollateralParams {
|
|
|
49
49
|
* signature is missing its expiration.
|
|
50
50
|
* @example
|
|
51
51
|
* ```ts
|
|
52
|
-
* import {
|
|
52
|
+
* import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
|
|
53
53
|
*
|
|
54
|
-
* const tx =
|
|
54
|
+
* const tx = blueSupplyCollateral({
|
|
55
55
|
* market: { chainId: 1, marketParams },
|
|
56
56
|
* args: { amount: 1_000_000_000_000_000_000n, onBehalf },
|
|
57
57
|
* });
|
|
58
|
-
* // tx satisfies Readonly<Transaction<
|
|
58
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export declare const
|
|
61
|
+
export declare const blueSupplyCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, requirementSignature, nativeAmount }, metadata, }: BlueSupplyCollateralParams) => Readonly<Transaction<BlueSupplyCollateralAction>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueSupplyCollateral = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const index_js_1 = require("../../bundler/index.js");
|
|
@@ -27,7 +27,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
27
27
|
* @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
|
|
28
28
|
* supply. Requires the collateral token to be the chain's wNative.
|
|
29
29
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
30
|
-
* @returns A deep-frozen `Transaction<
|
|
30
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralAction>` with `to`, `value`, `data`,
|
|
31
31
|
* and the typed `action` discriminator the simulation layer consumes.
|
|
32
32
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
33
33
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -43,16 +43,16 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
|
|
|
43
43
|
* signature is missing its expiration.
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
-
* import {
|
|
46
|
+
* import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
|
|
47
47
|
*
|
|
48
|
-
* const tx =
|
|
48
|
+
* const tx = blueSupplyCollateral({
|
|
49
49
|
* market: { chainId: 1, marketParams },
|
|
50
50
|
* args: { amount: 1_000_000_000_000_000_000n, onBehalf },
|
|
51
51
|
* });
|
|
52
|
-
* // tx satisfies Readonly<Transaction<
|
|
52
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
const
|
|
55
|
+
const blueSupplyCollateral = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, requirementSignature, nativeAmount }, metadata, }) => {
|
|
56
56
|
if (amount < 0n) {
|
|
57
57
|
throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
|
|
58
58
|
}
|
|
@@ -102,7 +102,7 @@ const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { a
|
|
|
102
102
|
return (0, morpho_ts_1.deepFreeze)({
|
|
103
103
|
...tx,
|
|
104
104
|
action: {
|
|
105
|
-
type: "
|
|
105
|
+
type: "blueSupplyCollateral",
|
|
106
106
|
args: {
|
|
107
107
|
market: marketParams.id,
|
|
108
108
|
amount: totalCollateral,
|
|
@@ -112,4 +112,4 @@ const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { a
|
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
|
-
exports.
|
|
115
|
+
exports.blueSupplyCollateral = blueSupplyCollateral;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueSupplyCollateralBorrowAction, type DepositAmountArgs, type Metadata, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueSupplyCollateralBorrow}. */
|
|
5
|
+
export interface BlueSupplyCollateralBorrowParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -47,7 +47,7 @@ export interface MarketV1SupplyCollateralBorrowParams {
|
|
|
47
47
|
* @param params.args.reallocations - Optional vault reallocations to execute between the supply
|
|
48
48
|
* and borrow legs, computed by the entity layer.
|
|
49
49
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
50
|
-
* @returns A deep-frozen `Transaction<
|
|
50
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
|
|
51
51
|
* `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
52
52
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
53
53
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -75,9 +75,9 @@ export interface MarketV1SupplyCollateralBorrowParams {
|
|
|
75
75
|
* reallocation withdrawals are not strictly sorted by market id.
|
|
76
76
|
* @example
|
|
77
77
|
* ```ts
|
|
78
|
-
* import {
|
|
78
|
+
* import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
|
|
79
79
|
*
|
|
80
|
-
* const tx =
|
|
80
|
+
* const tx = blueSupplyCollateralBorrow({
|
|
81
81
|
* market: { chainId: 1, marketParams },
|
|
82
82
|
* args: {
|
|
83
83
|
* amount: 1_000_000_000_000_000_000n,
|
|
@@ -87,7 +87,7 @@ export interface MarketV1SupplyCollateralBorrowParams {
|
|
|
87
87
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
|
|
88
88
|
* },
|
|
89
89
|
* });
|
|
90
|
-
* // tx satisfies Readonly<Transaction<
|
|
90
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
export declare const
|
|
93
|
+
export declare const blueSupplyCollateralBorrow: ({ market: { chainId, marketParams }, args: { amount, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }: BlueSupplyCollateralBorrowParams) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueSupplyCollateralBorrow = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const index_js_1 = require("../../bundler/index.js");
|
|
@@ -36,7 +36,7 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
36
36
|
* @param params.args.reallocations - Optional vault reallocations to execute between the supply
|
|
37
37
|
* and borrow legs, computed by the entity layer.
|
|
38
38
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
39
|
-
* @returns A deep-frozen `Transaction<
|
|
39
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
|
|
40
40
|
* `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
41
41
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
42
42
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -64,9 +64,9 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
64
64
|
* reallocation withdrawals are not strictly sorted by market id.
|
|
65
65
|
* @example
|
|
66
66
|
* ```ts
|
|
67
|
-
* import {
|
|
67
|
+
* import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
|
|
68
68
|
*
|
|
69
|
-
* const tx =
|
|
69
|
+
* const tx = blueSupplyCollateralBorrow({
|
|
70
70
|
* market: { chainId: 1, marketParams },
|
|
71
71
|
* args: {
|
|
72
72
|
* amount: 1_000_000_000_000_000_000n,
|
|
@@ -76,10 +76,10 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
76
76
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
|
|
77
77
|
* },
|
|
78
78
|
* });
|
|
79
|
-
* // tx satisfies Readonly<Transaction<
|
|
79
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
const
|
|
82
|
+
const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams }, args: { amount = 0n, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }) => {
|
|
83
83
|
if (amount < 0n) {
|
|
84
84
|
throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
|
|
85
85
|
}
|
|
@@ -145,7 +145,7 @@ const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, arg
|
|
|
145
145
|
return (0, morpho_ts_1.deepFreeze)({
|
|
146
146
|
...tx,
|
|
147
147
|
action: {
|
|
148
|
-
type: "
|
|
148
|
+
type: "blueSupplyCollateralBorrow",
|
|
149
149
|
args: {
|
|
150
150
|
market: marketParams.id,
|
|
151
151
|
collateralAmount: totalCollateral,
|
|
@@ -159,4 +159,4 @@ const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, arg
|
|
|
159
159
|
},
|
|
160
160
|
});
|
|
161
161
|
};
|
|
162
|
-
exports.
|
|
162
|
+
exports.blueSupplyCollateralBorrow = blueSupplyCollateralBorrow;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueWithdrawAction, type Metadata, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueWithdraw}. */
|
|
5
|
+
export interface BlueWithdrawParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -18,7 +18,7 @@ export interface MarketV1WithdrawParams {
|
|
|
18
18
|
minSharePrice: bigint;
|
|
19
19
|
/**
|
|
20
20
|
* Vault reallocations to execute before withdrawing. Compute via
|
|
21
|
-
* `
|
|
21
|
+
* `MorphoBlue.getReallocations({ operation: "withdraw", amount })` or directly via
|
|
22
22
|
* `computeReallocations({ operation: "withdraw", amount, ... })`.
|
|
23
23
|
*/
|
|
24
24
|
reallocations?: readonly VaultReallocation[];
|
|
@@ -40,7 +40,7 @@ export interface MarketV1WithdrawParams {
|
|
|
40
40
|
* computed on-chain directly to `receiver`; no skim is required.
|
|
41
41
|
*
|
|
42
42
|
* The withdraw is performed on behalf of the transaction initiator (signer) — there is no
|
|
43
|
-
* separate `onBehalf` field; mirror `
|
|
43
|
+
* separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
|
|
44
44
|
* with the user when none is provided. Requires the user to have authorized `GeneralAdapter1`
|
|
45
45
|
* on Morpho.
|
|
46
46
|
*
|
|
@@ -54,21 +54,21 @@ export interface MarketV1WithdrawParams {
|
|
|
54
54
|
* @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
|
|
55
55
|
* computed by the entity layer.
|
|
56
56
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
57
|
-
* @returns A deep-frozen `Transaction<
|
|
57
|
+
* @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
|
|
58
58
|
* the typed `action` discriminator the simulation layer consumes.
|
|
59
59
|
* @throws {NonPositiveWithdrawAmountError} when both `assets` and `shares` are zero, or either is negative.
|
|
60
60
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
|
|
61
61
|
* @throws {NegativeWithdrawMinSharePriceError} when `minSharePrice < 0n` (zero is allowed despite
|
|
62
|
-
* the class name — pattern preserved for symmetry with `
|
|
62
|
+
* the class name — pattern preserved for symmetry with `blueBorrow`).
|
|
63
63
|
* @throws Reallocation errors from `buildReallocationActions` when `reallocations` is malformed
|
|
64
64
|
* (see its JSDoc: `NegativeReallocationFeeError`, `EmptyReallocationWithdrawalsError`,
|
|
65
65
|
* `NonPositiveReallocationAmountError`, `ReallocationWithdrawalOnTargetMarketError`,
|
|
66
66
|
* `UnsortedReallocationWithdrawalsError`).
|
|
67
67
|
* @example
|
|
68
68
|
* ```ts
|
|
69
|
-
* import {
|
|
69
|
+
* import { blueWithdraw } from "@morpho-org/morpho-sdk";
|
|
70
70
|
*
|
|
71
|
-
* const tx =
|
|
71
|
+
* const tx = blueWithdraw({
|
|
72
72
|
* market: { chainId: 1, marketParams },
|
|
73
73
|
* args: {
|
|
74
74
|
* assets: 1_000_000_000n,
|
|
@@ -77,7 +77,7 @@ export interface MarketV1WithdrawParams {
|
|
|
77
77
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinWithdrawSharePrice` from market state + slippage tolerance
|
|
78
78
|
* },
|
|
79
79
|
* });
|
|
80
|
-
* // tx satisfies Readonly<Transaction<
|
|
80
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
export declare const
|
|
83
|
+
export declare const blueWithdraw: ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }: BlueWithdrawParams) => Readonly<Transaction<BlueWithdrawAction>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.blueWithdraw = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
const index_js_1 = require("../../bundler/index.js");
|
|
6
6
|
const index_js_2 = require("../../helpers/index.js");
|
|
@@ -21,7 +21,7 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
21
21
|
* computed on-chain directly to `receiver`; no skim is required.
|
|
22
22
|
*
|
|
23
23
|
* The withdraw is performed on behalf of the transaction initiator (signer) — there is no
|
|
24
|
-
* separate `onBehalf` field; mirror `
|
|
24
|
+
* separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
|
|
25
25
|
* with the user when none is provided. Requires the user to have authorized `GeneralAdapter1`
|
|
26
26
|
* on Morpho.
|
|
27
27
|
*
|
|
@@ -35,21 +35,21 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
35
35
|
* @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
|
|
36
36
|
* computed by the entity layer.
|
|
37
37
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
38
|
-
* @returns A deep-frozen `Transaction<
|
|
38
|
+
* @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
|
|
39
39
|
* the typed `action` discriminator the simulation layer consumes.
|
|
40
40
|
* @throws {NonPositiveWithdrawAmountError} when both `assets` and `shares` are zero, or either is negative.
|
|
41
41
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
|
|
42
42
|
* @throws {NegativeWithdrawMinSharePriceError} when `minSharePrice < 0n` (zero is allowed despite
|
|
43
|
-
* the class name — pattern preserved for symmetry with `
|
|
43
|
+
* the class name — pattern preserved for symmetry with `blueBorrow`).
|
|
44
44
|
* @throws Reallocation errors from `buildReallocationActions` when `reallocations` is malformed
|
|
45
45
|
* (see its JSDoc: `NegativeReallocationFeeError`, `EmptyReallocationWithdrawalsError`,
|
|
46
46
|
* `NonPositiveReallocationAmountError`, `ReallocationWithdrawalOnTargetMarketError`,
|
|
47
47
|
* `UnsortedReallocationWithdrawalsError`).
|
|
48
48
|
* @example
|
|
49
49
|
* ```ts
|
|
50
|
-
* import {
|
|
50
|
+
* import { blueWithdraw } from "@morpho-org/morpho-sdk";
|
|
51
51
|
*
|
|
52
|
-
* const tx =
|
|
52
|
+
* const tx = blueWithdraw({
|
|
53
53
|
* market: { chainId: 1, marketParams },
|
|
54
54
|
* args: {
|
|
55
55
|
* assets: 1_000_000_000n,
|
|
@@ -58,10 +58,10 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
|
|
|
58
58
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinWithdrawSharePrice` from market state + slippage tolerance
|
|
59
59
|
* },
|
|
60
60
|
* });
|
|
61
|
-
* // tx satisfies Readonly<Transaction<
|
|
61
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
const
|
|
64
|
+
const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }) => {
|
|
65
65
|
// Mutual exclusion is detected on "both values present" (either non-zero),
|
|
66
66
|
// before sign checks — otherwise `{ assets: -1n, shares: 5n }` would be
|
|
67
67
|
// misreported as a positivity error rather than the actual mode conflict.
|
|
@@ -95,7 +95,7 @@ const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { assets, s
|
|
|
95
95
|
return (0, morpho_ts_1.deepFreeze)({
|
|
96
96
|
...tx,
|
|
97
97
|
action: {
|
|
98
|
-
type: "
|
|
98
|
+
type: "blueWithdraw",
|
|
99
99
|
args: {
|
|
100
100
|
market: marketParams.id,
|
|
101
101
|
assets,
|
|
@@ -107,4 +107,4 @@ const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { assets, s
|
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
|
-
exports.
|
|
110
|
+
exports.blueWithdraw = blueWithdraw;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import { type
|
|
4
|
-
/** Parameters for {@link
|
|
5
|
-
export interface
|
|
3
|
+
import { type BlueWithdrawCollateralAction, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueWithdrawCollateral}. */
|
|
5
|
+
export interface BlueWithdrawCollateralParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -28,14 +28,14 @@ export interface MarketV1WithdrawCollateralParams {
|
|
|
28
28
|
* @param params.args.onBehalf - Address whose Morpho position the collateral is withdrawn from.
|
|
29
29
|
* @param params.args.receiver - Address that receives the withdrawn collateral.
|
|
30
30
|
* @param params.metadata - Optional analytics metadata attached to the transaction.
|
|
31
|
-
* @returns A deep-frozen `Transaction<
|
|
31
|
+
* @returns A deep-frozen `Transaction<BlueWithdrawCollateralAction>` with `to`, `value`,
|
|
32
32
|
* `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
33
33
|
* @throws {NonPositiveWithdrawCollateralAmountError} when `amount <= 0n`.
|
|
34
34
|
* @example
|
|
35
35
|
* ```ts
|
|
36
|
-
* import {
|
|
36
|
+
* import { blueWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
37
37
|
*
|
|
38
|
-
* const tx =
|
|
38
|
+
* const tx = blueWithdrawCollateral({
|
|
39
39
|
* market: { chainId: 1, marketParams },
|
|
40
40
|
* args: {
|
|
41
41
|
* amount: 1_000_000_000_000_000_000n,
|
|
@@ -43,7 +43,7 @@ export interface MarketV1WithdrawCollateralParams {
|
|
|
43
43
|
* receiver: borrower,
|
|
44
44
|
* },
|
|
45
45
|
* });
|
|
46
|
-
* // tx satisfies Readonly<Transaction<
|
|
46
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
-
export declare const
|
|
49
|
+
export declare const blueWithdrawCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }: BlueWithdrawCollateralParams) => Readonly<Transaction<BlueWithdrawCollateralAction>>;
|