@morpho-org/blue-sdk 5.3.0-next.2 → 5.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/lib/addresses.d.ts +120 -0
- package/lib/addresses.js +66 -0
- package/lib/chain.d.ts +25 -1
- package/lib/chain.js +16 -0
- package/lib/errors.d.ts +0 -21
- package/lib/errors.js +1 -40
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/market/Market.d.ts +11 -1
- package/lib/market/Market.js +21 -13
- package/lib/market/MarketParams.d.ts +0 -21
- package/lib/market/MarketParams.js +1 -21
- package/lib/position/Position.d.ts +4 -4
- package/lib/position/Position.js +2 -3
- package/lib/token/VaultToken.d.ts +3 -3
- package/lib/vault/Vault.d.ts +10 -24
- package/lib/vault/Vault.js +5 -31
- package/lib/vault/index.d.ts +0 -1
- package/lib/vault/index.js +0 -1
- package/package.json +4 -4
- package/lib/utils.d.ts +0 -13
- package/lib/utils.js +0 -13
- package/lib/vault/v2/VaultV2.d.ts +0 -87
- package/lib/vault/v2/VaultV2.js +0 -159
- package/lib/vault/v2/VaultV2Adapter.d.ts +0 -29
- package/lib/vault/v2/VaultV2Adapter.js +0 -16
- package/lib/vault/v2/VaultV2MorphoMarketV1Adapter.d.ts +0 -30
- package/lib/vault/v2/VaultV2MorphoMarketV1Adapter.js +0 -59
- package/lib/vault/v2/VaultV2MorphoVaultV1Adapter.d.ts +0 -24
- package/lib/vault/v2/VaultV2MorphoVaultV1Adapter.js +0 -41
- package/lib/vault/v2/index.d.ts +0 -4
- package/lib/vault/v2/index.js +0 -20
package/lib/addresses.d.ts
CHANGED
|
@@ -437,6 +437,37 @@ declare const _addressesRegistry: {
|
|
|
437
437
|
readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
|
|
438
438
|
readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
|
|
439
439
|
};
|
|
440
|
+
readonly 16661: {
|
|
441
|
+
readonly morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e";
|
|
442
|
+
readonly bundler3: {
|
|
443
|
+
readonly bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae";
|
|
444
|
+
readonly generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054";
|
|
445
|
+
};
|
|
446
|
+
readonly adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e";
|
|
447
|
+
readonly publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497";
|
|
448
|
+
readonly metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f";
|
|
449
|
+
readonly chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43";
|
|
450
|
+
readonly preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802";
|
|
451
|
+
readonly wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c";
|
|
452
|
+
};
|
|
453
|
+
readonly 143: {
|
|
454
|
+
readonly morpho: "0xD5D960E8C380B724a48AC59E2DfF1b2CB4a1eAee";
|
|
455
|
+
readonly bundler3: {
|
|
456
|
+
readonly bundler3: "0x82b684483e844422FD339df0b67b3B111F02c66E";
|
|
457
|
+
readonly generalAdapter1: "0x725AB8CAd931BCb80Fdbf10955a806765cCe00e5";
|
|
458
|
+
};
|
|
459
|
+
readonly adaptiveCurveIrm: "0x09475a3D6eA8c314c592b1a3799bDE044E2F400F";
|
|
460
|
+
readonly publicAllocator: "0xfd70575B732F9482F4197FE1075492e114E97302";
|
|
461
|
+
readonly metaMorphoFactory: "0x33f20973275B2F574488b18929cd7DCBf1AbF275";
|
|
462
|
+
readonly vaultV2Factory: "0x8B2F922162FBb60A6a072cC784A2E4168fB0bb0c";
|
|
463
|
+
readonly morphoMarketV1AdapterFactory: "0x8Da54fbF89B3D6fC6DCC92F31CF75a211ACF3d46";
|
|
464
|
+
readonly morphoVaultV1AdapterFactory: "0x9f3c0999425656fD189C69a8aD68cB64986D644A";
|
|
465
|
+
readonly registryList: "0x6a42f8b46224baA4DbBBc2F860F4675eeA7bd52B";
|
|
466
|
+
readonly chainlinkOracleFactory: "0xC8659Bcd5279DB664Be973aEFd752a5326653739";
|
|
467
|
+
readonly preLiquidationFactory: "0xB5b3e541abD19799E0c65905a5a42BD37d6c94c0";
|
|
468
|
+
readonly wNative: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A";
|
|
469
|
+
readonly usdc: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603";
|
|
470
|
+
};
|
|
440
471
|
};
|
|
441
472
|
export type ChainDeployments<Addresses = ChainAddresses> = {
|
|
442
473
|
[key in keyof Addresses]: Address extends Addresses[key] ? bigint : ChainDeployments<Addresses[key]>;
|
|
@@ -773,6 +804,35 @@ declare const _deployments: {
|
|
|
773
804
|
readonly preLiquidationFactory: 168897284n;
|
|
774
805
|
readonly usdc: 154131168n;
|
|
775
806
|
};
|
|
807
|
+
readonly 16661: {
|
|
808
|
+
readonly morpho: 7526486n;
|
|
809
|
+
readonly bundler3: {
|
|
810
|
+
readonly bundler3: 7527649n;
|
|
811
|
+
readonly generalAdapter1: 7527649n;
|
|
812
|
+
};
|
|
813
|
+
readonly adaptiveCurveIrm: 7526486n;
|
|
814
|
+
readonly publicAllocator: 7526486n;
|
|
815
|
+
readonly metaMorphoFactory: 7526768n;
|
|
816
|
+
readonly chainlinkOracleFactory: 7526768n;
|
|
817
|
+
readonly preLiquidationFactory: 7527649n;
|
|
818
|
+
};
|
|
819
|
+
readonly 143: {
|
|
820
|
+
readonly morpho: 31907457n;
|
|
821
|
+
readonly bundler3: {
|
|
822
|
+
readonly bundler3: 32321504n;
|
|
823
|
+
readonly generalAdapter1: 32321504n;
|
|
824
|
+
};
|
|
825
|
+
readonly adaptiveCurveIrm: 31907457n;
|
|
826
|
+
readonly publicAllocator: 31907457n;
|
|
827
|
+
readonly metaMorphoFactory: 32320327n;
|
|
828
|
+
readonly vaultV2Factory: 32321811n;
|
|
829
|
+
readonly morphoMarketV1AdapterFactory: 32321811n;
|
|
830
|
+
readonly morphoVaultV1AdapterFactory: 32321811n;
|
|
831
|
+
readonly registryList: 32322465n;
|
|
832
|
+
readonly chainlinkOracleFactory: 32320327n;
|
|
833
|
+
readonly preLiquidationFactory: 32321504n;
|
|
834
|
+
readonly usdc: 22909616n;
|
|
835
|
+
};
|
|
776
836
|
};
|
|
777
837
|
export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
|
|
778
838
|
export declare const getChainAddresses: (chainId: number) => ChainAddresses;
|
|
@@ -1194,6 +1254,37 @@ export declare let addressesRegistry: {
|
|
|
1194
1254
|
readonly wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7";
|
|
1195
1255
|
readonly usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392";
|
|
1196
1256
|
};
|
|
1257
|
+
readonly 16661: {
|
|
1258
|
+
readonly morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e";
|
|
1259
|
+
readonly bundler3: {
|
|
1260
|
+
readonly bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae";
|
|
1261
|
+
readonly generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054";
|
|
1262
|
+
};
|
|
1263
|
+
readonly adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e";
|
|
1264
|
+
readonly publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497";
|
|
1265
|
+
readonly metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f";
|
|
1266
|
+
readonly chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43";
|
|
1267
|
+
readonly preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802";
|
|
1268
|
+
readonly wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c";
|
|
1269
|
+
};
|
|
1270
|
+
readonly 143: {
|
|
1271
|
+
readonly morpho: "0xD5D960E8C380B724a48AC59E2DfF1b2CB4a1eAee";
|
|
1272
|
+
readonly bundler3: {
|
|
1273
|
+
readonly bundler3: "0x82b684483e844422FD339df0b67b3B111F02c66E";
|
|
1274
|
+
readonly generalAdapter1: "0x725AB8CAd931BCb80Fdbf10955a806765cCe00e5";
|
|
1275
|
+
};
|
|
1276
|
+
readonly adaptiveCurveIrm: "0x09475a3D6eA8c314c592b1a3799bDE044E2F400F";
|
|
1277
|
+
readonly publicAllocator: "0xfd70575B732F9482F4197FE1075492e114E97302";
|
|
1278
|
+
readonly metaMorphoFactory: "0x33f20973275B2F574488b18929cd7DCBf1AbF275";
|
|
1279
|
+
readonly vaultV2Factory: "0x8B2F922162FBb60A6a072cC784A2E4168fB0bb0c";
|
|
1280
|
+
readonly morphoMarketV1AdapterFactory: "0x8Da54fbF89B3D6fC6DCC92F31CF75a211ACF3d46";
|
|
1281
|
+
readonly morphoVaultV1AdapterFactory: "0x9f3c0999425656fD189C69a8aD68cB64986D644A";
|
|
1282
|
+
readonly registryList: "0x6a42f8b46224baA4DbBBc2F860F4675eeA7bd52B";
|
|
1283
|
+
readonly chainlinkOracleFactory: "0xC8659Bcd5279DB664Be973aEFd752a5326653739";
|
|
1284
|
+
readonly preLiquidationFactory: "0xB5b3e541abD19799E0c65905a5a42BD37d6c94c0";
|
|
1285
|
+
readonly wNative: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A";
|
|
1286
|
+
readonly usdc: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603";
|
|
1287
|
+
};
|
|
1197
1288
|
};
|
|
1198
1289
|
export declare let addresses: Record<number, ChainAddresses>;
|
|
1199
1290
|
export declare let deployments: {
|
|
@@ -1528,6 +1619,35 @@ export declare let deployments: {
|
|
|
1528
1619
|
readonly preLiquidationFactory: 168897284n;
|
|
1529
1620
|
readonly usdc: 154131168n;
|
|
1530
1621
|
};
|
|
1622
|
+
readonly 16661: {
|
|
1623
|
+
readonly morpho: 7526486n;
|
|
1624
|
+
readonly bundler3: {
|
|
1625
|
+
readonly bundler3: 7527649n;
|
|
1626
|
+
readonly generalAdapter1: 7527649n;
|
|
1627
|
+
};
|
|
1628
|
+
readonly adaptiveCurveIrm: 7526486n;
|
|
1629
|
+
readonly publicAllocator: 7526486n;
|
|
1630
|
+
readonly metaMorphoFactory: 7526768n;
|
|
1631
|
+
readonly chainlinkOracleFactory: 7526768n;
|
|
1632
|
+
readonly preLiquidationFactory: 7527649n;
|
|
1633
|
+
};
|
|
1634
|
+
readonly 143: {
|
|
1635
|
+
readonly morpho: 31907457n;
|
|
1636
|
+
readonly bundler3: {
|
|
1637
|
+
readonly bundler3: 32321504n;
|
|
1638
|
+
readonly generalAdapter1: 32321504n;
|
|
1639
|
+
};
|
|
1640
|
+
readonly adaptiveCurveIrm: 31907457n;
|
|
1641
|
+
readonly publicAllocator: 31907457n;
|
|
1642
|
+
readonly metaMorphoFactory: 32320327n;
|
|
1643
|
+
readonly vaultV2Factory: 32321811n;
|
|
1644
|
+
readonly morphoMarketV1AdapterFactory: 32321811n;
|
|
1645
|
+
readonly morphoVaultV1AdapterFactory: 32321811n;
|
|
1646
|
+
readonly registryList: 32322465n;
|
|
1647
|
+
readonly chainlinkOracleFactory: 32320327n;
|
|
1648
|
+
readonly preLiquidationFactory: 32321504n;
|
|
1649
|
+
readonly usdc: 22909616n;
|
|
1650
|
+
};
|
|
1531
1651
|
};
|
|
1532
1652
|
export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
|
|
1533
1653
|
/**
|
package/lib/addresses.js
CHANGED
|
@@ -426,6 +426,37 @@ const _addressesRegistry = {
|
|
|
426
426
|
wNative: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",
|
|
427
427
|
usdc: "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392",
|
|
428
428
|
},
|
|
429
|
+
[chain_js_1.ChainId.ZeroGMainnet]: {
|
|
430
|
+
morpho: "0x9CDD13a2212D94C4f12190cA30783B743E83C89e",
|
|
431
|
+
bundler3: {
|
|
432
|
+
bundler3: "0xbDaFC7ceF85C5fF69164330F521089C9E15DDDae",
|
|
433
|
+
generalAdapter1: "0xFaD987d0EedfbAC709EC27ee4a94f36A1300a054",
|
|
434
|
+
},
|
|
435
|
+
adaptiveCurveIrm: "0xf52e20C42FEc624819D4184226C4777D7cbd767e",
|
|
436
|
+
publicAllocator: "0x28a80F3713735CAD44bD9d7E1da9Fa16b0244497",
|
|
437
|
+
metaMorphoFactory: "0x41528AadC7314658b07Ca6e7213B9b77289B477f",
|
|
438
|
+
chainlinkOracleFactory: "0x5115c1a74ABf096150593EecF3e20F016fc9dB43",
|
|
439
|
+
preLiquidationFactory: "0x534858821653467c2ae231dc027aa1F2c8D91802",
|
|
440
|
+
wNative: "0x1Cd0690fF9a693f5EF2dD976660a8dAFc81A109c",
|
|
441
|
+
},
|
|
442
|
+
[chain_js_1.ChainId.MonadMainnet]: {
|
|
443
|
+
morpho: "0xD5D960E8C380B724a48AC59E2DfF1b2CB4a1eAee",
|
|
444
|
+
bundler3: {
|
|
445
|
+
bundler3: "0x82b684483e844422FD339df0b67b3B111F02c66E",
|
|
446
|
+
generalAdapter1: "0x725AB8CAd931BCb80Fdbf10955a806765cCe00e5",
|
|
447
|
+
},
|
|
448
|
+
adaptiveCurveIrm: "0x09475a3D6eA8c314c592b1a3799bDE044E2F400F",
|
|
449
|
+
publicAllocator: "0xfd70575B732F9482F4197FE1075492e114E97302",
|
|
450
|
+
metaMorphoFactory: "0x33f20973275B2F574488b18929cd7DCBf1AbF275",
|
|
451
|
+
vaultV2Factory: "0x8B2F922162FBb60A6a072cC784A2E4168fB0bb0c",
|
|
452
|
+
morphoMarketV1AdapterFactory: "0x8Da54fbF89B3D6fC6DCC92F31CF75a211ACF3d46",
|
|
453
|
+
morphoVaultV1AdapterFactory: "0x9f3c0999425656fD189C69a8aD68cB64986D644A",
|
|
454
|
+
registryList: "0x6a42f8b46224baA4DbBBc2F860F4675eeA7bd52B",
|
|
455
|
+
chainlinkOracleFactory: "0xC8659Bcd5279DB664Be973aEFd752a5326653739",
|
|
456
|
+
preLiquidationFactory: "0xB5b3e541abD19799E0c65905a5a42BD37d6c94c0",
|
|
457
|
+
wNative: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A",
|
|
458
|
+
usdc: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
459
|
+
},
|
|
429
460
|
};
|
|
430
461
|
const _deployments = {
|
|
431
462
|
[chain_js_1.ChainId.EthMainnet]: {
|
|
@@ -759,6 +790,35 @@ const _deployments = {
|
|
|
759
790
|
preLiquidationFactory: 168897284n,
|
|
760
791
|
usdc: 154131168n,
|
|
761
792
|
},
|
|
793
|
+
[chain_js_1.ChainId.ZeroGMainnet]: {
|
|
794
|
+
morpho: 7526486n,
|
|
795
|
+
bundler3: {
|
|
796
|
+
bundler3: 7527649n,
|
|
797
|
+
generalAdapter1: 7527649n,
|
|
798
|
+
},
|
|
799
|
+
adaptiveCurveIrm: 7526486n,
|
|
800
|
+
publicAllocator: 7526486n,
|
|
801
|
+
metaMorphoFactory: 7526768n,
|
|
802
|
+
chainlinkOracleFactory: 7526768n,
|
|
803
|
+
preLiquidationFactory: 7527649n,
|
|
804
|
+
},
|
|
805
|
+
[chain_js_1.ChainId.MonadMainnet]: {
|
|
806
|
+
morpho: 31907457n,
|
|
807
|
+
bundler3: {
|
|
808
|
+
bundler3: 32321504n,
|
|
809
|
+
generalAdapter1: 32321504n,
|
|
810
|
+
},
|
|
811
|
+
adaptiveCurveIrm: 31907457n,
|
|
812
|
+
publicAllocator: 31907457n,
|
|
813
|
+
metaMorphoFactory: 32320327n,
|
|
814
|
+
vaultV2Factory: 32321811n,
|
|
815
|
+
morphoMarketV1AdapterFactory: 32321811n,
|
|
816
|
+
morphoVaultV1AdapterFactory: 32321811n,
|
|
817
|
+
registryList: 32322465n,
|
|
818
|
+
chainlinkOracleFactory: 32320327n,
|
|
819
|
+
preLiquidationFactory: 32321504n,
|
|
820
|
+
usdc: 22909616n,
|
|
821
|
+
},
|
|
762
822
|
};
|
|
763
823
|
const getChainAddresses = (chainId) => {
|
|
764
824
|
const chainAddresses = exports.addresses[chainId];
|
|
@@ -847,6 +907,12 @@ const _unwrappedTokensMapping = {
|
|
|
847
907
|
[chain_js_1.ChainId.SeiMainnet]: {
|
|
848
908
|
[_addressesRegistry[chain_js_1.ChainId.SeiMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
849
909
|
},
|
|
910
|
+
[chain_js_1.ChainId.ZeroGMainnet]: {
|
|
911
|
+
[_addressesRegistry[chain_js_1.ChainId.ZeroGMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
912
|
+
},
|
|
913
|
+
[chain_js_1.ChainId.MonadMainnet]: {
|
|
914
|
+
[_addressesRegistry[chain_js_1.ChainId.MonadMainnet].wNative]: exports.NATIVE_ADDRESS,
|
|
915
|
+
},
|
|
850
916
|
};
|
|
851
917
|
function getUnwrappedToken(wrappedToken, chainId) {
|
|
852
918
|
return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
|
package/lib/chain.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export declare enum ChainId {
|
|
|
20
20
|
TacMainnet = 239,
|
|
21
21
|
LiskMainnet = 1135,
|
|
22
22
|
HyperliquidMainnet = 999,
|
|
23
|
-
SeiMainnet = 1329
|
|
23
|
+
SeiMainnet = 1329,
|
|
24
|
+
ZeroGMainnet = 16661,
|
|
25
|
+
MonadMainnet = 143
|
|
24
26
|
}
|
|
25
27
|
export interface ChainMetadata {
|
|
26
28
|
readonly name: string;
|
|
@@ -281,5 +283,27 @@ export declare namespace ChainUtils {
|
|
|
281
283
|
explorerUrl: string;
|
|
282
284
|
identifier: string;
|
|
283
285
|
};
|
|
286
|
+
16661: {
|
|
287
|
+
name: string;
|
|
288
|
+
id: ChainId.ZeroGMainnet;
|
|
289
|
+
nativeCurrency: {
|
|
290
|
+
name: string;
|
|
291
|
+
symbol: string;
|
|
292
|
+
decimals: number;
|
|
293
|
+
};
|
|
294
|
+
explorerUrl: string;
|
|
295
|
+
identifier: string;
|
|
296
|
+
};
|
|
297
|
+
143: {
|
|
298
|
+
name: string;
|
|
299
|
+
id: ChainId.MonadMainnet;
|
|
300
|
+
nativeCurrency: {
|
|
301
|
+
name: string;
|
|
302
|
+
symbol: string;
|
|
303
|
+
decimals: number;
|
|
304
|
+
};
|
|
305
|
+
explorerUrl: string;
|
|
306
|
+
identifier: string;
|
|
307
|
+
};
|
|
284
308
|
};
|
|
285
309
|
}
|
package/lib/chain.js
CHANGED
|
@@ -25,6 +25,8 @@ var ChainId;
|
|
|
25
25
|
ChainId[ChainId["LiskMainnet"] = 1135] = "LiskMainnet";
|
|
26
26
|
ChainId[ChainId["HyperliquidMainnet"] = 999] = "HyperliquidMainnet";
|
|
27
27
|
ChainId[ChainId["SeiMainnet"] = 1329] = "SeiMainnet";
|
|
28
|
+
ChainId[ChainId["ZeroGMainnet"] = 16661] = "ZeroGMainnet";
|
|
29
|
+
ChainId[ChainId["MonadMainnet"] = 143] = "MonadMainnet";
|
|
28
30
|
})(ChainId || (exports.ChainId = ChainId = {}));
|
|
29
31
|
var ChainUtils;
|
|
30
32
|
(function (ChainUtils) {
|
|
@@ -195,5 +197,19 @@ var ChainUtils;
|
|
|
195
197
|
explorerUrl: "https://seitrace.com",
|
|
196
198
|
identifier: "sei",
|
|
197
199
|
},
|
|
200
|
+
[ChainId.ZeroGMainnet]: {
|
|
201
|
+
name: "0G",
|
|
202
|
+
id: ChainId.ZeroGMainnet,
|
|
203
|
+
nativeCurrency: { name: "0G", symbol: "0G", decimals: 18 },
|
|
204
|
+
explorerUrl: "https://chainscan.0g.ai",
|
|
205
|
+
identifier: "0G",
|
|
206
|
+
},
|
|
207
|
+
[ChainId.MonadMainnet]: {
|
|
208
|
+
name: "Monad",
|
|
209
|
+
id: ChainId.MonadMainnet,
|
|
210
|
+
nativeCurrency: { name: "Monad", symbol: "MON", decimals: 18 },
|
|
211
|
+
explorerUrl: "https://monad.socialscan.io",
|
|
212
|
+
identifier: "monad",
|
|
213
|
+
},
|
|
198
214
|
};
|
|
199
215
|
})(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
2
1
|
import type { Address, MarketId } from "./types.js";
|
|
3
|
-
export declare class InvalidMarketParamsError extends Error {
|
|
4
|
-
readonly data: Hex;
|
|
5
|
-
constructor(data: Hex);
|
|
6
|
-
}
|
|
7
2
|
export declare class UnknownDataError extends Error {
|
|
8
3
|
}
|
|
9
4
|
export declare class UnknownTokenError extends UnknownDataError {
|
|
@@ -30,10 +25,6 @@ export declare class UnsupportedPreLiquidationParamsError extends Error {
|
|
|
30
25
|
readonly lltv: bigint;
|
|
31
26
|
constructor(lltv: bigint);
|
|
32
27
|
}
|
|
33
|
-
export declare class UnsupportedVaultV2AdapterError extends Error {
|
|
34
|
-
readonly address: Address;
|
|
35
|
-
constructor(address: Address);
|
|
36
|
-
}
|
|
37
28
|
export declare namespace BlueErrors {
|
|
38
29
|
class AlreadySet extends Error {
|
|
39
30
|
readonly name: string;
|
|
@@ -74,18 +65,6 @@ export declare namespace BlueErrors {
|
|
|
74
65
|
constructor(deadline: bigint);
|
|
75
66
|
}
|
|
76
67
|
}
|
|
77
|
-
export declare namespace VaultV2Errors {
|
|
78
|
-
class InvalidInterestAccrual extends Error {
|
|
79
|
-
readonly vault: Address;
|
|
80
|
-
readonly timestamp: bigint;
|
|
81
|
-
readonly lastUpdate: bigint;
|
|
82
|
-
constructor(vault: Address, timestamp: bigint, lastUpdate: bigint);
|
|
83
|
-
}
|
|
84
|
-
class UnsupportedLiquidityAdapter extends Error {
|
|
85
|
-
readonly address: Address;
|
|
86
|
-
constructor(address: Address);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
68
|
export interface ErrorClass<E extends Error> {
|
|
90
69
|
new (...args: any[]): E;
|
|
91
70
|
}
|
package/lib/errors.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BlueErrors = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketParamsError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
4
4
|
exports._try = _try;
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
|
-
class InvalidMarketParamsError extends Error {
|
|
7
|
-
data;
|
|
8
|
-
constructor(data) {
|
|
9
|
-
super(`cannot decode valid MarketParams from "${data}"`);
|
|
10
|
-
this.data = data;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.InvalidMarketParamsError = InvalidMarketParamsError;
|
|
14
6
|
class UnknownDataError extends Error {
|
|
15
7
|
}
|
|
16
8
|
exports.UnknownDataError = UnknownDataError;
|
|
@@ -62,14 +54,6 @@ class UnsupportedPreLiquidationParamsError extends Error {
|
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
56
|
exports.UnsupportedPreLiquidationParamsError = UnsupportedPreLiquidationParamsError;
|
|
65
|
-
class UnsupportedVaultV2AdapterError extends Error {
|
|
66
|
-
address;
|
|
67
|
-
constructor(address) {
|
|
68
|
-
super(`vault v2 adapter "${address}" is not supported`);
|
|
69
|
-
this.address = address;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.UnsupportedVaultV2AdapterError = UnsupportedVaultV2AdapterError;
|
|
73
57
|
var BlueErrors;
|
|
74
58
|
(function (BlueErrors) {
|
|
75
59
|
class AlreadySet extends Error {
|
|
@@ -149,29 +133,6 @@ var BlueErrors;
|
|
|
149
133
|
}
|
|
150
134
|
BlueErrors.ExpiredSignature = ExpiredSignature;
|
|
151
135
|
})(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
|
|
152
|
-
var VaultV2Errors;
|
|
153
|
-
(function (VaultV2Errors) {
|
|
154
|
-
class InvalidInterestAccrual extends Error {
|
|
155
|
-
vault;
|
|
156
|
-
timestamp;
|
|
157
|
-
lastUpdate;
|
|
158
|
-
constructor(vault, timestamp, lastUpdate) {
|
|
159
|
-
super(`invalid interest accrual on vault ${vault}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
160
|
-
this.vault = vault;
|
|
161
|
-
this.timestamp = timestamp;
|
|
162
|
-
this.lastUpdate = lastUpdate;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
VaultV2Errors.InvalidInterestAccrual = InvalidInterestAccrual;
|
|
166
|
-
class UnsupportedLiquidityAdapter extends Error {
|
|
167
|
-
address;
|
|
168
|
-
constructor(address) {
|
|
169
|
-
super(`unsupported liquidity adapter "${address}"`);
|
|
170
|
-
this.address = address;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
VaultV2Errors.UnsupportedLiquidityAdapter = UnsupportedLiquidityAdapter;
|
|
174
|
-
})(VaultV2Errors || (exports.VaultV2Errors = VaultV2Errors = {}));
|
|
175
136
|
function _try(accessor, ...errorClasses) {
|
|
176
137
|
const maybeCatchError = (error) => {
|
|
177
138
|
if (errorClasses.length === 0 ||
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -27,4 +27,3 @@ __exportStar(require("./holding/index.js"), exports);
|
|
|
27
27
|
__exportStar(require("./position/index.js"), exports);
|
|
28
28
|
__exportStar(require("./vault/index.js"), exports);
|
|
29
29
|
__exportStar(require("./preLiquidation.js"), exports);
|
|
30
|
-
__exportStar(require("./utils.js"), exports);
|
package/lib/market/Market.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { type RoundingDirection } from "../math/index.js";
|
|
2
2
|
import type { BigIntish } from "../types.js";
|
|
3
|
-
import { type CapacityLimit } from "../utils.js";
|
|
4
3
|
import { type IMarketParams, MarketParams } from "./MarketParams.js";
|
|
4
|
+
export declare enum CapacityLimitReason {
|
|
5
|
+
liquidity = "Liquidity",
|
|
6
|
+
balance = "Balance",
|
|
7
|
+
position = "Position",
|
|
8
|
+
collateral = "Collateral",
|
|
9
|
+
cap = "Cap"
|
|
10
|
+
}
|
|
11
|
+
export interface CapacityLimit {
|
|
12
|
+
value: bigint;
|
|
13
|
+
limiter: CapacityLimitReason;
|
|
14
|
+
}
|
|
5
15
|
export interface MaxBorrowOptions {
|
|
6
16
|
maxLtv?: bigint;
|
|
7
17
|
}
|
package/lib/market/Market.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Market = void 0;
|
|
3
|
+
exports.Market = exports.CapacityLimitReason = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
const errors_js_1 = require("../errors.js");
|
|
6
6
|
const index_js_1 = require("../math/index.js");
|
|
7
|
-
const utils_js_1 = require("../utils.js");
|
|
8
7
|
const MarketParams_js_1 = require("./MarketParams.js");
|
|
9
8
|
const MarketUtils_js_1 = require("./MarketUtils.js");
|
|
9
|
+
var CapacityLimitReason;
|
|
10
|
+
(function (CapacityLimitReason) {
|
|
11
|
+
CapacityLimitReason["liquidity"] = "Liquidity";
|
|
12
|
+
CapacityLimitReason["balance"] = "Balance";
|
|
13
|
+
CapacityLimitReason["position"] = "Position";
|
|
14
|
+
CapacityLimitReason["collateral"] = "Collateral";
|
|
15
|
+
CapacityLimitReason["cap"] = "Cap";
|
|
16
|
+
})(CapacityLimitReason || (exports.CapacityLimitReason = CapacityLimitReason = {}));
|
|
10
17
|
/**
|
|
11
18
|
* Represents a lending market on Morpho Blue.
|
|
12
19
|
*/
|
|
@@ -50,7 +57,8 @@ class Market {
|
|
|
50
57
|
*/
|
|
51
58
|
rateAtTarget;
|
|
52
59
|
constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }) {
|
|
53
|
-
this.params =
|
|
60
|
+
this.params =
|
|
61
|
+
params instanceof MarketParams_js_1.MarketParams ? params : new MarketParams_js_1.MarketParams(params);
|
|
54
62
|
this.totalSupplyAssets = totalSupplyAssets;
|
|
55
63
|
this.totalBorrowAssets = totalBorrowAssets;
|
|
56
64
|
this.totalSupplyShares = totalSupplyShares;
|
|
@@ -490,11 +498,11 @@ class Market {
|
|
|
490
498
|
if (maxBorrowableAssets > liquidity)
|
|
491
499
|
return {
|
|
492
500
|
value: liquidity,
|
|
493
|
-
limiter:
|
|
501
|
+
limiter: CapacityLimitReason.liquidity,
|
|
494
502
|
};
|
|
495
503
|
return {
|
|
496
504
|
value: maxBorrowableAssets,
|
|
497
|
-
limiter:
|
|
505
|
+
limiter: CapacityLimitReason.collateral,
|
|
498
506
|
};
|
|
499
507
|
}
|
|
500
508
|
/**
|
|
@@ -507,11 +515,11 @@ class Market {
|
|
|
507
515
|
if (borrowAssets > loanTokenBalance)
|
|
508
516
|
return {
|
|
509
517
|
value: loanTokenBalance,
|
|
510
|
-
limiter:
|
|
518
|
+
limiter: CapacityLimitReason.balance,
|
|
511
519
|
};
|
|
512
520
|
return {
|
|
513
521
|
value: borrowAssets,
|
|
514
|
-
limiter:
|
|
522
|
+
limiter: CapacityLimitReason.position,
|
|
515
523
|
};
|
|
516
524
|
}
|
|
517
525
|
/**
|
|
@@ -525,11 +533,11 @@ class Market {
|
|
|
525
533
|
if (supplyAssets > liquidity)
|
|
526
534
|
return {
|
|
527
535
|
value: liquidity,
|
|
528
|
-
limiter:
|
|
536
|
+
limiter: CapacityLimitReason.liquidity,
|
|
529
537
|
};
|
|
530
538
|
return {
|
|
531
539
|
value: supplyAssets,
|
|
532
|
-
limiter:
|
|
540
|
+
limiter: CapacityLimitReason.position,
|
|
533
541
|
};
|
|
534
542
|
}
|
|
535
543
|
/**
|
|
@@ -545,11 +553,11 @@ class Market {
|
|
|
545
553
|
if (position.collateral > withdrawableCollateral)
|
|
546
554
|
return {
|
|
547
555
|
value: withdrawableCollateral,
|
|
548
|
-
limiter:
|
|
556
|
+
limiter: CapacityLimitReason.collateral,
|
|
549
557
|
};
|
|
550
558
|
return {
|
|
551
559
|
value: position.collateral,
|
|
552
|
-
limiter:
|
|
560
|
+
limiter: CapacityLimitReason.position,
|
|
553
561
|
};
|
|
554
562
|
}
|
|
555
563
|
/**
|
|
@@ -563,14 +571,14 @@ class Market {
|
|
|
563
571
|
return {
|
|
564
572
|
supply: {
|
|
565
573
|
value: loanTokenBalance,
|
|
566
|
-
limiter:
|
|
574
|
+
limiter: CapacityLimitReason.balance,
|
|
567
575
|
},
|
|
568
576
|
withdraw: this.getWithdrawCapacityLimit(position),
|
|
569
577
|
borrow: this.getBorrowCapacityLimit(position, options?.borrow),
|
|
570
578
|
repay: this.getRepayCapacityLimit(position.borrowShares, loanTokenBalance),
|
|
571
579
|
supplyCollateral: {
|
|
572
580
|
value: collateralTokenBalance,
|
|
573
|
-
limiter:
|
|
581
|
+
limiter: CapacityLimitReason.balance,
|
|
574
582
|
},
|
|
575
583
|
withdrawCollateral: this.getWithdrawCollateralCapacityLimit(position, options?.withdrawCollateral),
|
|
576
584
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Address, BigIntish, MarketId } from "../types.js";
|
|
2
|
-
import { type Hex } from "viem";
|
|
3
2
|
export interface IMarketParams {
|
|
4
3
|
loanToken: Address;
|
|
5
4
|
collateralToken: Address;
|
|
@@ -8,25 +7,6 @@ export interface IMarketParams {
|
|
|
8
7
|
lltv: BigIntish;
|
|
9
8
|
}
|
|
10
9
|
export type InputMarketParams = Pick<MarketParams, "loanToken" | "collateralToken" | "oracle" | "irm" | "lltv">;
|
|
11
|
-
export declare const marketParamsAbi: {
|
|
12
|
-
readonly type: "tuple";
|
|
13
|
-
readonly components: readonly [{
|
|
14
|
-
readonly type: "address";
|
|
15
|
-
readonly name: "loanToken";
|
|
16
|
-
}, {
|
|
17
|
-
readonly type: "address";
|
|
18
|
-
readonly name: "collateralToken";
|
|
19
|
-
}, {
|
|
20
|
-
readonly type: "address";
|
|
21
|
-
readonly name: "oracle";
|
|
22
|
-
}, {
|
|
23
|
-
readonly type: "address";
|
|
24
|
-
readonly name: "irm";
|
|
25
|
-
}, {
|
|
26
|
-
readonly type: "uint256";
|
|
27
|
-
readonly name: "lltv";
|
|
28
|
-
}];
|
|
29
|
-
};
|
|
30
10
|
/**
|
|
31
11
|
* Represents a market's configuration (also called market params).
|
|
32
12
|
*/
|
|
@@ -41,7 +21,6 @@ export declare class MarketParams implements IMarketParams {
|
|
|
41
21
|
* Returns the canonical idle market configuration for the given loan token.
|
|
42
22
|
*/
|
|
43
23
|
static idle(token: Address): MarketParams;
|
|
44
|
-
static fromHex(data: Hex): MarketParams;
|
|
45
24
|
/**
|
|
46
25
|
* The market's collateral token address.
|
|
47
26
|
*/
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MarketParams =
|
|
3
|
+
exports.MarketParams = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
5
|
const errors_js_1 = require("../errors.js");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
6
|
const MarketUtils_js_1 = require("./MarketUtils.js");
|
|
8
|
-
exports.marketParamsAbi = {
|
|
9
|
-
type: "tuple",
|
|
10
|
-
components: [
|
|
11
|
-
{ type: "address", name: "loanToken" },
|
|
12
|
-
{ type: "address", name: "collateralToken" },
|
|
13
|
-
{ type: "address", name: "oracle" },
|
|
14
|
-
{ type: "address", name: "irm" },
|
|
15
|
-
{ type: "uint256", name: "lltv" },
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
7
|
/**
|
|
19
8
|
* Represents a market's configuration (also called market params).
|
|
20
9
|
*/
|
|
@@ -42,15 +31,6 @@ class MarketParams {
|
|
|
42
31
|
lltv: 0n,
|
|
43
32
|
});
|
|
44
33
|
}
|
|
45
|
-
static fromHex(data) {
|
|
46
|
-
try {
|
|
47
|
-
const [marketParams] = (0, viem_1.decodeAbiParameters)([exports.marketParamsAbi], data);
|
|
48
|
-
return new MarketParams(marketParams);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
throw new errors_js_1.InvalidMarketParamsError(data);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
34
|
/**
|
|
55
35
|
* The market's collateral token address.
|
|
56
36
|
*/
|
|
@@ -109,7 +109,7 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
|
|
|
109
109
|
* Returns the maximum amount of loan assets that can be withdrawn given a certain supply position
|
|
110
110
|
* and a balance of loan assets, and the reason for the limit.
|
|
111
111
|
*/
|
|
112
|
-
get withdrawCapacityLimit(): import("../
|
|
112
|
+
get withdrawCapacityLimit(): import("../market/Market.js").CapacityLimit;
|
|
113
113
|
/**
|
|
114
114
|
* Returns a new position derived from this position, whose interest has been accrued up to the given timestamp.
|
|
115
115
|
* @param timestamp The timestamp at which to accrue interest. Must be greater than or equal to the market's `lastUpdate`.
|
|
@@ -137,9 +137,9 @@ export declare class AccrualPosition extends Position implements IAccrualPositio
|
|
|
137
137
|
assets: bigint;
|
|
138
138
|
shares: bigint;
|
|
139
139
|
};
|
|
140
|
-
getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../
|
|
141
|
-
getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../
|
|
142
|
-
getRepayCapacityLimit(loanTokenBalance: bigint): import("../
|
|
140
|
+
getBorrowCapacityLimit(options?: MaxBorrowOptions): import("../market/Market.js").CapacityLimit | undefined;
|
|
141
|
+
getWithdrawCollateralCapacityLimit(options?: MaxWithdrawCollateralOptions): import("../market/Market.js").CapacityLimit | undefined;
|
|
142
|
+
getRepayCapacityLimit(loanTokenBalance: bigint): import("../market/Market.js").CapacityLimit;
|
|
143
143
|
getMaxCapacities(loanTokenBalance: bigint, collateralTokenBalance: bigint, options?: {
|
|
144
144
|
borrow?: MaxBorrowOptions;
|
|
145
145
|
withdrawCollateral?: MaxWithdrawCollateralOptions;
|
package/lib/position/Position.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.AccrualPosition = exports.Position = void 0;
|
|
|
4
4
|
const errors_js_1 = require("../errors.js");
|
|
5
5
|
const index_js_1 = require("../market/index.js");
|
|
6
6
|
const MathLib_js_1 = require("../math/MathLib.js");
|
|
7
|
-
const utils_js_1 = require("../utils.js");
|
|
8
7
|
class Position {
|
|
9
8
|
/**
|
|
10
9
|
* The user holding this position.
|
|
@@ -226,14 +225,14 @@ class AccrualPosition extends Position {
|
|
|
226
225
|
return {
|
|
227
226
|
supply: {
|
|
228
227
|
value: loanTokenBalance,
|
|
229
|
-
limiter:
|
|
228
|
+
limiter: index_js_1.CapacityLimitReason.balance,
|
|
230
229
|
},
|
|
231
230
|
withdraw: this.withdrawCapacityLimit,
|
|
232
231
|
borrow: this.getBorrowCapacityLimit(options?.borrow),
|
|
233
232
|
repay: this.getRepayCapacityLimit(loanTokenBalance),
|
|
234
233
|
supplyCollateral: {
|
|
235
234
|
value: collateralTokenBalance,
|
|
236
|
-
limiter:
|
|
235
|
+
limiter: index_js_1.CapacityLimitReason.balance,
|
|
237
236
|
},
|
|
238
237
|
withdrawCollateral: this.getWithdrawCollateralCapacityLimit(options?.withdrawCollateral),
|
|
239
238
|
};
|