@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 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>>;
|
|
@@ -18,14 +18,14 @@ import { NonPositiveWithdrawCollateralAmountError, } from "../../types/index.js"
|
|
|
18
18
|
* @param params.args.onBehalf - Address whose Morpho position the collateral is withdrawn from.
|
|
19
19
|
* @param params.args.receiver - Address that receives the withdrawn collateral.
|
|
20
20
|
* @param params.metadata - Optional analytics metadata attached to the transaction.
|
|
21
|
-
* @returns A deep-frozen `Transaction<
|
|
21
|
+
* @returns A deep-frozen `Transaction<BlueWithdrawCollateralAction>` with `to`, `value`,
|
|
22
22
|
* `data`, and the typed `action` discriminator the simulation layer consumes.
|
|
23
23
|
* @throws {NonPositiveWithdrawCollateralAmountError} when `amount <= 0n`.
|
|
24
24
|
* @example
|
|
25
25
|
* ```ts
|
|
26
|
-
* import {
|
|
26
|
+
* import { blueWithdrawCollateral } from "@morpho-org/morpho-sdk";
|
|
27
27
|
*
|
|
28
|
-
* const tx =
|
|
28
|
+
* const tx = blueWithdrawCollateral({
|
|
29
29
|
* market: { chainId: 1, marketParams },
|
|
30
30
|
* args: {
|
|
31
31
|
* amount: 1_000_000_000_000_000_000n,
|
|
@@ -33,10 +33,10 @@ import { NonPositiveWithdrawCollateralAmountError, } from "../../types/index.js"
|
|
|
33
33
|
* receiver: borrower,
|
|
34
34
|
* },
|
|
35
35
|
* });
|
|
36
|
-
* // tx satisfies Readonly<Transaction<
|
|
36
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export const
|
|
39
|
+
export const blueWithdrawCollateral = ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }) => {
|
|
40
40
|
if (amount <= 0n) {
|
|
41
41
|
throw new NonPositiveWithdrawCollateralAmountError(marketParams.id);
|
|
42
42
|
}
|
|
@@ -56,7 +56,7 @@ export const marketV1WithdrawCollateral = ({ market: { chainId, marketParams },
|
|
|
56
56
|
return deepFreeze({
|
|
57
57
|
...tx,
|
|
58
58
|
action: {
|
|
59
|
-
type: "
|
|
59
|
+
type: "blueWithdrawCollateral",
|
|
60
60
|
args: {
|
|
61
61
|
market: marketParams.id,
|
|
62
62
|
amount,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { BlueActions } from "../entities/blue/index.js";
|
|
2
2
|
export type { VaultV1Actions } from "../entities/vaultV1/index.js";
|
|
3
3
|
export type { VaultV2Actions } from "../entities/vaultV2/index.js";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./blue/index.js";
|
|
5
5
|
export * from "./requirements/index.js";
|
|
6
6
|
export * from "./vaultV1/index.js";
|
|
7
7
|
export * from "./vaultV2/index.js";
|
package/lib/esm/actions/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { type MorphoAuthorizationAction, type Transaction } from "../../types/in
|
|
|
6
6
|
* the `setAuthorization(generalAdapter1, true)` transaction when it does.
|
|
7
7
|
*
|
|
8
8
|
* Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
|
|
9
|
-
* any bundled
|
|
9
|
+
* any bundled Blue path that operates on behalf of the user (`borrow`,
|
|
10
10
|
* `supplyCollateralBorrow`, `repayWithdrawCollateral`).
|
|
11
11
|
*
|
|
12
12
|
* @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
@@ -8,7 +8,7 @@ import { ChainIdMismatchError, } from "../../types/index.js";
|
|
|
8
8
|
* the `setAuthorization(generalAdapter1, true)` transaction when it does.
|
|
9
9
|
*
|
|
10
10
|
* Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
|
|
11
|
-
* any bundled
|
|
11
|
+
* any bundled Blue path that operates on behalf of the user (`borrow`,
|
|
12
12
|
* `supplyCollateralBorrow`, `repayWithdrawCollateral`).
|
|
13
13
|
*
|
|
14
14
|
* @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
package/lib/esm/client/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import type { Client } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
import { MorphoClient } from "./morphoClient.js";
|
|
2
|
+
import { type Metadata, type MorphoClientType } from "../types/index.js";
|
|
4
3
|
/**
|
|
5
|
-
* Returns a viem `extend(...)` function that adds a `morpho` namespace to a viem client.
|
|
6
|
-
* namespace
|
|
7
|
-
*
|
|
4
|
+
* Returns a viem `extend(...)` function that adds a stateless `morpho` namespace to a viem client.
|
|
5
|
+
* The namespace rides on top of the same client (one transport / chain / account) and exposes the
|
|
6
|
+
* protocol entity factories under `client.morpho`, so reads and writes share one client.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
8
|
+
* Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
|
|
9
|
+
* (`client.morpho.vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to the client.
|
|
10
|
+
*
|
|
11
|
+
* @param _options - Optional SDK-wide options forwarded to the `morpho` namespace.
|
|
10
12
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
11
|
-
*
|
|
13
|
+
* `morpho` namespace builds.
|
|
12
14
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
13
|
-
* permit / permit2.
|
|
15
|
+
* permit / permit2. Defaults to `false` (classic approvals only).
|
|
14
16
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
15
17
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
16
18
|
* `client.morpho`.
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
19
|
-
* import { createWalletClient, http } from "viem";
|
|
21
|
+
* import { createWalletClient, http, publicActions } from "viem";
|
|
20
22
|
* import { mainnet } from "viem/chains";
|
|
21
23
|
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
22
24
|
*
|
|
@@ -24,8 +26,12 @@ import { MorphoClient } from "./morphoClient.js";
|
|
|
24
26
|
* chain: mainnet,
|
|
25
27
|
* transport: http(),
|
|
26
28
|
* account: user,
|
|
27
|
-
* })
|
|
29
|
+
* })
|
|
30
|
+
* .extend(publicActions)
|
|
31
|
+
* .extend(morphoViemExtension({ supportSignature: true }));
|
|
28
32
|
*
|
|
33
|
+
* // Native viem reads and Morpho factories share the same client:
|
|
34
|
+
* const block = await client.getBlockNumber();
|
|
29
35
|
* const vault = client.morpho.vaultV1(vaultAddress, 1);
|
|
30
36
|
* const vaultData = await vault.getData();
|
|
31
37
|
* const { buildTx } = vault.deposit({
|
|
@@ -41,5 +47,5 @@ export declare function morphoViemExtension(_options?: {
|
|
|
41
47
|
readonly supportSignature?: boolean;
|
|
42
48
|
readonly supportDeployless?: boolean;
|
|
43
49
|
}): <TClient extends Client>(client: TClient) => {
|
|
44
|
-
morpho:
|
|
50
|
+
morpho: MorphoClientType;
|
|
45
51
|
};
|
|
@@ -1,20 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarketUtils } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { MorphoBlue, MorphoVaultV1, MorphoVaultV2 } from "../entities/index.js";
|
|
4
|
+
import { MarketIdMismatchError, } from "../types/index.js";
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* options.
|
|
6
|
+
* Builds the stateless `morpho` namespace exposed on an extended viem client. Wraps the supplied
|
|
7
|
+
* viem `Client` plus a frozen options bag and exposes factory methods for the protocol entities.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
9
|
+
* Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
|
|
10
|
+
* (`vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to this client.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function createMorphoNamespace(viemClient, options) {
|
|
15
|
+
const namespace = {
|
|
16
|
+
viemClient,
|
|
17
|
+
options: deepFreeze({
|
|
18
|
+
...options,
|
|
19
|
+
metadata: options?.metadata === undefined ? undefined : { ...options.metadata },
|
|
20
|
+
supportSignature: options?.supportSignature ?? false,
|
|
21
|
+
supportDeployless: options?.supportDeployless,
|
|
22
|
+
}),
|
|
23
|
+
vaultV1(vault, chainId) {
|
|
24
|
+
return new MorphoVaultV1(namespace, vault, chainId);
|
|
25
|
+
},
|
|
26
|
+
vaultV2(vault, chainId) {
|
|
27
|
+
return new MorphoVaultV2(namespace, vault, chainId);
|
|
28
|
+
},
|
|
29
|
+
blue(marketParams, chainId) {
|
|
30
|
+
const derivedId = MarketUtils.getMarketId(marketParams);
|
|
31
|
+
// Can happen with one-time/hardcoded/agent-written possibly inconsistent input market params.
|
|
32
|
+
if (marketParams.id !== derivedId) {
|
|
33
|
+
throw new MarketIdMismatchError(marketParams.id, derivedId);
|
|
34
|
+
}
|
|
35
|
+
return new MorphoBlue(namespace, marketParams, chainId);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return namespace;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns a viem `extend(...)` function that adds a stateless `morpho` namespace to a viem client.
|
|
42
|
+
* The namespace rides on top of the same client (one transport / chain / account) and exposes the
|
|
43
|
+
* protocol entity factories under `client.morpho`, so reads and writes share one client.
|
|
44
|
+
*
|
|
45
|
+
* Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
|
|
46
|
+
* (`client.morpho.vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to the client.
|
|
47
|
+
*
|
|
48
|
+
* @param _options - Optional SDK-wide options forwarded to the `morpho` namespace.
|
|
8
49
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
9
|
-
*
|
|
50
|
+
* `morpho` namespace builds.
|
|
10
51
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
11
|
-
* permit / permit2.
|
|
52
|
+
* permit / permit2. Defaults to `false` (classic approvals only).
|
|
12
53
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
13
54
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
14
55
|
* `client.morpho`.
|
|
15
56
|
* @example
|
|
16
57
|
* ```ts
|
|
17
|
-
* import { createWalletClient, http } from "viem";
|
|
58
|
+
* import { createWalletClient, http, publicActions } from "viem";
|
|
18
59
|
* import { mainnet } from "viem/chains";
|
|
19
60
|
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
20
61
|
*
|
|
@@ -22,8 +63,12 @@ import { MorphoClient } from "./morphoClient.js";
|
|
|
22
63
|
* chain: mainnet,
|
|
23
64
|
* transport: http(),
|
|
24
65
|
* account: user,
|
|
25
|
-
* })
|
|
66
|
+
* })
|
|
67
|
+
* .extend(publicActions)
|
|
68
|
+
* .extend(morphoViemExtension({ supportSignature: true }));
|
|
26
69
|
*
|
|
70
|
+
* // Native viem reads and Morpho factories share the same client:
|
|
71
|
+
* const block = await client.getBlockNumber();
|
|
27
72
|
* const vault = client.morpho.vaultV1(vaultAddress, 1);
|
|
28
73
|
* const vaultData = await vault.getData();
|
|
29
74
|
* const { buildTx } = vault.deposit({
|
|
@@ -37,7 +82,7 @@ import { MorphoClient } from "./morphoClient.js";
|
|
|
37
82
|
export function morphoViemExtension(_options) {
|
|
38
83
|
return (client) => {
|
|
39
84
|
return {
|
|
40
|
-
morpho:
|
|
85
|
+
morpho: createMorphoNamespace(client, _options),
|
|
41
86
|
};
|
|
42
87
|
};
|
|
43
88
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AccrualPosition, type Market, type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
3
|
import type { FetchParameters } from "../../types/data.js";
|
|
4
|
-
import { type AssetsOrSharesArgs, type
|
|
4
|
+
import { type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawCollateralAction, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoAuthorizationAction, type MorphoClientType, type ReallocationComputeOptions, type RepayAmountArgs, type Requirement, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
|
|
5
5
|
import { ReallocationData } from "../reallocationData.js";
|
|
6
|
-
export interface
|
|
6
|
+
export interface BlueActions {
|
|
7
7
|
/**
|
|
8
8
|
* Fetches the latest market data with accrued interest.
|
|
9
9
|
*
|
|
@@ -32,7 +32,7 @@ export interface MarketV1Actions {
|
|
|
32
32
|
supplyCollateral: (params: {
|
|
33
33
|
userAddress: Address;
|
|
34
34
|
} & DepositAmountArgs) => {
|
|
35
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
35
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyCollateralAction>>;
|
|
36
36
|
getRequirements: (params?: {
|
|
37
37
|
useSimplePermit?: boolean;
|
|
38
38
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
|
|
@@ -55,7 +55,7 @@ export interface MarketV1Actions {
|
|
|
55
55
|
marketData: Market;
|
|
56
56
|
slippageTolerance?: bigint;
|
|
57
57
|
} & DepositAmountArgs) => {
|
|
58
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
58
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyAction>>;
|
|
59
59
|
getRequirements: (params?: {
|
|
60
60
|
useSimplePermit?: boolean;
|
|
61
61
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
|
|
@@ -89,7 +89,7 @@ export interface MarketV1Actions {
|
|
|
89
89
|
slippageTolerance?: bigint;
|
|
90
90
|
reallocations?: readonly VaultReallocation[];
|
|
91
91
|
} & AssetsOrSharesArgs) => {
|
|
92
|
-
buildTx: () => Readonly<Transaction<
|
|
92
|
+
buildTx: () => Readonly<Transaction<BlueWithdrawAction>>;
|
|
93
93
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
@@ -117,7 +117,7 @@ export interface MarketV1Actions {
|
|
|
117
117
|
slippageTolerance?: bigint;
|
|
118
118
|
reallocations?: readonly VaultReallocation[];
|
|
119
119
|
}) => {
|
|
120
|
-
buildTx: () => Readonly<Transaction<
|
|
120
|
+
buildTx: () => Readonly<Transaction<BlueBorrowAction>>;
|
|
121
121
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
@@ -143,7 +143,7 @@ export interface MarketV1Actions {
|
|
|
143
143
|
positionData: AccrualPosition;
|
|
144
144
|
slippageTolerance?: bigint;
|
|
145
145
|
} & RepayAmountArgs) => {
|
|
146
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
146
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueRepayAction>>;
|
|
147
147
|
getRequirements: (params?: {
|
|
148
148
|
useSimplePermit?: boolean;
|
|
149
149
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
|
|
@@ -168,7 +168,7 @@ export interface MarketV1Actions {
|
|
|
168
168
|
amount: bigint;
|
|
169
169
|
positionData: AccrualPosition;
|
|
170
170
|
}) => {
|
|
171
|
-
buildTx: () => Readonly<Transaction<
|
|
171
|
+
buildTx: () => Readonly<Transaction<BlueWithdrawCollateralAction>>;
|
|
172
172
|
};
|
|
173
173
|
/**
|
|
174
174
|
* Prepares an atomic repay-and-withdraw-collateral transaction.
|
|
@@ -192,7 +192,7 @@ export interface MarketV1Actions {
|
|
|
192
192
|
positionData: AccrualPosition;
|
|
193
193
|
slippageTolerance?: bigint;
|
|
194
194
|
} & RepayAmountArgs) => {
|
|
195
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
195
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueRepayWithdrawCollateralAction>>;
|
|
196
196
|
getRequirements: (params?: {
|
|
197
197
|
useSimplePermit?: boolean;
|
|
198
198
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>> | Requirement)[]>;
|
|
@@ -222,14 +222,14 @@ export interface MarketV1Actions {
|
|
|
222
222
|
slippageTolerance?: bigint;
|
|
223
223
|
reallocations?: readonly VaultReallocation[];
|
|
224
224
|
} & DepositAmountArgs) => {
|
|
225
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
225
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
|
|
226
226
|
getRequirements: (params?: {
|
|
227
227
|
useSimplePermit?: boolean;
|
|
228
228
|
}) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>> | Requirement)[]>;
|
|
229
229
|
};
|
|
230
230
|
/**
|
|
231
231
|
* Prepares an atomic refinance migrating this market's position to another Morpho Blue market
|
|
232
|
-
* that shares the same loan and collateral tokens. See {@link
|
|
232
|
+
* that shares the same loan and collateral tokens. See {@link blueRefinance} for the bundle.
|
|
233
233
|
*
|
|
234
234
|
* Validates ownership, token/id match, that amounts do not exceed the source position, and that
|
|
235
235
|
* both the residual source and the aggregate target position stay within LLTV − buffer. Both
|
|
@@ -263,7 +263,7 @@ export interface MarketV1Actions {
|
|
|
263
263
|
slippageTolerance?: bigint;
|
|
264
264
|
targetReallocations?: readonly VaultReallocation[];
|
|
265
265
|
}) => {
|
|
266
|
-
buildTx: () => Readonly<Transaction<
|
|
266
|
+
buildTx: () => Readonly<Transaction<BlueRefinanceAction>>;
|
|
267
267
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
268
268
|
};
|
|
269
269
|
/**
|
|
@@ -333,7 +333,7 @@ export interface MarketV1Actions {
|
|
|
333
333
|
amount?: never;
|
|
334
334
|
})) => readonly VaultReallocation[];
|
|
335
335
|
}
|
|
336
|
-
export declare class
|
|
336
|
+
export declare class MorphoBlue implements BlueActions {
|
|
337
337
|
private readonly client;
|
|
338
338
|
readonly marketParams: MarketParams;
|
|
339
339
|
private readonly chainId;
|
|
@@ -348,7 +348,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
348
348
|
getRequirements: (params?: {
|
|
349
349
|
useSimplePermit?: boolean;
|
|
350
350
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
351
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
351
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyAction>>;
|
|
352
352
|
};
|
|
353
353
|
withdraw(params: {
|
|
354
354
|
userAddress: Address;
|
|
@@ -358,7 +358,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
358
358
|
reallocations?: readonly VaultReallocation[];
|
|
359
359
|
} & AssetsOrSharesArgs): {
|
|
360
360
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
361
|
-
buildTx: () => Readonly<Transaction<
|
|
361
|
+
buildTx: () => Readonly<Transaction<BlueWithdrawAction>>;
|
|
362
362
|
};
|
|
363
363
|
supplyCollateral({ amount, userAddress, nativeAmount, }: {
|
|
364
364
|
userAddress: Address;
|
|
@@ -366,7 +366,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
366
366
|
getRequirements: (params?: {
|
|
367
367
|
useSimplePermit?: boolean;
|
|
368
368
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
369
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
369
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyCollateralAction>>;
|
|
370
370
|
};
|
|
371
371
|
borrow({ amount, userAddress, positionData, slippageTolerance, reallocations, }: {
|
|
372
372
|
amount: bigint;
|
|
@@ -376,7 +376,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
376
376
|
reallocations?: readonly VaultReallocation[];
|
|
377
377
|
}): {
|
|
378
378
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
379
|
-
buildTx: () => Readonly<Transaction<
|
|
379
|
+
buildTx: () => Readonly<Transaction<BlueBorrowAction>>;
|
|
380
380
|
};
|
|
381
381
|
repay(params: {
|
|
382
382
|
userAddress: Address;
|
|
@@ -386,14 +386,14 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
386
386
|
getRequirements: (reqParams?: {
|
|
387
387
|
useSimplePermit?: boolean;
|
|
388
388
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
|
|
389
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
389
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueRepayAction>>;
|
|
390
390
|
};
|
|
391
391
|
withdrawCollateral({ userAddress, amount, positionData, }: {
|
|
392
392
|
userAddress: Address;
|
|
393
393
|
amount: bigint;
|
|
394
394
|
positionData: AccrualPosition;
|
|
395
395
|
}): {
|
|
396
|
-
buildTx: () => Readonly<Transaction<
|
|
396
|
+
buildTx: () => Readonly<Transaction<BlueWithdrawCollateralAction>>;
|
|
397
397
|
};
|
|
398
398
|
repayWithdrawCollateral(params: {
|
|
399
399
|
userAddress: Address;
|
|
@@ -404,7 +404,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
404
404
|
getRequirements: (reqParams?: {
|
|
405
405
|
useSimplePermit?: boolean;
|
|
406
406
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>>)[]>;
|
|
407
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
407
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueRepayWithdrawCollateralAction>>;
|
|
408
408
|
};
|
|
409
409
|
supplyCollateralBorrow({ amount, userAddress, positionData, borrowAmount, nativeAmount, slippageTolerance, reallocations, }: {
|
|
410
410
|
userAddress: Address;
|
|
@@ -416,7 +416,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
416
416
|
getRequirements: (params?: {
|
|
417
417
|
useSimplePermit?: boolean;
|
|
418
418
|
}) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>> | Readonly<Transaction<MorphoAuthorizationAction>>)[]>;
|
|
419
|
-
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<
|
|
419
|
+
buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
|
|
420
420
|
};
|
|
421
421
|
refinance({ userAddress, positionData, target, collateralAmount, borrowAssets, borrowShares, slippageTolerance, targetReallocations, }: {
|
|
422
422
|
userAddress: Address;
|
|
@@ -432,7 +432,7 @@ export declare class MorphoMarketV1 implements MarketV1Actions {
|
|
|
432
432
|
targetReallocations?: readonly VaultReallocation[];
|
|
433
433
|
}): {
|
|
434
434
|
getRequirements: () => Promise<Readonly<Transaction<MorphoAuthorizationAction>>[]>;
|
|
435
|
-
buildTx: () => Readonly<Transaction<
|
|
435
|
+
buildTx: () => Readonly<Transaction<BlueRefinanceAction>>;
|
|
436
436
|
};
|
|
437
437
|
/**
|
|
438
438
|
* Fetches all on-chain inputs needed to compute public allocator reallocations.
|
|
@@ -2,11 +2,11 @@ import { AccrualPosition, DEFAULT_SLIPPAGE_TOLERANCE, MathLib, } from "@morpho-o
|
|
|
2
2
|
import { fetchAccrualPosition, fetchMarket, fetchPosition, fetchVault, fetchVaultMarketConfig, } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { Time } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { isAddressEqual } from "viem";
|
|
5
|
-
import {
|
|
5
|
+
import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral, getMorphoAuthorizationRequirement, getRequirements, } from "../../actions/index.js";
|
|
6
6
|
import { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinWithdrawSharePrice, computeReallocations, validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateWithdrawAmount, validateWithdrawShares, } from "../../helpers/index.js";
|
|
7
7
|
import { BorrowAmountAndSharesExclusiveError, MarketIdMismatchError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeBorrowSharesError, NegativeNativeAmountError, NegativeSupplyAmountError, NonPositiveAssetAmountError, NonPositiveBorrowAmountError, NonPositiveRepayAmountError, NonPositiveWithdrawAmountError, NonPositiveWithdrawCollateralAmountError, RefinanceExceedsBorrowAssetsError, RefinanceExceedsBorrowSharesError, RefinanceExceedsCollateralError, RefinanceSameMarketError, RefinanceTokenMismatchError, WithdrawExceedsCollateralError, ZeroCollateralAmountError, ZeroSupplyAmountError, } from "../../types/index.js";
|
|
8
8
|
import { ReallocationData } from "../reallocationData.js";
|
|
9
|
-
export class
|
|
9
|
+
export class MorphoBlue {
|
|
10
10
|
client;
|
|
11
11
|
marketParams;
|
|
12
12
|
chainId;
|
|
@@ -65,7 +65,7 @@ export class MorphoMarketV1 {
|
|
|
65
65
|
useSimplePermit: params?.useSimplePermit,
|
|
66
66
|
args: { amount, from: userAddress },
|
|
67
67
|
}),
|
|
68
|
-
buildTx: (requirementSignature) =>
|
|
68
|
+
buildTx: (requirementSignature) => blueSupply({
|
|
69
69
|
market: { chainId: this.chainId, marketParams: this.marketParams },
|
|
70
70
|
args: {
|
|
71
71
|
amount,
|
|
@@ -133,7 +133,7 @@ export class MorphoMarketV1 {
|
|
|
133
133
|
});
|
|
134
134
|
return authTx ? [authTx] : [];
|
|
135
135
|
},
|
|
136
|
-
buildTx: () =>
|
|
136
|
+
buildTx: () => blueWithdraw({
|
|
137
137
|
market: { chainId: this.chainId, marketParams: this.marketParams },
|
|
138
138
|
args: {
|
|
139
139
|
assets,
|
|
@@ -170,7 +170,7 @@ export class MorphoMarketV1 {
|
|
|
170
170
|
useSimplePermit: params?.useSimplePermit,
|
|
171
171
|
args: { amount, from: userAddress },
|
|
172
172
|
}),
|
|
173
|
-
buildTx: (requirementSignature) =>
|
|
173
|
+
buildTx: (requirementSignature) => blueSupplyCollateral({
|
|
174
174
|
market: {
|
|
175
175
|
chainId: this.chainId,
|
|
176
176
|
marketParams: this.marketParams,
|
|
@@ -220,7 +220,7 @@ export class MorphoMarketV1 {
|
|
|
220
220
|
});
|
|
221
221
|
return authTx ? [authTx] : [];
|
|
222
222
|
},
|
|
223
|
-
buildTx: () =>
|
|
223
|
+
buildTx: () => blueBorrow({
|
|
224
224
|
market: {
|
|
225
225
|
chainId: this.chainId,
|
|
226
226
|
marketParams: this.marketParams,
|
|
@@ -306,7 +306,7 @@ export class MorphoMarketV1 {
|
|
|
306
306
|
useSimplePermit: reqParams?.useSimplePermit,
|
|
307
307
|
args: { amount: transferAmount, from: userAddress },
|
|
308
308
|
}),
|
|
309
|
-
buildTx: (requirementSignature) =>
|
|
309
|
+
buildTx: (requirementSignature) => blueRepay({
|
|
310
310
|
market: {
|
|
311
311
|
chainId: this.chainId,
|
|
312
312
|
marketParams: this.marketParams,
|
|
@@ -351,7 +351,7 @@ export class MorphoMarketV1 {
|
|
|
351
351
|
marketId: this.marketParams.id,
|
|
352
352
|
});
|
|
353
353
|
return {
|
|
354
|
-
buildTx: () =>
|
|
354
|
+
buildTx: () => blueWithdrawCollateral({
|
|
355
355
|
market: {
|
|
356
356
|
chainId: this.chainId,
|
|
357
357
|
marketParams: this.marketParams,
|
|
@@ -463,7 +463,7 @@ export class MorphoMarketV1 {
|
|
|
463
463
|
]);
|
|
464
464
|
return [...erc20Requirements, ...(authTx ? [authTx] : [])];
|
|
465
465
|
},
|
|
466
|
-
buildTx: (requirementSignature) =>
|
|
466
|
+
buildTx: (requirementSignature) => blueRepayWithdrawCollateral({
|
|
467
467
|
market: {
|
|
468
468
|
chainId: this.chainId,
|
|
469
469
|
marketParams: this.marketParams,
|
|
@@ -540,7 +540,7 @@ export class MorphoMarketV1 {
|
|
|
540
540
|
]);
|
|
541
541
|
return [...erc20Requirements, ...(authTx ? [authTx] : [])];
|
|
542
542
|
},
|
|
543
|
-
buildTx: (requirementSignature) =>
|
|
543
|
+
buildTx: (requirementSignature) => blueSupplyCollateralBorrow({
|
|
544
544
|
market: {
|
|
545
545
|
chainId: this.chainId,
|
|
546
546
|
marketParams: this.marketParams,
|
|
@@ -697,7 +697,7 @@ export class MorphoMarketV1 {
|
|
|
697
697
|
});
|
|
698
698
|
return authTx ? [authTx] : [];
|
|
699
699
|
},
|
|
700
|
-
buildTx: () =>
|
|
700
|
+
buildTx: () => blueRefinance({
|
|
701
701
|
source: {
|
|
702
702
|
chainId: this.chainId,
|
|
703
703
|
marketParams: this.marketParams,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./blue.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./blue.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
3
|
-
export {
|
|
3
|
+
export { MorphoBlue } from "./blue/index.js";
|
|
4
4
|
export { type InputReallocationData, ReallocationData, } from "./reallocationData.js";
|
|
5
5
|
export { MorphoVaultV1 } from "./vaultV1/index.js";
|
|
6
6
|
export { MorphoVaultV2 } from "./vaultV2/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
2
|
-
export {
|
|
2
|
+
export { MorphoBlue } from "./blue/index.js";
|
|
3
3
|
export { ReallocationData, } from "./reallocationData.js";
|
|
4
4
|
export { MorphoVaultV1 } from "./vaultV1/index.js";
|
|
5
5
|
export { MorphoVaultV2 } from "./vaultV2/index.js";
|
|
@@ -140,7 +140,7 @@ export declare class ReallocationData implements InputReallocationData {
|
|
|
140
140
|
* }).extend(morphoViemExtension());
|
|
141
141
|
*
|
|
142
142
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
143
|
-
* const market = client.morpho.
|
|
143
|
+
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
144
144
|
* const block = await client.getBlock();
|
|
145
145
|
* const reallocationData = await market.getReallocationData({
|
|
146
146
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
@@ -229,7 +229,7 @@ export class ReallocationData {
|
|
|
229
229
|
* }).extend(morphoViemExtension());
|
|
230
230
|
*
|
|
231
231
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
232
|
-
* const market = client.morpho.
|
|
232
|
+
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
233
233
|
* const block = await client.getBlock();
|
|
234
234
|
* const reallocationData = await market.getReallocationData({
|
|
235
235
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
@@ -59,7 +59,7 @@ export class MorphoVaultV2 {
|
|
|
59
59
|
}
|
|
60
60
|
const totalAssets = amount + (nativeAmount ?? 0n);
|
|
61
61
|
// Accrue interest forward to bound the on-chain share price at execution.
|
|
62
|
-
// Mirrors
|
|
62
|
+
// Mirrors blue repay's 2h forward-accrual buffer.
|
|
63
63
|
const accrualTimestamp = MathLib.max(Time.timestamp(), vaultData.lastUpdate) + Time.s.from.h(2n);
|
|
64
64
|
const { vault: accruedVault } = vaultData.accrueInterest(accrualTimestamp);
|
|
65
65
|
const shares = accruedVault.toShares(totalAssets);
|
|
@@ -42,7 +42,7 @@ import { type ReallocationComputeOptions, type VaultReallocation } from "../type
|
|
|
42
42
|
*
|
|
43
43
|
* const userAddress = "0x000000000000000000000000000000000000dEaD";
|
|
44
44
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
45
|
-
* const market = client.morpho.
|
|
45
|
+
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
46
46
|
* const block = await client.getBlock();
|
|
47
47
|
* const reallocationData = await market.getReallocationData({
|
|
48
48
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
@@ -95,7 +95,7 @@ const capVaultWithdrawals = (withdrawals, assets) => {
|
|
|
95
95
|
*
|
|
96
96
|
* const userAddress = "0x000000000000000000000000000000000000dEaD";
|
|
97
97
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
98
|
-
* const market = client.morpho.
|
|
98
|
+
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
99
99
|
* const block = await client.getBlock();
|
|
100
100
|
* const reallocationData = await market.getReallocationData({
|
|
101
101
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|