@morpho-org/blue-sdk 6.0.0 → 6.1.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/lib/cjs/addresses.d.ts +105 -0
- package/lib/cjs/addresses.js +74 -0
- package/lib/cjs/chain.d.ts +84 -1
- package/lib/cjs/chain.js +78 -0
- package/lib/cjs/errors.d.ts +34 -0
- package/lib/cjs/errors.js +28 -0
- package/lib/cjs/holding/AssetBalances.d.ts +3 -0
- package/lib/cjs/holding/AssetBalances.js +1 -0
- package/lib/cjs/holding/Holding.d.ts +6 -0
- package/lib/cjs/holding/Holding.js +2 -0
- package/lib/cjs/market/Market.d.ts +4 -0
- package/lib/cjs/market/MarketParams.d.ts +3 -0
- package/lib/cjs/market/MarketParams.js +1 -0
- package/lib/cjs/market/MarketUtils.d.ts +397 -0
- package/lib/cjs/market/MarketUtils.js +397 -2
- package/lib/cjs/math/AdaptiveCurveIrmLib.d.ts +51 -1
- package/lib/cjs/math/AdaptiveCurveIrmLib.js +51 -1
- package/lib/cjs/math/MathLib.d.ts +152 -4
- package/lib/cjs/math/MathLib.js +151 -4
- package/lib/cjs/math/SharesMath.d.ts +34 -0
- package/lib/cjs/math/SharesMath.js +34 -0
- package/lib/cjs/position/Position.d.ts +4 -0
- package/lib/cjs/position/Position.js +2 -0
- package/lib/cjs/position/PreLiquidationPosition.d.ts +4 -0
- package/lib/cjs/position/PreLiquidationPosition.js +2 -0
- package/lib/cjs/preLiquidation.d.ts +16 -0
- package/lib/cjs/preLiquidation.js +16 -0
- package/lib/cjs/token/ConstantWrappedToken.d.ts +1 -0
- package/lib/cjs/token/ConstantWrappedToken.js +1 -0
- package/lib/cjs/token/Eip5267Domain.d.ts +4 -0
- package/lib/cjs/token/Eip5267Domain.js +2 -0
- package/lib/cjs/token/ExchangeRateWrappedToken.d.ts +1 -0
- package/lib/cjs/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/cjs/token/Token.d.ts +2 -0
- package/lib/cjs/token/Token.js +1 -0
- package/lib/cjs/token/VaultToken.d.ts +2 -0
- package/lib/cjs/token/VaultToken.js +1 -0
- package/lib/cjs/token/WrappedToken.d.ts +1 -0
- package/lib/cjs/token/WrappedToken.js +1 -0
- package/lib/cjs/types.d.ts +17 -0
- package/lib/cjs/types.js +13 -0
- package/lib/cjs/user/User.d.ts +1 -0
- package/lib/cjs/user/User.js +1 -0
- package/lib/cjs/utils.d.ts +2 -0
- package/lib/cjs/utils.js +1 -0
- package/lib/cjs/vault/Vault.d.ts +7 -0
- package/lib/cjs/vault/Vault.js +2 -0
- package/lib/cjs/vault/VaultConfig.d.ts +2 -0
- package/lib/cjs/vault/VaultConfig.js +1 -0
- package/lib/cjs/vault/VaultMarketAllocation.d.ts +2 -0
- package/lib/cjs/vault/VaultMarketAllocation.js +1 -0
- package/lib/cjs/vault/VaultMarketConfig.d.ts +2 -0
- package/lib/cjs/vault/VaultMarketConfig.js +1 -0
- package/lib/cjs/vault/VaultMarketPublicAllocatorConfig.d.ts +1 -0
- package/lib/cjs/vault/VaultMarketPublicAllocatorConfig.js +1 -0
- package/lib/cjs/vault/VaultUser.d.ts +2 -0
- package/lib/cjs/vault/VaultUser.js +1 -0
- package/lib/cjs/vault/VaultUtils.d.ts +49 -0
- package/lib/cjs/vault/VaultUtils.js +49 -0
- package/lib/cjs/vault/v2/VaultV2.d.ts +5 -0
- package/lib/cjs/vault/v2/VaultV2.js +2 -0
- package/lib/cjs/vault/v2/VaultV2Adapter.d.ts +3 -0
- package/lib/cjs/vault/v2/VaultV2Adapter.js +1 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +4 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1Adapter.js +2 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +4 -0
- package/lib/cjs/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +2 -0
- package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +4 -0
- package/lib/cjs/vault/v2/VaultV2MorphoVaultV1Adapter.js +2 -0
- package/lib/esm/addresses.d.ts +105 -0
- package/lib/esm/addresses.js +74 -0
- package/lib/esm/chain.d.ts +84 -1
- package/lib/esm/chain.js +78 -0
- package/lib/esm/errors.d.ts +34 -0
- package/lib/esm/errors.js +28 -0
- package/lib/esm/holding/AssetBalances.d.ts +3 -0
- package/lib/esm/holding/AssetBalances.js +1 -0
- package/lib/esm/holding/Holding.d.ts +6 -0
- package/lib/esm/holding/Holding.js +2 -0
- package/lib/esm/market/Market.d.ts +4 -0
- package/lib/esm/market/MarketParams.d.ts +3 -0
- package/lib/esm/market/MarketParams.js +1 -0
- package/lib/esm/market/MarketUtils.d.ts +397 -0
- package/lib/esm/market/MarketUtils.js +397 -2
- package/lib/esm/math/AdaptiveCurveIrmLib.d.ts +51 -1
- package/lib/esm/math/AdaptiveCurveIrmLib.js +51 -1
- package/lib/esm/math/MathLib.d.ts +152 -4
- package/lib/esm/math/MathLib.js +151 -4
- package/lib/esm/math/SharesMath.d.ts +34 -0
- package/lib/esm/math/SharesMath.js +34 -0
- package/lib/esm/position/Position.d.ts +4 -0
- package/lib/esm/position/Position.js +2 -0
- package/lib/esm/position/PreLiquidationPosition.d.ts +4 -0
- package/lib/esm/position/PreLiquidationPosition.js +2 -0
- package/lib/esm/preLiquidation.d.ts +16 -0
- package/lib/esm/preLiquidation.js +16 -0
- package/lib/esm/token/ConstantWrappedToken.d.ts +1 -0
- package/lib/esm/token/ConstantWrappedToken.js +1 -0
- package/lib/esm/token/Eip5267Domain.d.ts +4 -0
- package/lib/esm/token/Eip5267Domain.js +2 -0
- package/lib/esm/token/ExchangeRateWrappedToken.d.ts +1 -0
- package/lib/esm/token/ExchangeRateWrappedToken.js +1 -0
- package/lib/esm/token/Token.d.ts +2 -0
- package/lib/esm/token/Token.js +1 -0
- package/lib/esm/token/VaultToken.d.ts +2 -0
- package/lib/esm/token/VaultToken.js +1 -0
- package/lib/esm/token/WrappedToken.d.ts +1 -0
- package/lib/esm/token/WrappedToken.js +1 -0
- package/lib/esm/types.d.ts +17 -0
- package/lib/esm/types.js +13 -0
- package/lib/esm/user/User.d.ts +1 -0
- package/lib/esm/user/User.js +1 -0
- package/lib/esm/utils.d.ts +2 -0
- package/lib/esm/utils.js +1 -0
- package/lib/esm/vault/Vault.d.ts +7 -0
- package/lib/esm/vault/Vault.js +2 -0
- package/lib/esm/vault/VaultConfig.d.ts +2 -0
- package/lib/esm/vault/VaultConfig.js +1 -0
- package/lib/esm/vault/VaultMarketAllocation.d.ts +2 -0
- package/lib/esm/vault/VaultMarketAllocation.js +1 -0
- package/lib/esm/vault/VaultMarketConfig.d.ts +2 -0
- package/lib/esm/vault/VaultMarketConfig.js +1 -0
- package/lib/esm/vault/VaultMarketPublicAllocatorConfig.d.ts +1 -0
- package/lib/esm/vault/VaultMarketPublicAllocatorConfig.js +1 -0
- package/lib/esm/vault/VaultUser.d.ts +2 -0
- package/lib/esm/vault/VaultUser.js +1 -0
- package/lib/esm/vault/VaultUtils.d.ts +49 -0
- package/lib/esm/vault/VaultUtils.js +49 -0
- package/lib/esm/vault/v2/VaultV2.d.ts +5 -0
- package/lib/esm/vault/v2/VaultV2.js +2 -0
- package/lib/esm/vault/v2/VaultV2Adapter.d.ts +3 -0
- package/lib/esm/vault/v2/VaultV2Adapter.js +1 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +4 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1Adapter.js +2 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.d.ts +4 -0
- package/lib/esm/vault/v2/VaultV2MorphoMarketV1AdapterV2.js +2 -0
- package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +4 -0
- package/lib/esm/vault/v2/VaultV2MorphoVaultV1Adapter.js +2 -0
- package/package.json +10 -6
package/lib/cjs/addresses.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Address } from "./types.js";
|
|
|
6
6
|
* NB: data might differ from expected onchain native token data
|
|
7
7
|
*/
|
|
8
8
|
export declare const NATIVE_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
9
|
+
/** Registry entry for protocol, adapter, factory, and token addresses on one chain. */
|
|
9
10
|
export interface ChainAddresses {
|
|
10
11
|
morpho: Address;
|
|
11
12
|
permit2?: Address;
|
|
@@ -725,7 +726,22 @@ declare const _addressesRegistry: {
|
|
|
725
726
|
readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
|
|
726
727
|
readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
|
|
727
728
|
};
|
|
729
|
+
readonly 5042: {
|
|
730
|
+
readonly morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD";
|
|
731
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
732
|
+
readonly bundler3: {
|
|
733
|
+
readonly bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb";
|
|
734
|
+
readonly generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466";
|
|
735
|
+
};
|
|
736
|
+
readonly adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20";
|
|
737
|
+
readonly vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12";
|
|
738
|
+
readonly morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc";
|
|
739
|
+
readonly registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765";
|
|
740
|
+
readonly chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8";
|
|
741
|
+
readonly preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922";
|
|
742
|
+
};
|
|
728
743
|
};
|
|
744
|
+
/** Deployment block registry with the same shape as `ChainAddresses`. */
|
|
729
745
|
export type ChainDeployments<Addresses = ChainAddresses> = {
|
|
730
746
|
[key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
|
|
731
747
|
};
|
|
@@ -1324,9 +1340,52 @@ declare const _deployments: {
|
|
|
1324
1340
|
readonly preLiquidationFactory: 213462907n;
|
|
1325
1341
|
readonly wNative: 104802159n;
|
|
1326
1342
|
};
|
|
1343
|
+
readonly 5042: {
|
|
1344
|
+
readonly morpho: 1208685n;
|
|
1345
|
+
readonly permit2: 0n;
|
|
1346
|
+
readonly bundler3: {
|
|
1347
|
+
readonly bundler3: 1208685n;
|
|
1348
|
+
readonly generalAdapter1: 1208685n;
|
|
1349
|
+
};
|
|
1350
|
+
readonly adaptiveCurveIrm: 1208685n;
|
|
1351
|
+
readonly vaultV2Factory: 1208931n;
|
|
1352
|
+
readonly morphoMarketV1AdapterV2Factory: 1208978n;
|
|
1353
|
+
readonly registryList: 1208978n;
|
|
1354
|
+
readonly chainlinkOracleFactory: 1208882n;
|
|
1355
|
+
readonly preLiquidationFactory: 1208882n;
|
|
1356
|
+
};
|
|
1327
1357
|
};
|
|
1358
|
+
/** Dot-separated label for an address entry in the chain registry. */
|
|
1328
1359
|
export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
|
|
1360
|
+
/**
|
|
1361
|
+
* Returns the protocol address registry for a chain.
|
|
1362
|
+
*
|
|
1363
|
+
* @param chainId - The EIP-155 chain id.
|
|
1364
|
+
* @returns The configured protocol, adapter, factory, and token addresses for `chainId`.
|
|
1365
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
1366
|
+
* @example
|
|
1367
|
+
* ```ts
|
|
1368
|
+
* import { ChainId, getChainAddresses } from "@morpho-org/blue-sdk";
|
|
1369
|
+
*
|
|
1370
|
+
* const chainAddresses = getChainAddresses(ChainId.EthMainnet);
|
|
1371
|
+
* // chainAddresses satisfies ChainAddresses
|
|
1372
|
+
* ```
|
|
1373
|
+
*/
|
|
1329
1374
|
export declare const getChainAddresses: (chainId: number) => ChainAddresses;
|
|
1375
|
+
/**
|
|
1376
|
+
* Returns the unwrapped token mapped to a wrapped token on a chain.
|
|
1377
|
+
*
|
|
1378
|
+
* @param wrappedToken - The wrapped token address to resolve.
|
|
1379
|
+
* @param chainId - The EIP-155 chain id.
|
|
1380
|
+
* @returns The unwrapped token address, or `undefined` when no mapping is registered.
|
|
1381
|
+
* @example
|
|
1382
|
+
* ```ts
|
|
1383
|
+
* import { ChainId, getUnwrappedToken, NATIVE_ADDRESS, addresses } from "@morpho-org/blue-sdk";
|
|
1384
|
+
*
|
|
1385
|
+
* const unwrapped = getUnwrappedToken(addresses[ChainId.EthMainnet].wNative!, ChainId.EthMainnet);
|
|
1386
|
+
* // unwrapped === NATIVE_ADDRESS
|
|
1387
|
+
* ```
|
|
1388
|
+
*/
|
|
1330
1389
|
export declare function getUnwrappedToken(wrappedToken: Address, chainId: number): `0x${string}` | undefined;
|
|
1331
1390
|
/**
|
|
1332
1391
|
* The registry of all known ERC20Wrapper tokens.
|
|
@@ -1347,11 +1406,25 @@ export declare const permissionedBackedTokens: Record<number, Set<Address>>;
|
|
|
1347
1406
|
* All permissioned Coinbase tokens are considered PermissionedERC20Wrapper and automatically added to the permissionedWrapperTokens registry.
|
|
1348
1407
|
*/
|
|
1349
1408
|
export declare const permissionedCoinbaseTokens: Record<number, Set<Address>>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Returns the known Coinbase-attested wrapped tokens for a chain.
|
|
1411
|
+
*
|
|
1412
|
+
* @param chainId - The EIP-155 chain id.
|
|
1413
|
+
* @returns A set of permissioned wrapped token addresses, or an empty set when none are registered.
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```ts
|
|
1416
|
+
* import { ChainId, getPermissionedCoinbaseTokens } from "@morpho-org/blue-sdk";
|
|
1417
|
+
*
|
|
1418
|
+
* const tokens = getPermissionedCoinbaseTokens(ChainId.BaseMainnet);
|
|
1419
|
+
* // tokens satisfies Set<Address>
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1350
1422
|
export declare const getPermissionedCoinbaseTokens: (chainId: number) => Set<`0x${string}`>;
|
|
1351
1423
|
/** /!\ These tokens can not be listed in `erc20WrapperTokens` because the following specs are different:
|
|
1352
1424
|
* - calling `depositFor` supplies on blue instead of minting wrapped token to the user
|
|
1353
1425
|
*/
|
|
1354
1426
|
export declare const convexWrapperTokens: Record<number, Set<Address>>;
|
|
1427
|
+
/** Deep-frozen registry of known chain addresses, keyed by chain id. */
|
|
1355
1428
|
export declare let addressesRegistry: {
|
|
1356
1429
|
readonly 1: {
|
|
1357
1430
|
readonly morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb";
|
|
@@ -2028,8 +2101,24 @@ export declare let addressesRegistry: {
|
|
|
2028
2101
|
readonly preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440";
|
|
2029
2102
|
readonly wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432";
|
|
2030
2103
|
};
|
|
2104
|
+
readonly 5042: {
|
|
2105
|
+
readonly morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD";
|
|
2106
|
+
readonly permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
2107
|
+
readonly bundler3: {
|
|
2108
|
+
readonly bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb";
|
|
2109
|
+
readonly generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466";
|
|
2110
|
+
};
|
|
2111
|
+
readonly adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20";
|
|
2112
|
+
readonly vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12";
|
|
2113
|
+
readonly morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc";
|
|
2114
|
+
readonly registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765";
|
|
2115
|
+
readonly chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8";
|
|
2116
|
+
readonly preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922";
|
|
2117
|
+
};
|
|
2031
2118
|
};
|
|
2119
|
+
/** Address registry keyed by numeric chain id. */
|
|
2032
2120
|
export declare let addresses: Record<number, ChainAddresses>;
|
|
2121
|
+
/** Deep-frozen registry of deployment blocks, keyed by chain id. */
|
|
2033
2122
|
export declare let deployments: {
|
|
2034
2123
|
readonly 1: {
|
|
2035
2124
|
readonly morpho: 18883124n;
|
|
@@ -2625,7 +2714,22 @@ export declare let deployments: {
|
|
|
2625
2714
|
readonly preLiquidationFactory: 213462907n;
|
|
2626
2715
|
readonly wNative: 104802159n;
|
|
2627
2716
|
};
|
|
2717
|
+
readonly 5042: {
|
|
2718
|
+
readonly morpho: 1208685n;
|
|
2719
|
+
readonly permit2: 0n;
|
|
2720
|
+
readonly bundler3: {
|
|
2721
|
+
readonly bundler3: 1208685n;
|
|
2722
|
+
readonly generalAdapter1: 1208685n;
|
|
2723
|
+
};
|
|
2724
|
+
readonly adaptiveCurveIrm: 1208685n;
|
|
2725
|
+
readonly vaultV2Factory: 1208931n;
|
|
2726
|
+
readonly morphoMarketV1AdapterV2Factory: 1208978n;
|
|
2727
|
+
readonly registryList: 1208978n;
|
|
2728
|
+
readonly chainlinkOracleFactory: 1208882n;
|
|
2729
|
+
readonly preLiquidationFactory: 1208882n;
|
|
2730
|
+
};
|
|
2628
2731
|
};
|
|
2732
|
+
/** Deep-frozen registry of wrapped token to unwrapped token mappings. */
|
|
2629
2733
|
export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
|
|
2630
2734
|
/**
|
|
2631
2735
|
* Registers custom addresses and unwrapped token mappings to extend
|
|
@@ -2642,6 +2746,7 @@ export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`,
|
|
|
2642
2746
|
* Must provide all required deployments if chain is unknown.
|
|
2643
2747
|
*
|
|
2644
2748
|
* @throws {Error} If attempting to override an existing address.
|
|
2749
|
+
* @returns Nothing.
|
|
2645
2750
|
*
|
|
2646
2751
|
* @example
|
|
2647
2752
|
* ```ts
|
package/lib/cjs/addresses.js
CHANGED
|
@@ -718,6 +718,20 @@ const _addressesRegistry = {
|
|
|
718
718
|
preLiquidationFactory: "0xe8eCe452F04117e5Fe1Ea4403097215443225440",
|
|
719
719
|
wNative: "0x19Aac5f612f524B754CA7e7c41cbFa2E981A4432",
|
|
720
720
|
},
|
|
721
|
+
[chain_js_1.ChainId.ArcMainnet]: {
|
|
722
|
+
morpho: "0x34CD04070dD72b14E241112F6d83812Df5Af7fCD",
|
|
723
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
|
|
724
|
+
bundler3: {
|
|
725
|
+
bundler3: "0x855dbe13C409Df75CAF6a985Cf6993a4D0319Feb",
|
|
726
|
+
generalAdapter1: "0x0AF5BE7BD7B615e94e1d9275414482D028952466",
|
|
727
|
+
},
|
|
728
|
+
adaptiveCurveIrm: "0xF02615d094Fc02fC031C35fe705e175aA4653f20",
|
|
729
|
+
vaultV2Factory: "0x3b0eefaBfa22ec7CF2c73877ac16e78D76749f12",
|
|
730
|
+
morphoMarketV1AdapterV2Factory: "0x6C2FF5114E45b50bc7195c2F1f87C98cbdad62Cc",
|
|
731
|
+
registryList: "0xdEBC92370Cd74d55DA144116138681dbbb528765",
|
|
732
|
+
chainlinkOracleFactory: "0xbFc8D6167a02889D5EB08a023d9aB712B44f7dE8",
|
|
733
|
+
preLiquidationFactory: "0x8edf6Ac769a7E7D81d571aC0FB8733aD724f6922",
|
|
734
|
+
},
|
|
721
735
|
};
|
|
722
736
|
const _deployments = {
|
|
723
737
|
[chain_js_1.ChainId.EthMainnet]: {
|
|
@@ -1314,7 +1328,35 @@ const _deployments = {
|
|
|
1314
1328
|
preLiquidationFactory: 213462907n,
|
|
1315
1329
|
wNative: 104802159n,
|
|
1316
1330
|
},
|
|
1331
|
+
[chain_js_1.ChainId.ArcMainnet]: {
|
|
1332
|
+
morpho: 1208685n,
|
|
1333
|
+
permit2: 0n,
|
|
1334
|
+
bundler3: {
|
|
1335
|
+
bundler3: 1208685n,
|
|
1336
|
+
generalAdapter1: 1208685n,
|
|
1337
|
+
},
|
|
1338
|
+
adaptiveCurveIrm: 1208685n,
|
|
1339
|
+
vaultV2Factory: 1208931n,
|
|
1340
|
+
morphoMarketV1AdapterV2Factory: 1208978n,
|
|
1341
|
+
registryList: 1208978n,
|
|
1342
|
+
chainlinkOracleFactory: 1208882n,
|
|
1343
|
+
preLiquidationFactory: 1208882n,
|
|
1344
|
+
},
|
|
1317
1345
|
};
|
|
1346
|
+
/**
|
|
1347
|
+
* Returns the protocol address registry for a chain.
|
|
1348
|
+
*
|
|
1349
|
+
* @param chainId - The EIP-155 chain id.
|
|
1350
|
+
* @returns The configured protocol, adapter, factory, and token addresses for `chainId`.
|
|
1351
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
1352
|
+
* @example
|
|
1353
|
+
* ```ts
|
|
1354
|
+
* import { ChainId, getChainAddresses } from "@morpho-org/blue-sdk";
|
|
1355
|
+
*
|
|
1356
|
+
* const chainAddresses = getChainAddresses(ChainId.EthMainnet);
|
|
1357
|
+
* // chainAddresses satisfies ChainAddresses
|
|
1358
|
+
* ```
|
|
1359
|
+
*/
|
|
1318
1360
|
const getChainAddresses = (chainId) => {
|
|
1319
1361
|
const chainAddresses = exports.addresses[chainId];
|
|
1320
1362
|
if (chainAddresses == null)
|
|
@@ -1445,6 +1487,20 @@ const _unwrappedTokensMapping = {
|
|
|
1445
1487
|
[_addressesRegistry[chain_js_1.ChainId.KaiaMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
1446
1488
|
},
|
|
1447
1489
|
};
|
|
1490
|
+
/**
|
|
1491
|
+
* Returns the unwrapped token mapped to a wrapped token on a chain.
|
|
1492
|
+
*
|
|
1493
|
+
* @param wrappedToken - The wrapped token address to resolve.
|
|
1494
|
+
* @param chainId - The EIP-155 chain id.
|
|
1495
|
+
* @returns The unwrapped token address, or `undefined` when no mapping is registered.
|
|
1496
|
+
* @example
|
|
1497
|
+
* ```ts
|
|
1498
|
+
* import { ChainId, getUnwrappedToken, NATIVE_ADDRESS, addresses } from "@morpho-org/blue-sdk";
|
|
1499
|
+
*
|
|
1500
|
+
* const unwrapped = getUnwrappedToken(addresses[ChainId.EthMainnet].wNative!, ChainId.EthMainnet);
|
|
1501
|
+
* // unwrapped === NATIVE_ADDRESS
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1448
1504
|
function getUnwrappedToken(wrappedToken, chainId) {
|
|
1449
1505
|
return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
|
|
1450
1506
|
}
|
|
@@ -1480,6 +1536,19 @@ exports.permissionedCoinbaseTokens = {
|
|
|
1480
1536
|
_addressesRegistry[chain_js_1.ChainId.BaseMainnet].verUsdc,
|
|
1481
1537
|
]),
|
|
1482
1538
|
};
|
|
1539
|
+
/**
|
|
1540
|
+
* Returns the known Coinbase-attested wrapped tokens for a chain.
|
|
1541
|
+
*
|
|
1542
|
+
* @param chainId - The EIP-155 chain id.
|
|
1543
|
+
* @returns A set of permissioned wrapped token addresses, or an empty set when none are registered.
|
|
1544
|
+
* @example
|
|
1545
|
+
* ```ts
|
|
1546
|
+
* import { ChainId, getPermissionedCoinbaseTokens } from "@morpho-org/blue-sdk";
|
|
1547
|
+
*
|
|
1548
|
+
* const tokens = getPermissionedCoinbaseTokens(ChainId.BaseMainnet);
|
|
1549
|
+
* // tokens satisfies Set<Address>
|
|
1550
|
+
* ```
|
|
1551
|
+
*/
|
|
1483
1552
|
const getPermissionedCoinbaseTokens = (chainId) => exports.permissionedCoinbaseTokens[chainId] ?? new Set();
|
|
1484
1553
|
exports.getPermissionedCoinbaseTokens = getPermissionedCoinbaseTokens;
|
|
1485
1554
|
(0, morpho_ts_1.entries)(exports.permissionedBackedTokens).forEach(([chainId, tokens]) => {
|
|
@@ -1504,9 +1573,13 @@ exports.convexWrapperTokens = {
|
|
|
1504
1573
|
_addressesRegistry[chain_js_1.ChainId.EthMainnet]["stkcvx2BTC-f-morpho"],
|
|
1505
1574
|
]),
|
|
1506
1575
|
};
|
|
1576
|
+
/** Deep-frozen registry of known chain addresses, keyed by chain id. */
|
|
1507
1577
|
exports.addressesRegistry = (0, morpho_ts_1.deepFreeze)(_addressesRegistry);
|
|
1578
|
+
/** Address registry keyed by numeric chain id. */
|
|
1508
1579
|
exports.addresses = exports.addressesRegistry;
|
|
1580
|
+
/** Deep-frozen registry of deployment blocks, keyed by chain id. */
|
|
1509
1581
|
exports.deployments = (0, morpho_ts_1.deepFreeze)(_deployments);
|
|
1582
|
+
/** Deep-frozen registry of wrapped token to unwrapped token mappings. */
|
|
1510
1583
|
exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)(_unwrappedTokensMapping);
|
|
1511
1584
|
/**
|
|
1512
1585
|
* Registers custom addresses and unwrapped token mappings to extend
|
|
@@ -1523,6 +1596,7 @@ exports.unwrappedTokensMapping = (0, morpho_ts_1.deepFreeze)(_unwrappedTokensMap
|
|
|
1523
1596
|
* Must provide all required deployments if chain is unknown.
|
|
1524
1597
|
*
|
|
1525
1598
|
* @throws {Error} If attempting to override an existing address.
|
|
1599
|
+
* @returns Nothing.
|
|
1526
1600
|
*
|
|
1527
1601
|
* @example
|
|
1528
1602
|
* ```ts
|
package/lib/cjs/chain.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Supported EIP-155 chain ids with Morpho Blue deployments or registry metadata. */
|
|
1
2
|
export declare enum ChainId {
|
|
2
3
|
EthMainnet = 1,
|
|
3
4
|
BaseMainnet = 8453,
|
|
@@ -37,8 +38,10 @@ export declare enum ChainId {
|
|
|
37
38
|
GensynMainnet = 685689,
|
|
38
39
|
FlareMainnet = 14,
|
|
39
40
|
XdcMainnet = 50,
|
|
40
|
-
KaiaMainnet = 8217
|
|
41
|
+
KaiaMainnet = 8217,
|
|
42
|
+
ArcMainnet = 5042
|
|
41
43
|
}
|
|
44
|
+
/** Explorer, native currency, and identifier metadata for a supported chain. */
|
|
42
45
|
export interface ChainMetadata {
|
|
43
46
|
readonly name: string;
|
|
44
47
|
readonly id: ChainId;
|
|
@@ -52,12 +55,81 @@ export interface ChainMetadata {
|
|
|
52
55
|
/** Whether eth_getBalance returns a reliable value. Defaults to true. */
|
|
53
56
|
readonly hasReliableNativeBalance?: boolean;
|
|
54
57
|
}
|
|
58
|
+
/** Chain metadata helpers and registries. */
|
|
55
59
|
export declare namespace ChainUtils {
|
|
60
|
+
/**
|
|
61
|
+
* Returns whether native token balances are reliable on a chain.
|
|
62
|
+
*
|
|
63
|
+
* @param chainId - The EIP-155 chain id to inspect.
|
|
64
|
+
* @returns `false` only for chains whose metadata marks native balances as unreliable.
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
68
|
+
*
|
|
69
|
+
* const reliable = ChainUtils.hasReliableNativeBalance(ChainId.EthMainnet);
|
|
70
|
+
* // reliable === true
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
56
73
|
const hasReliableNativeBalance: (chainId: number) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a supported chain id to its hexadecimal JSON-RPC form.
|
|
76
|
+
*
|
|
77
|
+
* @param chainId - The supported chain id.
|
|
78
|
+
* @returns The chain id as a `0x`-prefixed hexadecimal string.
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
82
|
+
*
|
|
83
|
+
* const hexChainId = ChainUtils.toHexChainId(ChainId.EthMainnet);
|
|
84
|
+
* // hexChainId === "0x1"
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
57
87
|
const toHexChainId: (chainId: ChainId) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the block explorer base URL for a supported chain.
|
|
90
|
+
*
|
|
91
|
+
* @param chainId - The supported chain id.
|
|
92
|
+
* @returns The chain's configured block explorer base URL.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
96
|
+
*
|
|
97
|
+
* const explorerUrl = ChainUtils.getExplorerUrl(ChainId.EthMainnet);
|
|
98
|
+
* // explorerUrl === "https://etherscan.io"
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
58
101
|
const getExplorerUrl: (chainId: ChainId) => string;
|
|
102
|
+
/**
|
|
103
|
+
* Returns a block explorer address URL for a supported chain.
|
|
104
|
+
*
|
|
105
|
+
* @param chainId - The supported chain id.
|
|
106
|
+
* @param address - The address to link to.
|
|
107
|
+
* @returns The block explorer URL for `address`.
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { ChainId, ChainUtils, NATIVE_ADDRESS } from "@morpho-org/blue-sdk";
|
|
111
|
+
*
|
|
112
|
+
* const url = ChainUtils.getExplorerAddressUrl(ChainId.EthMainnet, NATIVE_ADDRESS);
|
|
113
|
+
* // url satisfies string
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
59
116
|
const getExplorerAddressUrl: (chainId: ChainId, address: string) => string;
|
|
117
|
+
/**
|
|
118
|
+
* Returns a block explorer transaction URL for a supported chain.
|
|
119
|
+
*
|
|
120
|
+
* @param chainId - The supported chain id.
|
|
121
|
+
* @param tx - The transaction hash to link to.
|
|
122
|
+
* @returns The block explorer URL for `tx`.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
126
|
+
*
|
|
127
|
+
* const url = ChainUtils.getExplorerTransactionUrl(ChainId.EthMainnet, "0xabc");
|
|
128
|
+
* // url satisfies string
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
60
131
|
const getExplorerTransactionUrl: (chainId: ChainId, tx: string) => string;
|
|
132
|
+
/** Metadata for each supported chain, keyed by `ChainId`. */
|
|
61
133
|
const CHAIN_METADATA: {
|
|
62
134
|
1: {
|
|
63
135
|
name: string;
|
|
@@ -489,5 +561,16 @@ export declare namespace ChainUtils {
|
|
|
489
561
|
explorerUrl: string;
|
|
490
562
|
identifier: string;
|
|
491
563
|
};
|
|
564
|
+
5042: {
|
|
565
|
+
name: string;
|
|
566
|
+
id: ChainId.ArcMainnet;
|
|
567
|
+
nativeCurrency: {
|
|
568
|
+
name: string;
|
|
569
|
+
symbol: string;
|
|
570
|
+
decimals: number;
|
|
571
|
+
};
|
|
572
|
+
explorerUrl: string;
|
|
573
|
+
identifier: string;
|
|
574
|
+
};
|
|
492
575
|
};
|
|
493
576
|
}
|
package/lib/cjs/chain.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChainUtils = exports.ChainId = void 0;
|
|
4
|
+
/** Supported EIP-155 chain ids with Morpho Blue deployments or registry metadata. */
|
|
4
5
|
var ChainId;
|
|
5
6
|
(function (ChainId) {
|
|
6
7
|
ChainId[ChainId["EthMainnet"] = 1] = "EthMainnet";
|
|
@@ -42,25 +43,95 @@ var ChainId;
|
|
|
42
43
|
ChainId[ChainId["FlareMainnet"] = 14] = "FlareMainnet";
|
|
43
44
|
ChainId[ChainId["XdcMainnet"] = 50] = "XdcMainnet";
|
|
44
45
|
ChainId[ChainId["KaiaMainnet"] = 8217] = "KaiaMainnet";
|
|
46
|
+
ChainId[ChainId["ArcMainnet"] = 5042] = "ArcMainnet";
|
|
45
47
|
})(ChainId || (exports.ChainId = ChainId = {}));
|
|
48
|
+
/** Chain metadata helpers and registries. */
|
|
46
49
|
var ChainUtils;
|
|
47
50
|
(function (ChainUtils) {
|
|
51
|
+
/**
|
|
52
|
+
* Returns whether native token balances are reliable on a chain.
|
|
53
|
+
*
|
|
54
|
+
* @param chainId - The EIP-155 chain id to inspect.
|
|
55
|
+
* @returns `false` only for chains whose metadata marks native balances as unreliable.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
59
|
+
*
|
|
60
|
+
* const reliable = ChainUtils.hasReliableNativeBalance(ChainId.EthMainnet);
|
|
61
|
+
* // reliable === true
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
48
64
|
ChainUtils.hasReliableNativeBalance = (chainId) => {
|
|
49
65
|
return (ChainUtils.CHAIN_METADATA[chainId]
|
|
50
66
|
?.hasReliableNativeBalance ?? true);
|
|
51
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Converts a supported chain id to its hexadecimal JSON-RPC form.
|
|
70
|
+
*
|
|
71
|
+
* @param chainId - The supported chain id.
|
|
72
|
+
* @returns The chain id as a `0x`-prefixed hexadecimal string.
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
76
|
+
*
|
|
77
|
+
* const hexChainId = ChainUtils.toHexChainId(ChainId.EthMainnet);
|
|
78
|
+
* // hexChainId === "0x1"
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
52
81
|
ChainUtils.toHexChainId = (chainId) => {
|
|
53
82
|
return `0x${chainId.toString(16)}`;
|
|
54
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Returns the block explorer base URL for a supported chain.
|
|
86
|
+
*
|
|
87
|
+
* @param chainId - The supported chain id.
|
|
88
|
+
* @returns The chain's configured block explorer base URL.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
92
|
+
*
|
|
93
|
+
* const explorerUrl = ChainUtils.getExplorerUrl(ChainId.EthMainnet);
|
|
94
|
+
* // explorerUrl === "https://etherscan.io"
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
55
97
|
ChainUtils.getExplorerUrl = (chainId) => {
|
|
56
98
|
return ChainUtils.CHAIN_METADATA[chainId].explorerUrl;
|
|
57
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Returns a block explorer address URL for a supported chain.
|
|
102
|
+
*
|
|
103
|
+
* @param chainId - The supported chain id.
|
|
104
|
+
* @param address - The address to link to.
|
|
105
|
+
* @returns The block explorer URL for `address`.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { ChainId, ChainUtils, NATIVE_ADDRESS } from "@morpho-org/blue-sdk";
|
|
109
|
+
*
|
|
110
|
+
* const url = ChainUtils.getExplorerAddressUrl(ChainId.EthMainnet, NATIVE_ADDRESS);
|
|
111
|
+
* // url satisfies string
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
58
114
|
ChainUtils.getExplorerAddressUrl = (chainId, address) => {
|
|
59
115
|
return `${ChainUtils.getExplorerUrl(chainId)}/address/${address}`;
|
|
60
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Returns a block explorer transaction URL for a supported chain.
|
|
119
|
+
*
|
|
120
|
+
* @param chainId - The supported chain id.
|
|
121
|
+
* @param tx - The transaction hash to link to.
|
|
122
|
+
* @returns The block explorer URL for `tx`.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { ChainId, ChainUtils } from "@morpho-org/blue-sdk";
|
|
126
|
+
*
|
|
127
|
+
* const url = ChainUtils.getExplorerTransactionUrl(ChainId.EthMainnet, "0xabc");
|
|
128
|
+
* // url satisfies string
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
61
131
|
ChainUtils.getExplorerTransactionUrl = (chainId, tx) => {
|
|
62
132
|
return `${ChainUtils.getExplorerUrl(chainId)}/tx/${tx}`;
|
|
63
133
|
};
|
|
134
|
+
/** Metadata for each supported chain, keyed by `ChainId`. */
|
|
64
135
|
ChainUtils.CHAIN_METADATA = {
|
|
65
136
|
[ChainId.EthMainnet]: {
|
|
66
137
|
name: "Ethereum",
|
|
@@ -336,5 +407,12 @@ var ChainUtils;
|
|
|
336
407
|
explorerUrl: "https://kaiascan.io",
|
|
337
408
|
identifier: "kaia",
|
|
338
409
|
},
|
|
410
|
+
[ChainId.ArcMainnet]: {
|
|
411
|
+
name: "Arc",
|
|
412
|
+
id: ChainId.ArcMainnet,
|
|
413
|
+
nativeCurrency: { name: "USDC", symbol: "USDC", decimals: 18 },
|
|
414
|
+
explorerUrl: "http://explorer.arc.io/",
|
|
415
|
+
identifier: "arc",
|
|
416
|
+
},
|
|
339
417
|
};
|
|
340
418
|
})(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,101 +1,135 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
2
|
import type { Address, MarketId } from "./types.js";
|
|
3
|
+
/** Error thrown when bytes cannot be decoded into valid Morpho Blue market params. */
|
|
3
4
|
export declare class InvalidMarketParamsError extends Error {
|
|
4
5
|
readonly data: Hex;
|
|
5
6
|
constructor(data: Hex);
|
|
6
7
|
}
|
|
8
|
+
/** Base error for optional data lookups that were not available. */
|
|
7
9
|
export declare class UnknownDataError extends Error {
|
|
8
10
|
}
|
|
11
|
+
/** Error thrown when token metadata is unavailable for an address. */
|
|
9
12
|
export declare class UnknownTokenError extends UnknownDataError {
|
|
10
13
|
readonly address: Address;
|
|
11
14
|
constructor(address: Address);
|
|
12
15
|
}
|
|
16
|
+
/** Error thrown when a token price is unavailable for an address. */
|
|
13
17
|
export declare class UnknownTokenPriceError extends UnknownDataError {
|
|
14
18
|
readonly address: Address;
|
|
15
19
|
constructor(address: Address);
|
|
16
20
|
}
|
|
21
|
+
/** Error thrown when market params are unavailable for a market id. */
|
|
17
22
|
export declare class UnknownMarketParamsError extends UnknownDataError {
|
|
18
23
|
readonly marketId: MarketId;
|
|
19
24
|
constructor(marketId: MarketId);
|
|
20
25
|
}
|
|
26
|
+
/** Error thrown when vault config is unavailable for a vault address. */
|
|
21
27
|
export declare class UnknownVaultConfigError extends UnknownDataError {
|
|
22
28
|
readonly vault: Address;
|
|
23
29
|
constructor(vault: Address);
|
|
24
30
|
}
|
|
31
|
+
/** Error thrown when a chain id has no configured SDK registry entry. */
|
|
25
32
|
export declare class UnsupportedChainIdError extends Error {
|
|
26
33
|
readonly chainId: number;
|
|
27
34
|
constructor(chainId: number);
|
|
28
35
|
}
|
|
36
|
+
/** Error thrown when no default pre-liquidation params exist for an LLTV. */
|
|
29
37
|
export declare class UnsupportedPreLiquidationParamsError extends Error {
|
|
30
38
|
readonly lltv: bigint;
|
|
31
39
|
constructor(lltv: bigint);
|
|
32
40
|
}
|
|
41
|
+
/** Error thrown when a Vault V2 adapter address is not supported by the SDK. */
|
|
33
42
|
export declare class UnsupportedVaultV2AdapterError extends Error {
|
|
34
43
|
readonly address: Address;
|
|
35
44
|
constructor(address: Address);
|
|
36
45
|
}
|
|
46
|
+
/** Morpho Blue protocol simulation errors. */
|
|
37
47
|
export declare namespace BlueErrors {
|
|
48
|
+
/** Error thrown when a value that must be set once is already set. */
|
|
38
49
|
class AlreadySet extends Error {
|
|
39
50
|
readonly name: string;
|
|
40
51
|
readonly value: string;
|
|
41
52
|
constructor(name: string, value: string);
|
|
42
53
|
}
|
|
54
|
+
/** Error thrown when market interest accrual is requested before `lastUpdate`. */
|
|
43
55
|
class InvalidInterestAccrual extends Error {
|
|
44
56
|
readonly marketId: MarketId;
|
|
45
57
|
readonly timestamp: bigint;
|
|
46
58
|
readonly lastUpdate: bigint;
|
|
47
59
|
constructor(marketId: MarketId, timestamp: bigint, lastUpdate: bigint);
|
|
48
60
|
}
|
|
61
|
+
/** Error thrown when asset and share inputs describe inconsistent values. */
|
|
49
62
|
class InconsistentInput extends Error {
|
|
50
63
|
readonly assets: bigint;
|
|
51
64
|
readonly shares: bigint;
|
|
52
65
|
constructor(assets: bigint, shares: bigint);
|
|
53
66
|
}
|
|
67
|
+
/** Error thrown when a market has insufficient liquidity for an operation. */
|
|
54
68
|
class InsufficientLiquidity extends Error {
|
|
55
69
|
readonly marketId: MarketId;
|
|
56
70
|
constructor(marketId: MarketId);
|
|
57
71
|
}
|
|
72
|
+
/** Error thrown when a market oracle price is unavailable. */
|
|
58
73
|
class UnknownOraclePrice extends Error {
|
|
59
74
|
readonly marketId: MarketId;
|
|
60
75
|
constructor(marketId: MarketId);
|
|
61
76
|
}
|
|
77
|
+
/** Error thrown when a user position is too small for an operation. */
|
|
62
78
|
class InsufficientPosition extends Error {
|
|
63
79
|
readonly user: Address;
|
|
64
80
|
readonly marketId: MarketId;
|
|
65
81
|
constructor(user: Address, marketId: MarketId);
|
|
66
82
|
}
|
|
83
|
+
/** Error thrown when a user position lacks required collateral. */
|
|
67
84
|
class InsufficientCollateral extends Error {
|
|
68
85
|
readonly user: Address;
|
|
69
86
|
readonly marketId: MarketId;
|
|
70
87
|
constructor(user: Address, marketId: MarketId);
|
|
71
88
|
}
|
|
89
|
+
/** Error thrown when a signature deadline has expired. */
|
|
72
90
|
class ExpiredSignature extends Error {
|
|
73
91
|
readonly deadline: bigint;
|
|
74
92
|
constructor(deadline: bigint);
|
|
75
93
|
}
|
|
76
94
|
}
|
|
95
|
+
/** Morpho Vault V2 simulation errors. */
|
|
77
96
|
export declare namespace VaultV2Errors {
|
|
97
|
+
/** Error thrown when vault interest accrual is requested before `lastUpdate`. */
|
|
78
98
|
class InvalidInterestAccrual extends Error {
|
|
79
99
|
readonly vault: Address;
|
|
80
100
|
readonly timestamp: bigint;
|
|
81
101
|
readonly lastUpdate: bigint;
|
|
82
102
|
constructor(vault: Address, timestamp: bigint, lastUpdate: bigint);
|
|
83
103
|
}
|
|
104
|
+
/** Error thrown when a Vault V2 liquidity adapter is not supported by the SDK. */
|
|
84
105
|
class UnsupportedLiquidityAdapter extends Error {
|
|
85
106
|
readonly address: Address;
|
|
86
107
|
constructor(address: Address);
|
|
87
108
|
}
|
|
88
109
|
}
|
|
110
|
+
/** Error thrown when a factory address is unavailable. */
|
|
89
111
|
export declare class UnknownFactory extends Error {
|
|
90
112
|
constructor();
|
|
91
113
|
}
|
|
114
|
+
/** Error thrown when an address is not deployed by the expected factory. */
|
|
92
115
|
export declare class UnknownOfFactory extends Error {
|
|
93
116
|
readonly factory: Address;
|
|
94
117
|
readonly address: Address;
|
|
95
118
|
constructor(factory: Address, address: Address);
|
|
96
119
|
}
|
|
120
|
+
/** Constructor type for errors accepted by `_try`. */
|
|
97
121
|
export interface ErrorClass<E extends Error = Error> {
|
|
98
122
|
new (...args: any[]): E;
|
|
99
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Runs an async accessor and returns `undefined` for expected lookup errors.
|
|
126
|
+
*
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
100
129
|
export declare function _try<T, ErrorClasses extends readonly ErrorClass[] = []>(accessor: () => Promise<T>, ...errorClasses: ErrorClasses): Promise<T | undefined>;
|
|
130
|
+
/**
|
|
131
|
+
* Runs a sync accessor and returns `undefined` for expected lookup errors.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
101
135
|
export declare function _try<T, ErrorClasses extends readonly ErrorClass[] = []>(accessor: () => T, ...errorClasses: ErrorClasses): T | undefined;
|