@morpho-org/morpho-sdk 3.2.0 → 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 +19 -16
- 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/{esm/actions/marketV1 → cjs/actions/blue}/refinance.d.ts +8 -8
- package/lib/cjs/actions/{marketV1 → blue}/refinance.js +8 -8
- 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/cjs/actions/{marketV1 → 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} +22 -22
- package/lib/cjs/entities/{marketV1/marketV1.js → blue/blue.js} +12 -12
- 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 +10 -10
- package/lib/cjs/types/client.d.ts +5 -4
- 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/{cjs/actions/marketV1 → esm/actions/blue}/refinance.d.ts +8 -8
- package/lib/esm/actions/{marketV1 → blue}/refinance.js +6 -6
- 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/esm/actions/{marketV1 → 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} +22 -22
- package/lib/esm/entities/{marketV1/marketV1.js → blue/blue.js} +11 -11
- 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 +10 -10
- package/lib/esm/types/client.d.ts +5 -4
- package/package.json +7 -7
- 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
- /package/lib/cjs/actions/{marketV1 → blue}/index.d.ts +0 -0
- /package/lib/cjs/actions/{marketV1 → blue}/index.js +0 -0
- /package/lib/esm/actions/{marketV1 → blue}/index.d.ts +0 -0
- /package/lib/esm/actions/{marketV1 → blue}/index.js +0 -0
|
@@ -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 BlueRefinanceAction, type Metadata, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueRefinance}. */
|
|
5
|
+
export interface BlueRefinanceParams {
|
|
6
6
|
source: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -78,7 +78,7 @@ export interface MarketV1RefinanceParams {
|
|
|
78
78
|
* @param params.args.maxRepaySharePrice - Maximum repay share price (ray) on the source.
|
|
79
79
|
* @param params.args.targetReallocations - PublicAllocator reallocations into the target, run before the supply leg.
|
|
80
80
|
* @param params.metadata - Optional analytics metadata appended to `tx.data`.
|
|
81
|
-
* @returns A deep-frozen `Transaction<
|
|
81
|
+
* @returns A deep-frozen `Transaction<BlueRefinanceAction>`.
|
|
82
82
|
* @remarks `borrowAssets` and `borrowShares` describe different markets (target borrow vs. source
|
|
83
83
|
* repay); in shares mode the entity passes both. Caller-facing mutual exclusivity is enforced at the entity layer.
|
|
84
84
|
* @throws {ZeroCollateralAmountError} when `collateralAmount <= 0n`.
|
|
@@ -97,9 +97,9 @@ export interface MarketV1RefinanceParams {
|
|
|
97
97
|
* @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly sorted by market id.
|
|
98
98
|
* @example
|
|
99
99
|
* ```ts
|
|
100
|
-
* import {
|
|
100
|
+
* import { blueRefinance } from "@morpho-org/morpho-sdk";
|
|
101
101
|
*
|
|
102
|
-
* const tx =
|
|
102
|
+
* const tx = blueRefinance({
|
|
103
103
|
* source: { chainId: 1, marketParams: sourceParams },
|
|
104
104
|
* target: { marketParams: targetParams },
|
|
105
105
|
* args: {
|
|
@@ -111,7 +111,7 @@ export interface MarketV1RefinanceParams {
|
|
|
111
111
|
* maxRepaySharePrice: 1_500_000_000_000_000_000_000_000_000n,
|
|
112
112
|
* },
|
|
113
113
|
* });
|
|
114
|
-
* // tx satisfies Readonly<Transaction<
|
|
114
|
+
* // tx satisfies Readonly<Transaction<BlueRefinanceAction>>
|
|
115
115
|
* ```
|
|
116
116
|
*/
|
|
117
|
-
export declare const
|
|
117
|
+
export declare const blueRefinance: ({ source: { chainId, marketParams: sourceParams }, target: { marketParams: targetParams }, args: { user, collateralAmount, borrowAssets, borrowShares, minBorrowSharePrice, maxRepaySharePrice, targetReallocations, }, metadata, }: BlueRefinanceParams) => Readonly<Transaction<BlueRefinanceAction>>;
|
|
@@ -53,7 +53,7 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
53
53
|
* @param params.args.maxRepaySharePrice - Maximum repay share price (ray) on the source.
|
|
54
54
|
* @param params.args.targetReallocations - PublicAllocator reallocations into the target, run before the supply leg.
|
|
55
55
|
* @param params.metadata - Optional analytics metadata appended to `tx.data`.
|
|
56
|
-
* @returns A deep-frozen `Transaction<
|
|
56
|
+
* @returns A deep-frozen `Transaction<BlueRefinanceAction>`.
|
|
57
57
|
* @remarks `borrowAssets` and `borrowShares` describe different markets (target borrow vs. source
|
|
58
58
|
* repay); in shares mode the entity passes both. Caller-facing mutual exclusivity is enforced at the entity layer.
|
|
59
59
|
* @throws {ZeroCollateralAmountError} when `collateralAmount <= 0n`.
|
|
@@ -72,9 +72,9 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
72
72
|
* @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly sorted by market id.
|
|
73
73
|
* @example
|
|
74
74
|
* ```ts
|
|
75
|
-
* import {
|
|
75
|
+
* import { blueRefinance } from "@morpho-org/morpho-sdk";
|
|
76
76
|
*
|
|
77
|
-
* const tx =
|
|
77
|
+
* const tx = blueRefinance({
|
|
78
78
|
* source: { chainId: 1, marketParams: sourceParams },
|
|
79
79
|
* target: { marketParams: targetParams },
|
|
80
80
|
* args: {
|
|
@@ -86,10 +86,10 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
86
86
|
* maxRepaySharePrice: 1_500_000_000_000_000_000_000_000_000n,
|
|
87
87
|
* },
|
|
88
88
|
* });
|
|
89
|
-
* // tx satisfies Readonly<Transaction<
|
|
89
|
+
* // tx satisfies Readonly<Transaction<BlueRefinanceAction>>
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
export const
|
|
92
|
+
export const blueRefinance = ({ source: { chainId, marketParams: sourceParams }, target: { marketParams: targetParams }, args: { user, collateralAmount, borrowAssets = 0n, borrowShares = 0n, minBorrowSharePrice, maxRepaySharePrice, targetReallocations, }, metadata, }) => {
|
|
93
93
|
if (collateralAmount <= 0n) {
|
|
94
94
|
throw new ZeroCollateralAmountError(sourceParams.id);
|
|
95
95
|
}
|
|
@@ -197,7 +197,7 @@ export const marketV1Refinance = ({ source: { chainId, marketParams: sourceParam
|
|
|
197
197
|
return deepFreeze({
|
|
198
198
|
...tx,
|
|
199
199
|
action: {
|
|
200
|
-
type: "
|
|
200
|
+
type: "blueRefinance",
|
|
201
201
|
args: {
|
|
202
202
|
sourceMarket: sourceParams.id,
|
|
203
203
|
targetMarket: targetParams.id,
|
|
@@ -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 { BlueRepayAction, Metadata, RequirementSignature, Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueRepay}. */
|
|
5
|
+
export interface BlueRepayParams {
|
|
6
6
|
market: {
|
|
7
7
|
readonly chainId: number;
|
|
8
8
|
readonly marketParams: MarketParams;
|
|
@@ -56,7 +56,7 @@ export interface MarketV1RepayParams {
|
|
|
56
56
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
57
57
|
* loan-token transfer.
|
|
58
58
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
59
|
-
* @returns A deep-frozen `Transaction<
|
|
59
|
+
* @returns A deep-frozen `Transaction<BlueRepayAction>` with `to`, `value`, `data`, and the
|
|
60
60
|
* typed `action` discriminator the simulation layer consumes.
|
|
61
61
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
62
62
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -72,9 +72,9 @@ export interface MarketV1RepayParams {
|
|
|
72
72
|
* signature is missing its expiration.
|
|
73
73
|
* @example
|
|
74
74
|
* ```ts
|
|
75
|
-
* import {
|
|
75
|
+
* import { blueRepay } from "@morpho-org/morpho-sdk";
|
|
76
76
|
*
|
|
77
|
-
* const tx =
|
|
77
|
+
* const tx = blueRepay({
|
|
78
78
|
* market: { chainId: 1, marketParams },
|
|
79
79
|
* args: {
|
|
80
80
|
* assets: 500_000_000n,
|
|
@@ -85,7 +85,7 @@ export interface MarketV1RepayParams {
|
|
|
85
85
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
86
86
|
* },
|
|
87
87
|
* });
|
|
88
|
-
* // tx satisfies Readonly<Transaction<
|
|
88
|
+
* // tx satisfies Readonly<Transaction<BlueRepayAction>>
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
export declare const
|
|
91
|
+
export declare const blueRepay: ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }: BlueRepayParams) => Readonly<Transaction<BlueRepayAction>>;
|
|
@@ -32,7 +32,7 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
32
32
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
33
33
|
* loan-token transfer.
|
|
34
34
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
35
|
-
* @returns A deep-frozen `Transaction<
|
|
35
|
+
* @returns A deep-frozen `Transaction<BlueRepayAction>` with `to`, `value`, `data`, and the
|
|
36
36
|
* typed `action` discriminator the simulation layer consumes.
|
|
37
37
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
38
38
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -48,9 +48,9 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
48
48
|
* signature is missing its expiration.
|
|
49
49
|
* @example
|
|
50
50
|
* ```ts
|
|
51
|
-
* import {
|
|
51
|
+
* import { blueRepay } from "@morpho-org/morpho-sdk";
|
|
52
52
|
*
|
|
53
|
-
* const tx =
|
|
53
|
+
* const tx = blueRepay({
|
|
54
54
|
* market: { chainId: 1, marketParams },
|
|
55
55
|
* args: {
|
|
56
56
|
* assets: 500_000_000n,
|
|
@@ -61,10 +61,10 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
61
61
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
62
62
|
* },
|
|
63
63
|
* });
|
|
64
|
-
* // tx satisfies Readonly<Transaction<
|
|
64
|
+
* // tx satisfies Readonly<Transaction<BlueRepayAction>>
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export const
|
|
67
|
+
export const blueRepay = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
|
|
68
68
|
validateRepayParams({
|
|
69
69
|
assets,
|
|
70
70
|
shares,
|
|
@@ -114,7 +114,7 @@ export const marketV1Repay = ({ market: { chainId, marketParams }, args: { asset
|
|
|
114
114
|
return deepFreeze({
|
|
115
115
|
...tx,
|
|
116
116
|
action: {
|
|
117
|
-
type: "
|
|
117
|
+
type: "blueRepay",
|
|
118
118
|
args: {
|
|
119
119
|
market: marketParams.id,
|
|
120
120
|
assets,
|
|
@@ -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>>;
|
|
@@ -42,7 +42,7 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
42
42
|
* @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
|
|
43
43
|
* loan-token transfer.
|
|
44
44
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
45
|
-
* @returns A deep-frozen `Transaction<
|
|
45
|
+
* @returns A deep-frozen `Transaction<BlueRepayWithdrawCollateralAction>` with `to`,
|
|
46
46
|
* `value`, `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
47
47
|
* @throws {NonPositiveRepayMaxSharePriceError} when `maxSharePrice <= 0n`.
|
|
48
48
|
* @throws {NonPositiveRepayAmountError} when either `assets` or `shares` is negative, or when
|
|
@@ -59,9 +59,9 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
59
59
|
* signature is missing its expiration.
|
|
60
60
|
* @example
|
|
61
61
|
* ```ts
|
|
62
|
-
* import {
|
|
62
|
+
* import { blueRepayWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
63
63
|
*
|
|
64
|
-
* const tx =
|
|
64
|
+
* const tx = blueRepayWithdrawCollateral({
|
|
65
65
|
* market: { chainId: 1, marketParams },
|
|
66
66
|
* args: {
|
|
67
67
|
* assets: 500_000_000n,
|
|
@@ -73,10 +73,10 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
73
73
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
74
74
|
* },
|
|
75
75
|
* });
|
|
76
|
-
* // tx satisfies Readonly<Transaction<
|
|
76
|
+
* // tx satisfies Readonly<Transaction<BlueRepayWithdrawCollateralAction>>
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export const
|
|
79
|
+
export const blueRepayWithdrawCollateral = ({ market: { chainId, marketParams }, args: { assets, shares, transferAmount, withdrawAmount, onBehalf, receiver, maxSharePrice, requirementSignature, }, metadata, }) => {
|
|
80
80
|
validateRepayParams({
|
|
81
81
|
assets,
|
|
82
82
|
shares,
|
|
@@ -134,7 +134,7 @@ export const marketV1RepayWithdrawCollateral = ({ market: { chainId, marketParam
|
|
|
134
134
|
return deepFreeze({
|
|
135
135
|
...tx,
|
|
136
136
|
action: {
|
|
137
|
-
type: "
|
|
137
|
+
type: "blueRepayWithdrawCollateral",
|
|
138
138
|
args: {
|
|
139
139
|
market: marketParams.id,
|
|
140
140
|
repayAssets: assets,
|
|
@@ -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>>;
|
|
@@ -27,7 +27,7 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
27
27
|
* absent, the bundle uses a plain `erc20TransferFrom` and assumes the user has already
|
|
28
28
|
* approved `GeneralAdapter1`.
|
|
29
29
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
30
|
-
* @returns A deep-frozen `Transaction<
|
|
30
|
+
* @returns A deep-frozen `Transaction<BlueSupplyAction>` with `to`, `value`, `data`, and the
|
|
31
31
|
* typed `action` discriminator the simulation layer consumes.
|
|
32
32
|
* @throws {NegativeSupplyAmountError} when `amount < 0n`.
|
|
33
33
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -42,9 +42,9 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
42
42
|
* is provided and the signed amount differs from `args.amount`.
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
|
-
* import {
|
|
45
|
+
* import { blueSupply } from "@morpho-org/morpho-sdk";
|
|
46
46
|
*
|
|
47
|
-
* const tx =
|
|
47
|
+
* const tx = blueSupply({
|
|
48
48
|
* market: { chainId: 1, marketParams },
|
|
49
49
|
* args: {
|
|
50
50
|
* amount: 1_000_000_000n,
|
|
@@ -52,10 +52,10 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
52
52
|
* maxSharePrice: 1_010_000_000_000_000_000_000_000_000n, // RAY-scaled, 1.01x
|
|
53
53
|
* },
|
|
54
54
|
* });
|
|
55
|
-
* // tx satisfies Readonly<Transaction<
|
|
55
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
export const
|
|
58
|
+
export const blueSupply = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, maxSharePrice, requirementSignature, nativeAmount, }, metadata, }) => {
|
|
59
59
|
if (amount < 0n) {
|
|
60
60
|
throw new NegativeSupplyAmountError(marketParams.id);
|
|
61
61
|
}
|
|
@@ -111,7 +111,7 @@ export const marketV1Supply = ({ market: { chainId, marketParams }, args: { amou
|
|
|
111
111
|
return deepFreeze({
|
|
112
112
|
...tx,
|
|
113
113
|
action: {
|
|
114
|
-
type: "
|
|
114
|
+
type: "blueSupply",
|
|
115
115
|
args: {
|
|
116
116
|
market: marketParams.id,
|
|
117
117
|
amount: totalAssets,
|
|
@@ -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>>;
|
|
@@ -24,7 +24,7 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
24
24
|
* @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
|
|
25
25
|
* supply. Requires the collateral token to be the chain's wNative.
|
|
26
26
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
27
|
-
* @returns A deep-frozen `Transaction<
|
|
27
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralAction>` with `to`, `value`, `data`,
|
|
28
28
|
* and the typed `action` discriminator the simulation layer consumes.
|
|
29
29
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
30
30
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -40,16 +40,16 @@ import { getRequirementsAction } from "../requirements/getRequirementsAction.js"
|
|
|
40
40
|
* signature is missing its expiration.
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* import {
|
|
43
|
+
* import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
|
|
44
44
|
*
|
|
45
|
-
* const tx =
|
|
45
|
+
* const tx = blueSupplyCollateral({
|
|
46
46
|
* market: { chainId: 1, marketParams },
|
|
47
47
|
* args: { amount: 1_000_000_000_000_000_000n, onBehalf },
|
|
48
48
|
* });
|
|
49
|
-
* // tx satisfies Readonly<Transaction<
|
|
49
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
export const
|
|
52
|
+
export const blueSupplyCollateral = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, requirementSignature, nativeAmount }, metadata, }) => {
|
|
53
53
|
if (amount < 0n) {
|
|
54
54
|
throw new NonPositiveAssetAmountError(marketParams.collateralToken);
|
|
55
55
|
}
|
|
@@ -99,7 +99,7 @@ export const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, ar
|
|
|
99
99
|
return deepFreeze({
|
|
100
100
|
...tx,
|
|
101
101
|
action: {
|
|
102
|
-
type: "
|
|
102
|
+
type: "blueSupplyCollateral",
|
|
103
103
|
args: {
|
|
104
104
|
market: marketParams.id,
|
|
105
105
|
amount: totalCollateral,
|
|
@@ -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>>;
|
|
@@ -33,7 +33,7 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
33
33
|
* @param params.args.reallocations - Optional vault reallocations to execute between the supply
|
|
34
34
|
* and borrow legs, computed by the entity layer.
|
|
35
35
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
36
|
-
* @returns A deep-frozen `Transaction<
|
|
36
|
+
* @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
|
|
37
37
|
* `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
38
38
|
* @throws {NonPositiveAssetAmountError} when `amount < 0n`.
|
|
39
39
|
* @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
|
|
@@ -61,9 +61,9 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
61
61
|
* reallocation withdrawals are not strictly sorted by market id.
|
|
62
62
|
* @example
|
|
63
63
|
* ```ts
|
|
64
|
-
* import {
|
|
64
|
+
* import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
|
|
65
65
|
*
|
|
66
|
-
* const tx =
|
|
66
|
+
* const tx = blueSupplyCollateralBorrow({
|
|
67
67
|
* market: { chainId: 1, marketParams },
|
|
68
68
|
* args: {
|
|
69
69
|
* amount: 1_000_000_000_000_000_000n,
|
|
@@ -73,10 +73,10 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
73
73
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
|
|
74
74
|
* },
|
|
75
75
|
* });
|
|
76
|
-
* // tx satisfies Readonly<Transaction<
|
|
76
|
+
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export const
|
|
79
|
+
export const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams }, args: { amount = 0n, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }) => {
|
|
80
80
|
if (amount < 0n) {
|
|
81
81
|
throw new NonPositiveAssetAmountError(marketParams.collateralToken);
|
|
82
82
|
}
|
|
@@ -142,7 +142,7 @@ export const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams
|
|
|
142
142
|
return deepFreeze({
|
|
143
143
|
...tx,
|
|
144
144
|
action: {
|
|
145
|
-
type: "
|
|
145
|
+
type: "blueSupplyCollateralBorrow",
|
|
146
146
|
args: {
|
|
147
147
|
market: marketParams.id,
|
|
148
148
|
collateralAmount: totalCollateral,
|
|
@@ -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>>;
|
|
@@ -18,7 +18,7 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
18
18
|
* computed on-chain directly to `receiver`; no skim is required.
|
|
19
19
|
*
|
|
20
20
|
* The withdraw is performed on behalf of the transaction initiator (signer) — there is no
|
|
21
|
-
* separate `onBehalf` field; mirror `
|
|
21
|
+
* separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
|
|
22
22
|
* with the user when none is provided. Requires the user to have authorized `GeneralAdapter1`
|
|
23
23
|
* on Morpho.
|
|
24
24
|
*
|
|
@@ -32,21 +32,21 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
32
32
|
* @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
|
|
33
33
|
* computed by the entity layer.
|
|
34
34
|
* @param params.metadata - Optional analytics metadata attached to the bundle.
|
|
35
|
-
* @returns A deep-frozen `Transaction<
|
|
35
|
+
* @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
|
|
36
36
|
* the typed `action` discriminator the simulation layer consumes.
|
|
37
37
|
* @throws {NonPositiveWithdrawAmountError} when both `assets` and `shares` are zero, or either is negative.
|
|
38
38
|
* @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
|
|
39
39
|
* @throws {NegativeWithdrawMinSharePriceError} when `minSharePrice < 0n` (zero is allowed despite
|
|
40
|
-
* the class name — pattern preserved for symmetry with `
|
|
40
|
+
* the class name — pattern preserved for symmetry with `blueBorrow`).
|
|
41
41
|
* @throws Reallocation errors from `buildReallocationActions` when `reallocations` is malformed
|
|
42
42
|
* (see its JSDoc: `NegativeReallocationFeeError`, `EmptyReallocationWithdrawalsError`,
|
|
43
43
|
* `NonPositiveReallocationAmountError`, `ReallocationWithdrawalOnTargetMarketError`,
|
|
44
44
|
* `UnsortedReallocationWithdrawalsError`).
|
|
45
45
|
* @example
|
|
46
46
|
* ```ts
|
|
47
|
-
* import {
|
|
47
|
+
* import { blueWithdraw } from "@morpho-org/morpho-sdk";
|
|
48
48
|
*
|
|
49
|
-
* const tx =
|
|
49
|
+
* const tx = blueWithdraw({
|
|
50
50
|
* market: { chainId: 1, marketParams },
|
|
51
51
|
* args: {
|
|
52
52
|
* assets: 1_000_000_000n,
|
|
@@ -55,10 +55,10 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
|
|
|
55
55
|
* minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinWithdrawSharePrice` from market state + slippage tolerance
|
|
56
56
|
* },
|
|
57
57
|
* });
|
|
58
|
-
* // tx satisfies Readonly<Transaction<
|
|
58
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export const
|
|
61
|
+
export const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }) => {
|
|
62
62
|
// Mutual exclusion is detected on "both values present" (either non-zero),
|
|
63
63
|
// before sign checks — otherwise `{ assets: -1n, shares: 5n }` would be
|
|
64
64
|
// misreported as a positivity error rather than the actual mode conflict.
|
|
@@ -92,7 +92,7 @@ export const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { as
|
|
|
92
92
|
return deepFreeze({
|
|
93
93
|
...tx,
|
|
94
94
|
action: {
|
|
95
|
-
type: "
|
|
95
|
+
type: "blueWithdraw",
|
|
96
96
|
args: {
|
|
97
97
|
market: marketParams.id,
|
|
98
98
|
assets,
|