@morpho-org/morpho-sdk 9.3.0-next.0 → 9.4.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 +6 -4
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +4 -5
- package/lib/cjs/actions/blue/index.d.ts +1 -0
- package/lib/cjs/actions/blue/index.js +1 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +60 -0
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +79 -0
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +3 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/blue/blue.d.ts +85 -9
- package/lib/cjs/entities/blue/blue.js +85 -3
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +1 -2
- package/lib/cjs/entities/midnight/midnight.js +4 -5
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +5 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +15 -12
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +0 -8
- package/lib/cjs/entities/vaultV1/vaultV1.js +0 -4
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +9 -37
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -36
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -10
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.d.ts +5 -4
- package/lib/cjs/helpers/deadShares.js +5 -6
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +2 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/types/action.d.ts +15 -1
- package/lib/cjs/types/error.d.ts +35 -6
- package/lib/cjs/types/error.js +42 -7
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/blue/index.d.ts +1 -0
- package/lib/esm/actions/blue/index.js +1 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +60 -0
- package/lib/esm/actions/blue/withdrawBuyCallback.js +75 -0
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +85 -9
- package/lib/esm/entities/blue/blue.js +87 -5
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +1 -2
- package/lib/esm/entities/midnight/midnight.js +5 -6
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +5 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +15 -12
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +0 -8
- package/lib/esm/entities/vaultV1/vaultV1.js +0 -4
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +9 -37
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -36
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.d.ts +5 -4
- package/lib/esm/helpers/deadShares.js +6 -7
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/types/action.d.ts +15 -1
- package/lib/esm/types/error.d.ts +35 -6
- package/lib/esm/types/error.js +36 -6
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -24,9 +24,9 @@ General Vault V1 operations remain supported.
|
|
|
24
24
|
pnpm add @morpho-org/morpho-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Read [
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
Read [Dead-share validators](./DEAD-SHARE-PROTECTION.md) for the exported checks. Builders do not
|
|
28
|
+
enforce the dead-deposit rule; integrators should validate their snapshot before building.
|
|
29
|
+
Snapshot-free Blue `supply` remains deprecated.
|
|
30
30
|
|
|
31
31
|
Upgrading from v8? Read the [v8 → v9 migration guide](./MIGRATION-v8-to-v9.md) for the approval
|
|
32
32
|
API removals and the new unlimited-approval behavior.
|
|
@@ -54,6 +54,7 @@ BlueBundlesV1, and the remaining rows identify their destination.
|
|
|
54
54
|
| | `forceRedeem` | Vault multicall |
|
|
55
55
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
56
56
|
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
57
|
+
| **Blue** | `withdrawBuyCallback` | Morpho Blue (direct `withdraw` for a BlueBuyCallback's owner) |
|
|
57
58
|
| **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `takeRepayWithdrawCollateral`, `repayWithdrawCollateral`, `takeWithdraw` | MidnightBundlesV2 (Ethereum, Base, Arc, Robinhood, Tempo) |
|
|
58
59
|
| | `supplyCollateral`, `withdrawCollateral`, `redeem` | Direct call |
|
|
59
60
|
| | `makeLend`, `makeBorrow`, `makeWithdraw`, `makeRepay`, `supplyCollateralMakeBorrow`, `supplyBlueMakeLend`, `cancelOffers` | MidnightBundlesV2 (Ethereum, Base, Arc, Robinhood, Tempo) |
|
|
@@ -76,7 +77,8 @@ Robinhood Chain, Arc, and X Layer. Custom deployments can still be configured wi
|
|
|
76
77
|
## How it works
|
|
77
78
|
|
|
78
79
|
Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`. All Blue
|
|
79
|
-
writes use this lazy shape while still encoding one direct BlueBundlesV1 call
|
|
80
|
+
writes use this lazy shape while still encoding one direct BlueBundlesV1 call, except
|
|
81
|
+
`withdrawBuyCallback`, which encodes one direct Morpho Blue `withdraw`. Vault deposits,
|
|
80
82
|
`withdraw`, and `redeem` use the same shape for token or vault-share authorization to
|
|
81
83
|
VaultBundlesV1. Vault `inKindRedeem` and `forceWithdraw` use it so callers can await
|
|
82
84
|
`getRequirements()` to check share authorization to VaultExitBundlesV1 — and, for `inKindRedeem`,
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
6
|
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
7
|
-
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
7
|
+
export { blueBuyCallbackAbi as midnightBlueBuyCallbackAbi, blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi as midnightEcrecoverAuthorizerAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
8
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
9
9
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
|
10
10
|
readonly type: "constructor";
|
package/lib/cjs/abis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.
|
|
3
|
+
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.midnightBlueBuyCallbackAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
6
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -8,13 +8,11 @@ Object.defineProperty(exports, "blueAdaptiveCurveIrmAbi", { enumerable: true, ge
|
|
|
8
8
|
Object.defineProperty(exports, "blueAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.blueAbi; } });
|
|
9
9
|
Object.defineProperty(exports, "blueOracleAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.blueOracleAbi; } });
|
|
10
10
|
Object.defineProperty(exports, "erc2612Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc2612Abi; } });
|
|
11
|
+
Object.defineProperty(exports, "erc3643Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc3643Abi; } });
|
|
12
|
+
Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc3643IdentityRegistryAbi; } });
|
|
11
13
|
Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
|
|
12
14
|
Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
|
|
13
15
|
Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
|
|
14
|
-
Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
|
|
15
|
-
Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
|
|
16
|
-
Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
|
|
17
|
-
Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
|
|
18
16
|
Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
|
|
19
17
|
Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
|
|
20
18
|
Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
|
|
@@ -34,6 +32,7 @@ Object.defineProperty(exports, "whitelistControllerAggregatorV2Abi", { enumerabl
|
|
|
34
32
|
Object.defineProperty(exports, "wrappedBackedTokenAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.wrappedBackedTokenAbi; } });
|
|
35
33
|
Object.defineProperty(exports, "wstEthAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.wstEthAbi; } });
|
|
36
34
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
35
|
+
Object.defineProperty(exports, "midnightBlueBuyCallbackAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackAbi; } });
|
|
37
36
|
Object.defineProperty(exports, "midnightBlueBuyCallbackFactoryAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackFactoryAbi; } });
|
|
38
37
|
Object.defineProperty(exports, "midnightEcrecoverAuthorizerAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverAuthorizerAbi; } });
|
|
39
38
|
Object.defineProperty(exports, "midnightEcrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
|
|
@@ -22,4 +22,5 @@ __exportStar(require("./supply.js"), exports);
|
|
|
22
22
|
__exportStar(require("./supplyCollateral.js"), exports);
|
|
23
23
|
__exportStar(require("./supplyCollateralBorrow.js"), exports);
|
|
24
24
|
__exportStar(require("./withdraw.js"), exports);
|
|
25
|
+
__exportStar(require("./withdrawBuyCallback.js"), exports);
|
|
25
26
|
__exportStar(require("./withdrawCollateral.js"), exports);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { type Address } from "viem";
|
|
3
|
+
import { type BlueWithdrawBuyCallbackAction, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
|
+
/** Parameters for {@link blueWithdrawBuyCallback}. */
|
|
5
|
+
export interface BlueWithdrawBuyCallbackParams {
|
|
6
|
+
/** Chain and scoped Morpho Blue market. */
|
|
7
|
+
readonly market: {
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
readonly marketParams: MarketParams;
|
|
10
|
+
};
|
|
11
|
+
/** Direct Morpho Blue withdrawal arguments. */
|
|
12
|
+
readonly args: {
|
|
13
|
+
/** BlueBuyCallback whose supply position is withdrawn. */
|
|
14
|
+
readonly callbackAddress: Address;
|
|
15
|
+
/** Callback owner, who sends the transaction and receives the loan assets. */
|
|
16
|
+
readonly userAddress: Address;
|
|
17
|
+
/** Supply shares burned. */
|
|
18
|
+
readonly shares: bigint;
|
|
19
|
+
};
|
|
20
|
+
/** Optional transaction metadata suffix. */
|
|
21
|
+
readonly metadata?: Metadata;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
|
|
25
|
+
*
|
|
26
|
+
* The call is `withdraw(marketParams, 0, shares, callbackAddress, userAddress)` on Morpho Blue, not
|
|
27
|
+
* BlueBundlesV1: the callback authorizes its owner on Blue, so the owner withdraws on its behalf
|
|
28
|
+
* directly. Use `client.morpho.blue(...).withdrawBuyCallback(...)` to check the callback, its owner,
|
|
29
|
+
* the Blue authorization and the market liquidity first.
|
|
30
|
+
*
|
|
31
|
+
* @param params - Withdrawal encoding parameters.
|
|
32
|
+
* @param params.market.chainId - Chain containing Morpho Blue.
|
|
33
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
34
|
+
* @param params.args.callbackAddress - BlueBuyCallback whose supply position is withdrawn.
|
|
35
|
+
* @param params.args.userAddress - Callback owner, sender and receiver of the loan assets.
|
|
36
|
+
* @param params.args.shares - Supply shares burned.
|
|
37
|
+
* @param params.metadata - Optional transaction metadata.
|
|
38
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawBuyCallbackAction>>` whose `to` address
|
|
39
|
+
* is Morpho Blue.
|
|
40
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
41
|
+
* @throws {NegativeInputError} when `shares` is negative.
|
|
42
|
+
* @throws {NonPositiveInputError} when `shares` is zero.
|
|
43
|
+
* @throws {InputExceedsMaxError} when `shares` exceeds `uint256`.
|
|
44
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
45
|
+
* @throws {UnknownAddressError} when Morpho Blue is not registered.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
49
|
+
* import { blueWithdrawBuyCallback } from "@morpho-org/morpho-sdk";
|
|
50
|
+
* import { zeroAddress } from "viem";
|
|
51
|
+
* import { mainnet } from "viem/chains";
|
|
52
|
+
*
|
|
53
|
+
* const tx = blueWithdrawBuyCallback({
|
|
54
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
55
|
+
* args: { callbackAddress: zeroAddress, userAddress: zeroAddress, shares: 1_000_000n },
|
|
56
|
+
* });
|
|
57
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const blueWithdrawBuyCallback: (params: BlueWithdrawBuyCallbackParams) => Readonly<Transaction<BlueWithdrawBuyCallbackAction>>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blueWithdrawBuyCallback = void 0;
|
|
4
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const abis_js_1 = require("../../abis.js");
|
|
7
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
9
|
+
const index_js_2 = require("../../types/index.js");
|
|
10
|
+
/**
|
|
11
|
+
* Encodes a direct Morpho Blue `withdraw` of a BlueBuyCallback's supply shares to its owner.
|
|
12
|
+
*
|
|
13
|
+
* The call is `withdraw(marketParams, 0, shares, callbackAddress, userAddress)` on Morpho Blue, not
|
|
14
|
+
* BlueBundlesV1: the callback authorizes its owner on Blue, so the owner withdraws on its behalf
|
|
15
|
+
* directly. Use `client.morpho.blue(...).withdrawBuyCallback(...)` to check the callback, its owner,
|
|
16
|
+
* the Blue authorization and the market liquidity first.
|
|
17
|
+
*
|
|
18
|
+
* @param params - Withdrawal encoding parameters.
|
|
19
|
+
* @param params.market.chainId - Chain containing Morpho Blue.
|
|
20
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
21
|
+
* @param params.args.callbackAddress - BlueBuyCallback whose supply position is withdrawn.
|
|
22
|
+
* @param params.args.userAddress - Callback owner, sender and receiver of the loan assets.
|
|
23
|
+
* @param params.args.shares - Supply shares burned.
|
|
24
|
+
* @param params.metadata - Optional transaction metadata.
|
|
25
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueWithdrawBuyCallbackAction>>` whose `to` address
|
|
26
|
+
* is Morpho Blue.
|
|
27
|
+
* @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
|
|
28
|
+
* @throws {NegativeInputError} when `shares` is negative.
|
|
29
|
+
* @throws {NonPositiveInputError} when `shares` is zero.
|
|
30
|
+
* @throws {InputExceedsMaxError} when `shares` exceeds `uint256`.
|
|
31
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
32
|
+
* @throws {UnknownAddressError} when Morpho Blue is not registered.
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
36
|
+
* import { blueWithdrawBuyCallback } from "@morpho-org/morpho-sdk";
|
|
37
|
+
* import { zeroAddress } from "viem";
|
|
38
|
+
* import { mainnet } from "viem/chains";
|
|
39
|
+
*
|
|
40
|
+
* const tx = blueWithdrawBuyCallback({
|
|
41
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
42
|
+
* args: { callbackAddress: zeroAddress, userAddress: zeroAddress, shares: 1_000_000n },
|
|
43
|
+
* });
|
|
44
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
const blueWithdrawBuyCallback = (params) => {
|
|
48
|
+
const { chainId, marketParams } = params.market;
|
|
49
|
+
const { callbackAddress, userAddress, shares } = params.args;
|
|
50
|
+
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
51
|
+
(0, validate_js_1.validateUint256Field)("shares", shares);
|
|
52
|
+
if (shares === 0n)
|
|
53
|
+
throw new index_js_2.NonPositiveInputError("shares", shares);
|
|
54
|
+
let tx = {
|
|
55
|
+
to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
|
|
56
|
+
value: 0n,
|
|
57
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
58
|
+
abi: abis_js_1.blueAbi,
|
|
59
|
+
functionName: "withdraw",
|
|
60
|
+
args: [marketParams, 0n, shares, callbackAddress, userAddress],
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
if (params.metadata) {
|
|
64
|
+
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
65
|
+
}
|
|
66
|
+
return (0, morpho_ts_1.deepFreeze)({
|
|
67
|
+
...tx,
|
|
68
|
+
action: {
|
|
69
|
+
type: "blueWithdrawBuyCallback",
|
|
70
|
+
args: {
|
|
71
|
+
market: marketParams.id,
|
|
72
|
+
shares,
|
|
73
|
+
onBehalf: callbackAddress,
|
|
74
|
+
receiver: userAddress,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
exports.blueWithdrawBuyCallback = blueWithdrawBuyCallback;
|
package/lib/cjs/blue/abis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/cjs/blue/abis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.
|
|
3
|
+
exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "marketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
6
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -8,13 +8,11 @@ Object.defineProperty(exports, "adaptiveCurveIrmAbi", { enumerable: true, get: f
|
|
|
8
8
|
Object.defineProperty(exports, "blueAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.blueAbi; } });
|
|
9
9
|
Object.defineProperty(exports, "blueOracleAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.blueOracleAbi; } });
|
|
10
10
|
Object.defineProperty(exports, "erc2612Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc2612Abi; } });
|
|
11
|
+
Object.defineProperty(exports, "erc3643Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc3643Abi; } });
|
|
12
|
+
Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc3643IdentityRegistryAbi; } });
|
|
11
13
|
Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
|
|
12
14
|
Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
|
|
13
15
|
Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
|
|
14
|
-
Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
|
|
15
|
-
Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
|
|
16
|
-
Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
|
|
17
|
-
Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
|
|
18
16
|
Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
|
|
19
17
|
Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
|
|
20
18
|
Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter,
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig,
|
|
6
|
-
export { AccrualPosition, AccrualVault, AccrualVaultV2,
|
|
5
|
+
IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
-
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig,
|
|
10
|
+
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/cjs/blue/entities.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.
|
|
3
|
+
exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.Token = exports.PreLiquidationPosition = exports.PreLiquidationParams = exports.Position = exports.MarketParams = exports.Market = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
8
|
-
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
9
8
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
10
9
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
11
10
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -33,7 +32,6 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
33
32
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
34
33
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
35
34
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
36
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
37
35
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
38
36
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
39
37
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
package/lib/cjs/blue/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError,
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError,
|
|
4
|
+
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedPermitDomainExtensionsError = exports.
|
|
3
|
+
exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.MarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownOfFactory = exports.UnknownMarketParamsError = exports.UnknownMarketAllocationError = exports.UnknownFactory = exports.UnknownDataError = exports.UnknownAddressError = exports.RegistryValueAlreadyRegisteredError = exports.InvalidMarketParamsError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.IncompleteChainRegistryError = exports.DivisionByZeroError = exports.BlueErrors = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
6
6
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return blue_sdk_1.DivisionByZeroError; } });
|
|
@@ -8,9 +8,6 @@ Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: tru
|
|
|
8
8
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return blue_sdk_1.InvalidAddressError; } });
|
|
9
9
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return blue_sdk_1.InvalidBitLengthError; } });
|
|
10
10
|
Object.defineProperty(exports, "InvalidMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
|
|
11
|
-
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return blue_sdk_1.InvalidPositionAccrualStateError; } });
|
|
12
|
-
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return blue_sdk_1.InvalidPositionLossFactorError; } });
|
|
13
|
-
Object.defineProperty(exports, "InvalidVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
|
|
14
11
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return blue_sdk_1.RegistryValueAlreadyRegisteredError; } });
|
|
15
12
|
Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
|
|
16
13
|
Object.defineProperty(exports, "UnknownDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
|
|
@@ -40,5 +37,4 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
|
|
|
40
37
|
Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
|
|
41
38
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
42
39
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
43
|
-
Object.defineProperty(exports, "UnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
44
40
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
package/lib/cjs/blue/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter,
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData,
|
|
5
|
+
fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/fetch.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.
|
|
3
|
+
exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchUser = exports.fetchToken = exports.fetchPreLiquidationPosition = exports.fetchPreLiquidationParams = exports.fetchPosition = exports.fetchMarketParams = exports.fetchMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchAccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
Object.defineProperty(exports, "fetchAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
|
|
8
8
|
Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
|
|
9
|
-
Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
|
|
10
9
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
|
|
11
10
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
12
11
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -30,7 +29,6 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
|
|
|
30
29
|
Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
|
|
31
30
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
|
|
32
31
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
|
|
33
|
-
Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
|
|
34
32
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
|
|
35
33
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
|
|
36
34
|
Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
|
package/lib/cjs/blue/utils.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
defaultPreLiquidationParamsRegistry,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
-
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils,
|
|
6
|
+
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.MetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.
|
|
3
|
+
exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.MetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.SharesMath = exports.MathLib = exports.MarketUtils = exports.getDefaultPreLiquidationParams = exports.defaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.AdaptiveCurveIrmLib = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
6
6
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "SharesMath", { enumerable: true, get: function (
|
|
|
14
14
|
Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
|
|
15
15
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
|
|
16
16
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
|
|
17
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapterUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapterUtils; } });
|
|
18
17
|
Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
|
|
19
18
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
20
19
|
Object.defineProperty(exports, "catchRevertOnly", { enumerable: true, get: function () { return blue_sdk_viem_1.catchRevertOnly; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type 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 ActionOutput, type ActionRequirement, type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawCollateralAction, type MorphoClientType, type RequirementSignature, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
|
+
import { type ActionOutput, type ActionRequirement, type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawBuyCallbackAction, type BlueWithdrawCollateralAction, type MorphoClientType, type RequirementSignature, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
5
5
|
import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
|
|
6
6
|
type VaultV2BlueReallocationsParams = {
|
|
7
7
|
readonly reallocationData: VaultV2BlueReallocationData;
|
|
@@ -23,7 +23,10 @@ export interface BlueTokenRequirementsParams {
|
|
|
23
23
|
/** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
|
|
24
24
|
readonly permit2Nonce?: bigint;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Action surface for Morpho Blue reads and writes; writes route through BlueBundlesV1, except
|
|
28
|
+
* `withdrawBuyCallback`, which calls Morpho Blue directly.
|
|
29
|
+
*/
|
|
27
30
|
export interface BlueActions {
|
|
28
31
|
/**
|
|
29
32
|
* Fetches the latest market data with accrued interest.
|
|
@@ -151,7 +154,8 @@ export interface BlueActions {
|
|
|
151
154
|
*
|
|
152
155
|
* @param params.userAddress - User funding and receiving the supply position.
|
|
153
156
|
* @param params.marketData - Snapshot of this market from `getMarketData()` (or `fetchMarket` in
|
|
154
|
-
* `@morpho-org/blue-sdk-viem`),
|
|
157
|
+
* `@morpho-org/blue-sdk-viem`), checked only for `MarketIdMismatchError`. To check the dead-deposit
|
|
158
|
+
* rule, call `validateBlueMarketDeadShares` on the snapshot yourself before building.
|
|
155
159
|
* @param params.assets - Gross loan-token assets funded before the referral fee.
|
|
156
160
|
* @param params.nativeAmount - Optional full native funding; must equal `assets` and requires wNative.
|
|
157
161
|
* @param params.deadline - Final call deadline in Unix seconds.
|
|
@@ -180,8 +184,6 @@ export interface BlueActions {
|
|
|
180
184
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
181
185
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
182
186
|
* @throws {MarketIdMismatchError} when `marketData` belongs to another market.
|
|
183
|
-
* @throws {MissingDeadSharesDataError} when `marketData` has no `deadSupplyShares`.
|
|
184
|
-
* @throws {InsufficientDeadSharesError} when the market holds fewer than `MIN_DEAD_SHARES` supply shares at `DEAD_ADDRESS`.
|
|
185
187
|
* @throws {UnknownTokenError} from `getRequirements()` when the funded token's `decimals()` is unusable.
|
|
186
188
|
* @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
|
|
187
189
|
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
@@ -223,8 +225,7 @@ export interface BlueActions {
|
|
|
223
225
|
readonly referralFeeRecipient?: Address;
|
|
224
226
|
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
225
227
|
/**
|
|
226
|
-
* @deprecated Pass `marketData` from `getMarketData()
|
|
227
|
-
* Snapshot-free supply is unprotected and will be removed in the next major after one minor.
|
|
228
|
+
* @deprecated Pass `marketData` from `getMarketData()`; the snapshot-free overload is removed in the next major.
|
|
228
229
|
*/
|
|
229
230
|
(params: {
|
|
230
231
|
readonly userAddress: Address;
|
|
@@ -316,6 +317,76 @@ export interface BlueActions {
|
|
|
316
317
|
readonly referralFeePct?: bigint;
|
|
317
318
|
readonly referralFeeRecipient?: Address;
|
|
318
319
|
} & AssetsOrSharesArgs) => ActionOutput<BlueWithdrawAction, readonly RequirementSignature[], undefined>;
|
|
320
|
+
/**
|
|
321
|
+
* Prepares a direct Morpho Blue withdrawal of a BlueBuyCallback's whole supply position to its
|
|
322
|
+
* owner.
|
|
323
|
+
*
|
|
324
|
+
* A BlueBuyCallback parks a maker's Midnight buy-offer funds as Blue supply owned by the
|
|
325
|
+
* callback. After the offer is cancelled or expires, its owner recovers them with
|
|
326
|
+
* `withdraw(marketParams, 0, supplyShares, callbackAddress, userAddress)` sent straight to Morpho
|
|
327
|
+
* Blue: BlueBundlesV1 cannot act for the callback. The callback's constructor authorizes its
|
|
328
|
+
* owner on Blue, so no requirement is returned.
|
|
329
|
+
*
|
|
330
|
+
* The handle checks the snapshot synchronously: it must be the callback's position on this
|
|
331
|
+
* market, hold supply shares, and the market's liquidity must cover their assets.
|
|
332
|
+
* `getRequirements()` then reads the chain and throws unless the registered
|
|
333
|
+
* `midnightBlueBuyCallbackFactory` created the callback, its `OWNER()` is `userAddress`, and Blue
|
|
334
|
+
* still authorizes `userAddress` for the callback. Await it before submitting the transaction.
|
|
335
|
+
*
|
|
336
|
+
* @param params.userAddress - Callback owner, who sends the transaction and receives the assets.
|
|
337
|
+
* @param params.callbackAddress - BlueBuyCallback whose supply position is withdrawn.
|
|
338
|
+
* @param params.positionData - Fresh snapshot of the callback's position on this market, for
|
|
339
|
+
* example from `getPositionData(callbackAddress)`. Every supply share in it is withdrawn.
|
|
340
|
+
* @returns Lazy owner and authorization checks with no requirements, and a synchronous
|
|
341
|
+
* deep-frozen transaction targeting Morpho Blue.
|
|
342
|
+
* @throws {ChainIdMismatchError} when the client targets another chain, or from
|
|
343
|
+
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
344
|
+
* @throws {viem.InvalidAddressError} when `callbackAddress` is malformed.
|
|
345
|
+
* @throws {MissingAccrualPositionError} when no position snapshot is provided.
|
|
346
|
+
* @throws {MarketIdMismatchError} when `positionData` belongs to another market.
|
|
347
|
+
* @throws {AccrualPositionUserMismatchError} when `positionData` belongs to another account than
|
|
348
|
+
* `callbackAddress`.
|
|
349
|
+
* @throws {EmptyBlueSupplyPositionError} when the callback holds no supply shares.
|
|
350
|
+
* @throws {InsufficientBlueLiquidityError} when the position's assets exceed market liquidity.
|
|
351
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
352
|
+
* @throws {UnknownAddressError} when Morpho Blue or `midnightBlueBuyCallbackFactory` is not
|
|
353
|
+
* registered.
|
|
354
|
+
* @throws {MissingContractCodeError} from `getRequirements()` when Morpho Blue or the factory has
|
|
355
|
+
* no code at its registered address.
|
|
356
|
+
* @throws {NotBlueBuyCallbackError} from `getRequirements()` when the factory did not create
|
|
357
|
+
* `callbackAddress`.
|
|
358
|
+
* @throws {BlueBuyCallbackOwnerMismatchError} from `getRequirements()` when the callback's
|
|
359
|
+
* `OWNER()` is not `userAddress`.
|
|
360
|
+
* @throws {BlueBuyCallbackUnauthorizedError} from `getRequirements()` when Blue does not
|
|
361
|
+
* authorize `userAddress` for the callback.
|
|
362
|
+
* @throws {viem.BaseError} from `getRequirements()` when a read fails.
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
366
|
+
* import { createPublicClient, http, zeroAddress } from "viem";
|
|
367
|
+
* import { mainnet } from "viem/chains";
|
|
368
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
369
|
+
*
|
|
370
|
+
* const userAddress = zeroAddress;
|
|
371
|
+
* const callbackAddress = zeroAddress;
|
|
372
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
373
|
+
* .extend(morphoViemExtension());
|
|
374
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
375
|
+
* const action = market.withdrawBuyCallback({
|
|
376
|
+
* userAddress,
|
|
377
|
+
* callbackAddress,
|
|
378
|
+
* positionData: await market.getPositionData(callbackAddress),
|
|
379
|
+
* });
|
|
380
|
+
* await action.getRequirements(); // throws unless userAddress owns the callback
|
|
381
|
+
* const tx = action.buildTx();
|
|
382
|
+
* // tx satisfies Readonly<Transaction<BlueWithdrawBuyCallbackAction>>
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
withdrawBuyCallback: (params: {
|
|
386
|
+
readonly userAddress: Address;
|
|
387
|
+
readonly callbackAddress: Address;
|
|
388
|
+
readonly positionData: AccrualPosition;
|
|
389
|
+
}) => ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
|
|
319
390
|
/**
|
|
320
391
|
* Prepares a direct BlueBundlesV1 loan-asset borrow.
|
|
321
392
|
*
|
|
@@ -1002,8 +1073,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1002
1073
|
readonly referralFeeRecipient?: Address;
|
|
1003
1074
|
}): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
|
|
1004
1075
|
/**
|
|
1005
|
-
* @deprecated Pass `marketData` from `getMarketData()
|
|
1006
|
-
* Snapshot-free supply is unprotected and will be removed in the next major after one minor.
|
|
1076
|
+
* @deprecated Pass `marketData` from `getMarketData()`; the snapshot-free overload is removed in the next major.
|
|
1007
1077
|
*/
|
|
1008
1078
|
supply(params: {
|
|
1009
1079
|
readonly userAddress: Address;
|
|
@@ -1025,6 +1095,12 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1025
1095
|
getRequirements: () => Promise<readonly ActionRequirement[]>;
|
|
1026
1096
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../index.js").Transaction<BlueWithdrawAction>>;
|
|
1027
1097
|
};
|
|
1098
|
+
/** {@inheritDoc BlueActions.withdrawBuyCallback} */
|
|
1099
|
+
withdrawBuyCallback(params: {
|
|
1100
|
+
readonly userAddress: Address;
|
|
1101
|
+
readonly callbackAddress: Address;
|
|
1102
|
+
readonly positionData: AccrualPosition;
|
|
1103
|
+
}): ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
|
|
1028
1104
|
/** {@inheritDoc BlueActions.supplyCollateral} */
|
|
1029
1105
|
supplyCollateral(params: {
|
|
1030
1106
|
readonly userAddress: Address;
|