@defisaver/positions-sdk 0.0.30 → 0.0.32
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 +63 -63
- package/cjs/config/contracts.d.ts +115 -0
- package/cjs/config/contracts.js +14 -0
- package/cjs/constants/index.d.ts +2 -0
- package/cjs/constants/index.js +3 -1
- package/cjs/contracts.d.ts +2 -0
- package/cjs/contracts.js +3 -1
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/helpers/morphoBlueHelpers/index.d.ts +7 -0
- package/cjs/helpers/morphoBlueHelpers/index.js +41 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/markets/morphoBlue/index.d.ts +6 -0
- package/cjs/markets/morphoBlue/index.js +24 -0
- package/cjs/morphoBlue/index.d.ts +5 -0
- package/cjs/morphoBlue/index.js +153 -0
- package/cjs/types/common.d.ts +1 -1
- package/cjs/types/contracts/generated/FeedRegistry.d.ts +182 -0
- package/cjs/types/contracts/generated/FeedRegistry.js +5 -0
- package/cjs/types/contracts/generated/MorphoBlueView.d.ts +122 -0
- package/cjs/types/contracts/generated/MorphoBlueView.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +2 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/morphoBlue.d.ts +74 -0
- package/cjs/types/morphoBlue.js +7 -0
- package/esm/config/contracts.d.ts +115 -0
- package/esm/config/contracts.js +14 -0
- package/esm/constants/index.d.ts +2 -0
- package/esm/constants/index.js +2 -0
- package/esm/contracts.d.ts +2 -0
- package/esm/contracts.js +2 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/morphoBlueHelpers/index.d.ts +7 -0
- package/esm/helpers/morphoBlueHelpers/index.js +34 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/markets/morphoBlue/index.d.ts +6 -0
- package/esm/markets/morphoBlue/index.js +19 -0
- package/esm/morphoBlue/index.d.ts +5 -0
- package/esm/morphoBlue/index.js +145 -0
- package/esm/types/common.d.ts +1 -1
- package/esm/types/contracts/generated/FeedRegistry.d.ts +182 -0
- package/esm/types/contracts/generated/FeedRegistry.js +4 -0
- package/esm/types/contracts/generated/MorphoBlueView.d.ts +122 -0
- package/esm/types/contracts/generated/MorphoBlueView.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +2 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/morphoBlue.d.ts +74 -0
- package/esm/types/morphoBlue.js +4 -0
- package/package.json +40 -40
- package/src/aaveV2/index.ts +226 -226
- package/src/aaveV3/index.ts +561 -561
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +219 -219
- package/src/compoundV3/index.ts +275 -275
- package/src/config/contracts.js +690 -676
- package/src/constants/index.ts +6 -4
- package/src/contracts.ts +131 -127
- package/src/curveUsd/index.ts +228 -228
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +134 -134
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +181 -181
- package/src/helpers/curveUsdHelpers/index.ts +32 -32
- package/src/helpers/index.ts +7 -6
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +47 -0
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +42 -40
- package/src/liquity/index.ts +116 -116
- package/src/maker/index.ts +101 -101
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +24 -24
- package/src/markets/compound/index.ts +141 -141
- package/src/markets/compound/marketsAssets.ts +48 -48
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +5 -4
- package/src/markets/morphoBlue/index.ts +21 -0
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +75 -75
- package/src/morphoAaveV2/index.ts +255 -255
- package/src/morphoAaveV3/index.ts +619 -619
- package/src/morphoBlue/index.ts +166 -0
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +21 -21
- package/src/services/utils.ts +34 -34
- package/src/spark/index.ts +422 -422
- package/src/staking/staking.ts +167 -167
- package/src/types/aave.ts +256 -256
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +83 -83
- package/src/types/compound.ts +128 -128
- package/src/types/contracts/generated/FeedRegistry.ts +337 -0
- package/src/types/contracts/generated/MorphoBlueView.ts +171 -0
- package/src/types/contracts/generated/index.ts +2 -0
- package/src/types/curveUsd.ts +112 -112
- package/src/types/index.ts +8 -7
- package/src/types/liquity.ts +30 -30
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +80 -0
- package/src/types/spark.ts +106 -106
- package/src/morpho/markets.ts +0 -39
package/README.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
-
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
-
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
-
|
|
16
|
-
## Setup
|
|
17
|
-
Supported Node version is v10.
|
|
18
|
-
|
|
19
|
-
- run `npm install` (first time)
|
|
20
|
-
- run `npm run build`
|
|
21
|
-
|
|
22
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
-
|
|
24
|
-
## How to use
|
|
25
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
-
|
|
27
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
-
```js
|
|
29
|
-
import Web3 from 'web3';
|
|
30
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// every protocol has market data and user data getters
|
|
34
|
-
const {
|
|
35
|
-
getCompoundV3MarketsData,
|
|
36
|
-
getCompoundV3AccountData,
|
|
37
|
-
} = compoundV3;
|
|
38
|
-
|
|
39
|
-
const provider = 'Your RPC provider';
|
|
40
|
-
const web3 = new Web3(provider);
|
|
41
|
-
|
|
42
|
-
const user = '0x123...';
|
|
43
|
-
|
|
44
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
-
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
-
1, // network
|
|
47
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
-
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const userData = await getCompoundV3AccountData(
|
|
52
|
-
web3,
|
|
53
|
-
1, // network
|
|
54
|
-
userAddress, // EOA or DSProxy
|
|
55
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
-
{
|
|
57
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
-
assetsData,
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
+
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
+
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
Supported Node version is v10.
|
|
18
|
+
|
|
19
|
+
- run `npm install` (first time)
|
|
20
|
+
- run `npm run build`
|
|
21
|
+
|
|
22
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
+
|
|
24
|
+
## How to use
|
|
25
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
+
|
|
27
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
+
```js
|
|
29
|
+
import Web3 from 'web3';
|
|
30
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// every protocol has market data and user data getters
|
|
34
|
+
const {
|
|
35
|
+
getCompoundV3MarketsData,
|
|
36
|
+
getCompoundV3AccountData,
|
|
37
|
+
} = compoundV3;
|
|
38
|
+
|
|
39
|
+
const provider = 'Your RPC provider';
|
|
40
|
+
const web3 = new Web3(provider);
|
|
41
|
+
|
|
42
|
+
const user = '0x123...';
|
|
43
|
+
|
|
44
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
+
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
+
1, // network
|
|
47
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
+
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const userData = await getCompoundV3AccountData(
|
|
52
|
+
web3,
|
|
53
|
+
1, // network
|
|
54
|
+
userAddress, // EOA or DSProxy
|
|
55
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
+
{
|
|
57
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
+
assetsData,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
@@ -3617,3 +3617,118 @@ export namespace USDCPriceFeed {
|
|
|
3617
3617
|
};
|
|
3618
3618
|
export { networks_66 as networks };
|
|
3619
3619
|
}
|
|
3620
|
+
export namespace MorphoBlueView {
|
|
3621
|
+
let abi_67: ({
|
|
3622
|
+
inputs: {
|
|
3623
|
+
components: {
|
|
3624
|
+
internalType: string;
|
|
3625
|
+
name: string;
|
|
3626
|
+
type: string;
|
|
3627
|
+
}[];
|
|
3628
|
+
internalType: string;
|
|
3629
|
+
name: string;
|
|
3630
|
+
type: string;
|
|
3631
|
+
}[];
|
|
3632
|
+
name: string;
|
|
3633
|
+
outputs: {
|
|
3634
|
+
internalType: string;
|
|
3635
|
+
name: string;
|
|
3636
|
+
type: string;
|
|
3637
|
+
}[];
|
|
3638
|
+
stateMutability: string;
|
|
3639
|
+
type: string;
|
|
3640
|
+
} | {
|
|
3641
|
+
inputs: ({
|
|
3642
|
+
components: {
|
|
3643
|
+
internalType: string;
|
|
3644
|
+
name: string;
|
|
3645
|
+
type: string;
|
|
3646
|
+
}[];
|
|
3647
|
+
internalType: string;
|
|
3648
|
+
name: string;
|
|
3649
|
+
type: string;
|
|
3650
|
+
} | {
|
|
3651
|
+
internalType: string;
|
|
3652
|
+
name: string;
|
|
3653
|
+
type: string;
|
|
3654
|
+
components?: undefined;
|
|
3655
|
+
})[];
|
|
3656
|
+
name: string;
|
|
3657
|
+
outputs: {
|
|
3658
|
+
components: {
|
|
3659
|
+
internalType: string;
|
|
3660
|
+
name: string;
|
|
3661
|
+
type: string;
|
|
3662
|
+
}[];
|
|
3663
|
+
internalType: string;
|
|
3664
|
+
name: string;
|
|
3665
|
+
type: string;
|
|
3666
|
+
}[];
|
|
3667
|
+
stateMutability: string;
|
|
3668
|
+
type: string;
|
|
3669
|
+
})[];
|
|
3670
|
+
export { abi_67 as abi };
|
|
3671
|
+
let networks_67: {
|
|
3672
|
+
"1": {
|
|
3673
|
+
address: string;
|
|
3674
|
+
};
|
|
3675
|
+
};
|
|
3676
|
+
export { networks_67 as networks };
|
|
3677
|
+
}
|
|
3678
|
+
export namespace FeedRegistry {
|
|
3679
|
+
let abi_68: ({
|
|
3680
|
+
anonymous: boolean;
|
|
3681
|
+
inputs: {
|
|
3682
|
+
indexed: boolean;
|
|
3683
|
+
internalType: string;
|
|
3684
|
+
name: string;
|
|
3685
|
+
type: string;
|
|
3686
|
+
}[];
|
|
3687
|
+
name: string;
|
|
3688
|
+
type: string;
|
|
3689
|
+
outputs?: undefined;
|
|
3690
|
+
stateMutability?: undefined;
|
|
3691
|
+
} | {
|
|
3692
|
+
inputs: {
|
|
3693
|
+
internalType: string;
|
|
3694
|
+
name: string;
|
|
3695
|
+
type: string;
|
|
3696
|
+
}[];
|
|
3697
|
+
name: string;
|
|
3698
|
+
outputs: {
|
|
3699
|
+
internalType: string;
|
|
3700
|
+
name: string;
|
|
3701
|
+
type: string;
|
|
3702
|
+
}[];
|
|
3703
|
+
stateMutability: string;
|
|
3704
|
+
type: string;
|
|
3705
|
+
anonymous?: undefined;
|
|
3706
|
+
} | {
|
|
3707
|
+
inputs: {
|
|
3708
|
+
internalType: string;
|
|
3709
|
+
name: string;
|
|
3710
|
+
type: string;
|
|
3711
|
+
}[];
|
|
3712
|
+
name: string;
|
|
3713
|
+
outputs: {
|
|
3714
|
+
components: {
|
|
3715
|
+
internalType: string;
|
|
3716
|
+
name: string;
|
|
3717
|
+
type: string;
|
|
3718
|
+
}[];
|
|
3719
|
+
internalType: string;
|
|
3720
|
+
name: string;
|
|
3721
|
+
type: string;
|
|
3722
|
+
}[];
|
|
3723
|
+
stateMutability: string;
|
|
3724
|
+
type: string;
|
|
3725
|
+
anonymous?: undefined;
|
|
3726
|
+
})[];
|
|
3727
|
+
export { abi_68 as abi };
|
|
3728
|
+
let networks_68: {
|
|
3729
|
+
"1": {
|
|
3730
|
+
address: string;
|
|
3731
|
+
};
|
|
3732
|
+
};
|
|
3733
|
+
export { networks_68 as networks };
|
|
3734
|
+
}
|
package/cjs/config/contracts.js
CHANGED
|
@@ -673,5 +673,19 @@ module.exports = {
|
|
|
673
673
|
"networks": {
|
|
674
674
|
"1": { "address": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6" }
|
|
675
675
|
}
|
|
676
|
+
},
|
|
677
|
+
"MorphoBlueView": {
|
|
678
|
+
"abi": [{ "inputs": [], "name": "MORPHO_BLUE_ADDRESS", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }], "name": "getMarketId", "outputs": [{ "internalType": "Id", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "Id", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalSupplyAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalSupplyShares", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowShares", "type": "uint128" }, { "internalType": "uint256", "name": "lastUpdate", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "oracle", "type": "uint256" }], "internalType": "struct MorphoBlueView.MarketInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "name": "getMarketInfoNotTuple", "outputs": [{ "components": [{ "internalType": "Id", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalSupplyAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalSupplyShares", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowAssets", "type": "uint128" }, { "internalType": "uint128", "name": "totalBorrowShares", "type": "uint128" }, { "internalType": "uint256", "name": "lastUpdate", "type": "uint256" }, { "internalType": "uint256", "name": "fee", "type": "uint256" }, { "internalType": "uint256", "name": "borrowRate", "type": "uint256" }, { "internalType": "uint256", "name": "oracle", "type": "uint256" }], "internalType": "struct MorphoBlueView.MarketInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "loanToken", "type": "address" }, { "internalType": "address", "name": "collateralToken", "type": "address" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "address", "name": "irm", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }], "internalType": "struct MarketParams", "name": "marketParams", "type": "tuple" }, { "internalType": "address", "name": "owner", "type": "address" }], "name": "getUserInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "supplyShares", "type": "uint256" }, { "internalType": "uint256", "name": "suppliedInAssets", "type": "uint256" }, { "internalType": "uint256", "name": "borrowShares", "type": "uint256" }, { "internalType": "uint256", "name": "borrowedInAssets", "type": "uint256" }, { "internalType": "uint256", "name": "collateral", "type": "uint256" }], "internalType": "struct MorphoBlueView.PositionInfo", "name": "", "type": "tuple" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "morphoBlue", "outputs": [{ "internalType": "contract IMorphoBlue", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }],
|
|
679
|
+
"networks": {
|
|
680
|
+
"1": {
|
|
681
|
+
"address": "0xE29175a86B60138403a9534A391acaDb19f1E9a6",
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
"FeedRegistry": {
|
|
686
|
+
"abi": [{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "accessController", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "AccessControllerSet", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, { "indexed": true, "internalType": "address", "name": "denomination", "type": "address" }, { "indexed": true, "internalType": "address", "name": "latestAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "previousAggregator", "type": "address" }, { "indexed": false, "internalType": "uint16", "name": "nextPhaseId", "type": "uint16" }, { "indexed": false, "internalType": "address", "name": "sender", "type": "address" }], "name": "FeedConfirmed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, { "indexed": true, "internalType": "address", "name": "denomination", "type": "address" }, { "indexed": true, "internalType": "address", "name": "proposedAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "currentAggregator", "type": "address" }, { "indexed": false, "internalType": "address", "name": "sender", "type": "address" }], "name": "FeedProposed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferRequested", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "confirmFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getAccessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint256", "name": "roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "answer", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getCurrentPhaseId", "outputs": [{ "internalType": "uint16", "name": "currentPhaseId", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getNextRoundId", "outputs": [{ "internalType": "uint80", "name": "nextRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhase", "outputs": [{ "components": [{ "internalType": "uint16", "name": "phaseId", "type": "uint16" }, { "internalType": "uint80", "name": "startingAggregatorRoundId", "type": "uint80" }, { "internalType": "uint80", "name": "endingAggregatorRoundId", "type": "uint80" }], "internalType": "struct FeedRegistryInterface.Phase", "name": "phase", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhaseFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint16", "name": "phaseId", "type": "uint16" }], "name": "getPhaseRange", "outputs": [{ "internalType": "uint80", "name": "startingRoundId", "type": "uint80" }, { "internalType": "uint80", "name": "endingRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getPreviousRoundId", "outputs": [{ "internalType": "uint80", "name": "previousRoundId", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getProposedFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "proposedAggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "getRoundFeed", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint256", "name": "roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "aggregator", "type": "address" }], "name": "isFeedEnabled", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "answer", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "roundId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "proposeFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "uint80", "name": "roundId", "type": "uint80" }], "name": "proposedGetRoundData", "outputs": [{ "internalType": "uint80", "name": "id", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "proposedLatestRoundData", "outputs": [{ "internalType": "uint80", "name": "id", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract AccessControllerInterface", "name": "_accessController", "type": "address" }], "name": "setAccessController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "typeAndVersion", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
687
|
+
"networks": {
|
|
688
|
+
"1": { "address": "0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf" }
|
|
689
|
+
}
|
|
676
690
|
}
|
|
677
691
|
};
|
package/cjs/constants/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export declare const SECONDS_PER_YEAR: number;
|
|
|
2
2
|
export declare const AVG_BLOCK_TIME = 12;
|
|
3
3
|
export declare const BLOCKS_IN_A_YEAR: number;
|
|
4
4
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
5
|
+
export declare const WAD = 1000000000000000000;
|
|
6
|
+
export declare const USD_QUOTE = "0x0000000000000000000000000000000000000348";
|
package/cjs/constants/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZERO_ADDRESS = exports.BLOCKS_IN_A_YEAR = exports.AVG_BLOCK_TIME = exports.SECONDS_PER_YEAR = void 0;
|
|
3
|
+
exports.USD_QUOTE = exports.WAD = exports.ZERO_ADDRESS = exports.BLOCKS_IN_A_YEAR = exports.AVG_BLOCK_TIME = exports.SECONDS_PER_YEAR = void 0;
|
|
4
4
|
exports.SECONDS_PER_YEAR = 365 * 24 * 60 * 60;
|
|
5
5
|
exports.AVG_BLOCK_TIME = 12;
|
|
6
6
|
exports.BLOCKS_IN_A_YEAR = exports.SECONDS_PER_YEAR / exports.AVG_BLOCK_TIME;
|
|
7
7
|
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
8
|
+
exports.WAD = 1e18;
|
|
9
|
+
exports.USD_QUOTE = '0x0000000000000000000000000000000000000348';
|
package/cjs/contracts.d.ts
CHANGED
|
@@ -42,3 +42,5 @@ export declare const ChickenBondsManagerContract: (web3: Web3, network: NetworkN
|
|
|
42
42
|
export declare const ETHPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ETHPriceFeed;
|
|
43
43
|
export declare const COMPPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.COMPPriceFeed;
|
|
44
44
|
export declare const USDCPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.USDCPriceFeed;
|
|
45
|
+
export declare const FeedRegistryContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FeedRegistry;
|
|
46
|
+
export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.MorphoBlueView;
|
package/cjs/contracts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.USDCPriceFeedContract = exports.COMPPriceFeedContract = exports.ETHPriceFeedContract = exports.ChickenBondsManagerContract = exports.ChickenBondsViewContract = exports.McdVatContract = exports.McdJugContract = exports.McdDogContract = exports.McdSpotterContract = exports.McdViewContract = exports.LiquityActivePoolContract = exports.LiquityPriceFeedContract = exports.LiquityTroveManagerContract = exports.LiquityCollSurplusPoolContract = exports.LiquityViewContract = exports.CrvUSDFactoryContract = exports.CrvUSDViewContract = exports.SparkViewContract = exports.SparkIncentiveDataProviderContract = exports.MorphoAaveV2ViewContract = exports.PotContract = exports.ComptrollerContract = exports.CompoundLoanInfoContract = exports.AaveLoanInfoV2Contract = exports.wstETHContract = exports.CompV3ViewContract = exports.BalanceScannerContract = exports.REthContract = exports.CbEthContract = exports.LidoContract = exports.GhoTokenContract = exports.AaveIncentiveDataProviderV3Contract = exports.AaveV3ViewContract = exports.UniMulticallContract = exports.createContractWrapper = exports.getErc20Contract = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
6
|
+
exports.MorphoBlueViewContract = exports.FeedRegistryContract = exports.USDCPriceFeedContract = exports.COMPPriceFeedContract = exports.ETHPriceFeedContract = exports.ChickenBondsManagerContract = exports.ChickenBondsViewContract = exports.McdVatContract = exports.McdJugContract = exports.McdDogContract = exports.McdSpotterContract = exports.McdViewContract = exports.LiquityActivePoolContract = exports.LiquityPriceFeedContract = exports.LiquityTroveManagerContract = exports.LiquityCollSurplusPoolContract = exports.LiquityViewContract = exports.CrvUSDFactoryContract = exports.CrvUSDViewContract = exports.SparkViewContract = exports.SparkIncentiveDataProviderContract = exports.MorphoAaveV2ViewContract = exports.PotContract = exports.ComptrollerContract = exports.CompoundLoanInfoContract = exports.AaveLoanInfoV2Contract = exports.wstETHContract = exports.CompV3ViewContract = exports.BalanceScannerContract = exports.REthContract = exports.CbEthContract = exports.LidoContract = exports.GhoTokenContract = exports.AaveIncentiveDataProviderV3Contract = exports.AaveV3ViewContract = exports.UniMulticallContract = exports.createContractWrapper = exports.getErc20Contract = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
7
7
|
const contracts_1 = __importDefault(require("./config/contracts"));
|
|
8
8
|
const contractConfig = contracts_1.default;
|
|
9
9
|
const getConfigContractAddress = (name, network, block) => {
|
|
@@ -90,3 +90,5 @@ exports.ChickenBondsManagerContract = createContractFromConfigFunc('ChickenBonds
|
|
|
90
90
|
exports.ETHPriceFeedContract = createContractFromConfigFunc('ETHPriceFeed');
|
|
91
91
|
exports.COMPPriceFeedContract = createContractFromConfigFunc('COMPPriceFeed');
|
|
92
92
|
exports.USDCPriceFeedContract = createContractFromConfigFunc('USDCPriceFeed');
|
|
93
|
+
exports.FeedRegistryContract = createContractFromConfigFunc('FeedRegistry');
|
|
94
|
+
exports.MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueView');
|
package/cjs/helpers/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export * as sparkHelpers from './sparkHelpers';
|
|
|
4
4
|
export * as curveUsdHelpers from './curveUsdHelpers';
|
|
5
5
|
export * as makerHelpers from './makerHelpers';
|
|
6
6
|
export * as chickenBondsHelpers from './chickenBondsHelpers';
|
|
7
|
+
export * as morphoBlueHelpers from './morphoBlueHelpers';
|
package/cjs/helpers/index.js
CHANGED
|
@@ -23,10 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.chickenBondsHelpers = exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
26
|
+
exports.morphoBlueHelpers = exports.chickenBondsHelpers = exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
27
27
|
exports.aaveHelpers = __importStar(require("./aaveHelpers"));
|
|
28
28
|
exports.compoundHelpers = __importStar(require("./compoundHelpers"));
|
|
29
29
|
exports.sparkHelpers = __importStar(require("./sparkHelpers"));
|
|
30
30
|
exports.curveUsdHelpers = __importStar(require("./curveUsdHelpers"));
|
|
31
31
|
exports.makerHelpers = __importStar(require("./makerHelpers"));
|
|
32
32
|
exports.chickenBondsHelpers = __importStar(require("./chickenBondsHelpers"));
|
|
33
|
+
exports.morphoBlueHelpers = __importStar(require("./morphoBlueHelpers"));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MMUsedAssets } from '../../types/common';
|
|
2
|
+
import { MorphoBlueAggregatedPositionData, MorphoBlueAssetsData } from '../../types';
|
|
3
|
+
export declare const getMorphoBlueAggregatedPositionData: ({ usedAssets, assetsData, lltv }: {
|
|
4
|
+
usedAssets: MMUsedAssets;
|
|
5
|
+
assetsData: MorphoBlueAssetsData;
|
|
6
|
+
lltv: string;
|
|
7
|
+
}) => MorphoBlueAggregatedPositionData;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMorphoBlueAggregatedPositionData = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const moneymarket_1 = require("../../moneymarket");
|
|
9
|
+
const staking_1 = require("../../staking");
|
|
10
|
+
const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, lltv }) => {
|
|
11
|
+
const payload = {};
|
|
12
|
+
payload.suppliedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
|
|
13
|
+
payload.suppliedCollateralUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
|
|
14
|
+
payload.borrowedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
|
|
15
|
+
payload.borrowLimitUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd }) => {
|
|
16
|
+
const suppliedUsdAmount = suppliedUsd;
|
|
17
|
+
return new decimal_js_1.default(suppliedUsdAmount).mul(lltv);
|
|
18
|
+
});
|
|
19
|
+
payload.liquidationLimitUsd = payload.borrowLimitUsd;
|
|
20
|
+
const leftToBorrowUsd = new decimal_js_1.default(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
21
|
+
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
22
|
+
const { netApy, incentiveUsd, totalInterestUsd } = (0, staking_1.calculateNetApy)(usedAssets, assetsData);
|
|
23
|
+
payload.netApy = netApy;
|
|
24
|
+
payload.incentiveUsd = incentiveUsd;
|
|
25
|
+
payload.totalInterestUsd = totalInterestUsd;
|
|
26
|
+
payload.ltv = new decimal_js_1.default(payload.borrowedUsd).div(payload.suppliedCollateralUsd).toString();
|
|
27
|
+
const { leveragedType, leveragedAsset } = (0, moneymarket_1.isLeveragedPos)(usedAssets);
|
|
28
|
+
payload.leveragedType = leveragedType;
|
|
29
|
+
if (leveragedType !== '') {
|
|
30
|
+
payload.leveragedAsset = leveragedAsset;
|
|
31
|
+
let assetPrice = assetsData[leveragedAsset].price;
|
|
32
|
+
if (leveragedType === 'lsd-leverage') {
|
|
33
|
+
// Treat ETH like a stablecoin in a long stETH position
|
|
34
|
+
payload.leveragedLsdAssetRatio = new decimal_js_1.default(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
|
|
35
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(assetsData.ETH.price).toString();
|
|
36
|
+
}
|
|
37
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
38
|
+
}
|
|
39
|
+
return payload;
|
|
40
|
+
};
|
|
41
|
+
exports.getMorphoBlueAggregatedPositionData = getMorphoBlueAggregatedPositionData;
|
package/cjs/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ import * as markets from './markets';
|
|
|
15
15
|
import * as helpers from './helpers';
|
|
16
16
|
import * as chickenBonds from './chickenBonds';
|
|
17
17
|
import * as exchange from './exchange';
|
|
18
|
+
import * as morphoBlue from './morphoBlue';
|
|
18
19
|
export * from './types';
|
|
19
|
-
export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, };
|
|
20
|
+
export { aaveV2, aaveV3, morphoAaveV2, morphoAaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, maker, chickenBonds, exchange, staking, multicall, moneymarket, markets, helpers, morphoBlue, };
|
package/cjs/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.helpers = exports.markets = exports.moneymarket = exports.multicall = exports.staking = exports.exchange = exports.chickenBonds = exports.maker = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.morphoAaveV3 = exports.morphoAaveV2 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
29
|
+
exports.morphoBlue = exports.helpers = exports.markets = exports.moneymarket = exports.multicall = exports.staking = exports.exchange = exports.chickenBonds = exports.maker = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.morphoAaveV3 = exports.morphoAaveV2 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
30
30
|
const aaveV3 = __importStar(require("./aaveV3"));
|
|
31
31
|
exports.aaveV3 = aaveV3;
|
|
32
32
|
const morphoAaveV3 = __importStar(require("./morphoAaveV3"));
|
|
@@ -61,4 +61,6 @@ const chickenBonds = __importStar(require("./chickenBonds"));
|
|
|
61
61
|
exports.chickenBonds = chickenBonds;
|
|
62
62
|
const exchange = __importStar(require("./exchange"));
|
|
63
63
|
exports.exchange = exchange;
|
|
64
|
+
const morphoBlue = __importStar(require("./morphoBlue"));
|
|
65
|
+
exports.morphoBlue = morphoBlue;
|
|
64
66
|
__exportStar(require("./types"), exports);
|
package/cjs/markets/index.d.ts
CHANGED
package/cjs/markets/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CrvUsdMarkets = exports.SparkMarkets = exports.CompoundMarkets = exports.AaveMarkets = void 0;
|
|
3
|
+
exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.CompoundMarkets = exports.AaveMarkets = void 0;
|
|
4
4
|
var aave_1 = require("./aave");
|
|
5
5
|
Object.defineProperty(exports, "AaveMarkets", { enumerable: true, get: function () { return aave_1.AaveMarkets; } });
|
|
6
6
|
var compound_1 = require("./compound");
|
|
@@ -9,3 +9,5 @@ var spark_1 = require("./spark");
|
|
|
9
9
|
Object.defineProperty(exports, "SparkMarkets", { enumerable: true, get: function () { return spark_1.SparkMarkets; } });
|
|
10
10
|
var curveUsd_1 = require("./curveUsd");
|
|
11
11
|
Object.defineProperty(exports, "CrvUsdMarkets", { enumerable: true, get: function () { return curveUsd_1.CrvUsdMarkets; } });
|
|
12
|
+
var morphoBlue_1 = require("./morphoBlue");
|
|
13
|
+
Object.defineProperty(exports, "MorphoBlueMarkets", { enumerable: true, get: function () { return morphoBlue_1.MorphoBlueMarkets; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MorphoBlueMarketData } from '../../types';
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
export declare const MORPHO_BLUE_WSTETH_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
4
|
+
export declare const MorphoBlueMarkets: (networkId: NetworkNumber) => {
|
|
5
|
+
readonly morphobluewstetheth: MorphoBlueMarketData;
|
|
6
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MorphoBlueMarkets = exports.MORPHO_BLUE_WSTETH_ETH = void 0;
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
const common_1 = require("../../types/common");
|
|
6
|
+
const MORPHO_BLUE_WSTETH_ETH = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
7
|
+
chainIds: [1],
|
|
8
|
+
label: 'Morpho Blue',
|
|
9
|
+
shortLabel: 'wstETH/ETH',
|
|
10
|
+
value: types_1.MorphoBlueVersions.MorphoBlueWstEthEth,
|
|
11
|
+
url: 'default',
|
|
12
|
+
loanToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
13
|
+
collateralToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
14
|
+
oracle: '0x2a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
15
|
+
irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
16
|
+
lltv: 0.945,
|
|
17
|
+
// icon: SvgAdapter(protocolIcons.spark),
|
|
18
|
+
protocolName: 'morpho-blue',
|
|
19
|
+
});
|
|
20
|
+
exports.MORPHO_BLUE_WSTETH_ETH = MORPHO_BLUE_WSTETH_ETH;
|
|
21
|
+
const MorphoBlueMarkets = (networkId) => ({
|
|
22
|
+
[types_1.MorphoBlueVersions.MorphoBlueWstEthEth]: (0, exports.MORPHO_BLUE_WSTETH_ETH)(networkId),
|
|
23
|
+
});
|
|
24
|
+
exports.MorphoBlueMarkets = MorphoBlueMarkets;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Web3 from 'web3';
|
|
2
|
+
import { NetworkNumber } from '../types/common';
|
|
3
|
+
import { MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBluePositionData } from '../types';
|
|
4
|
+
export declare function getMorphoBlueMarketData(web3: Web3, network: NetworkNumber, selectedMarket: MorphoBlueMarketData, mainnetWeb3: Web3): Promise<MorphoBlueMarketInfo>;
|
|
5
|
+
export declare function getMorphoBlueAccountData(web3: Web3, network: NetworkNumber, account: string, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
|