@defisaver/positions-sdk 0.0.201-fluid-dev-4 → 0.0.201-fluid-dev-6
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/config/contracts.d.ts +15 -0
- package/cjs/config/contracts.js +7 -2
- package/cjs/fluid/index.d.ts +14 -0
- package/cjs/fluid/index.js +32 -5
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/fluid/index.d.ts +0 -6
- package/cjs/markets/fluid/index.js +57 -62
- package/cjs/services/priceService.d.ts +1 -0
- package/cjs/services/priceService.js +29 -1
- package/cjs/types/fluid.d.ts +1 -9
- package/cjs/types/fluid.js +0 -8
- package/esm/config/contracts.d.ts +15 -0
- package/esm/config/contracts.js +7 -2
- package/esm/fluid/index.d.ts +14 -0
- package/esm/fluid/index.js +32 -6
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/fluid/index.d.ts +0 -6
- package/esm/markets/fluid/index.js +56 -57
- package/esm/services/priceService.d.ts +1 -0
- package/esm/services/priceService.js +27 -0
- package/esm/types/fluid.d.ts +1 -9
- package/esm/types/fluid.js +0 -8
- package/package.json +51 -51
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +625 -625
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +220 -220
- package/src/compoundV3/index.ts +291 -291
- package/src/config/contracts.js +1122 -1117
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +134 -134
- package/src/curveUsd/index.ts +229 -229
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/fluid/index.ts +329 -298
- package/src/helpers/aaveHelpers/index.ts +198 -198
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +246 -246
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +232 -232
- package/src/helpers/fluidHelpers/index.ts +53 -53
- package/src/helpers/index.ts +11 -11
- package/src/helpers/liquityV2Helpers/index.ts +79 -79
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +365 -365
- package/src/helpers/sparkHelpers/index.ts +150 -150
- package/src/index.ts +52 -52
- package/src/liquity/index.ts +116 -116
- package/src/liquityV2/index.ts +227 -227
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +44 -44
- package/src/markets/compound/index.ts +213 -213
- package/src/markets/compound/marketsAssets.ts +82 -82
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2002 -2005
- package/src/markets/index.ts +27 -27
- package/src/markets/liquityV2/index.ts +43 -43
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +631 -631
- package/src/morphoBlue/index.ts +202 -202
- package/src/multicall/index.ts +33 -33
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +91 -62
- package/src/services/utils.ts +59 -59
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +461 -461
- package/src/staking/staking.ts +220 -220
- package/src/types/aave.ts +271 -271
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +131 -131
- package/src/types/curveUsd.ts +118 -118
- package/src/types/euler.ts +171 -171
- package/src/types/fluid.ts +263 -271
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +118 -118
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +192 -192
- package/src/types/spark.ts +131 -131
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
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)
|
|
64
|
-
|
|
65
|
-
## Testing
|
|
66
|
-
|
|
67
|
-
`npm run test` - Run all tests
|
|
68
|
-
|
|
69
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
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)
|
|
64
|
+
|
|
65
|
+
## Testing
|
|
66
|
+
|
|
67
|
+
`npm run test` - Run all tests
|
|
68
|
+
|
|
69
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
@@ -6715,6 +6715,12 @@ export namespace ETHPriceFeed {
|
|
|
6715
6715
|
"1": {
|
|
6716
6716
|
address: string;
|
|
6717
6717
|
};
|
|
6718
|
+
"8453": {
|
|
6719
|
+
address: string;
|
|
6720
|
+
};
|
|
6721
|
+
"42161": {
|
|
6722
|
+
address: string;
|
|
6723
|
+
};
|
|
6718
6724
|
};
|
|
6719
6725
|
export { networks_73 as networks };
|
|
6720
6726
|
}
|
|
@@ -6799,6 +6805,12 @@ export namespace WstETHPriceFeed {
|
|
|
6799
6805
|
"1": {
|
|
6800
6806
|
address: string;
|
|
6801
6807
|
};
|
|
6808
|
+
"8453": {
|
|
6809
|
+
address: string;
|
|
6810
|
+
};
|
|
6811
|
+
"42161": {
|
|
6812
|
+
address: string;
|
|
6813
|
+
};
|
|
6802
6814
|
};
|
|
6803
6815
|
export { networks_75 as networks };
|
|
6804
6816
|
}
|
|
@@ -7283,6 +7295,9 @@ export namespace DFSFeedRegistry {
|
|
|
7283
7295
|
"8453": {
|
|
7284
7296
|
address: string;
|
|
7285
7297
|
};
|
|
7298
|
+
"42161": {
|
|
7299
|
+
address: string;
|
|
7300
|
+
};
|
|
7286
7301
|
};
|
|
7287
7302
|
export { networks_78 as networks };
|
|
7288
7303
|
}
|
package/cjs/config/contracts.js
CHANGED
|
@@ -1015,7 +1015,9 @@ module.exports = {
|
|
|
1015
1015
|
"ETHPriceFeed": {
|
|
1016
1016
|
"abi": [{ "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }, { "internalType": "address", "name": "_accessController", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "int256", "name": "current", "type": "int256" }, { "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "updatedAt", "type": "uint256" }], "name": "AnswerUpdated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "startedBy", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "startedAt", "type": "uint256" }], "name": "NewRound", "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": [], "name": "accessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "aggregator", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "confirmAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "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": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "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": [], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address payable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "name": "phaseAggregators", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "phaseId", "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "proposeAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proposedAggregator", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "proposedGetRoundData", "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": [], "name": "proposedLatestRoundData", "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": "_accessController", "type": "address" }], "name": "setController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
1017
1017
|
"networks": {
|
|
1018
|
-
"1": { "address": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" }
|
|
1018
|
+
"1": { "address": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" },
|
|
1019
|
+
"8453": { "address": "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70" },
|
|
1020
|
+
"42161": { "address": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612" }
|
|
1019
1021
|
},
|
|
1020
1022
|
},
|
|
1021
1023
|
"USDCPriceFeed": {
|
|
@@ -1027,7 +1029,9 @@ module.exports = {
|
|
|
1027
1029
|
"WstETHPriceFeed": {
|
|
1028
1030
|
"abi": [{ "inputs": [{ "internalType": "address", "name": "stETHtoETHPriceFeed_", "type": "address" }, { "internalType": "address", "name": "wstETH_", "type": "address" }, { "internalType": "uint8", "name": "decimals_", "type": "uint8" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "BadDecimals", "type": "error" }, { "inputs": [], "name": "InvalidInt256", "type": "error" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "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": [], "name": "stETHToETHPriceFeedDecimals", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "stETHtoETHPriceFeed", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "wstETH", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "wstETHScale", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }],
|
|
1029
1031
|
"networks": {
|
|
1030
|
-
"1": { "address": "0x4F67e4d9BD67eFa28236013288737D39AeF48e79" }
|
|
1032
|
+
"1": { "address": "0x4F67e4d9BD67eFa28236013288737D39AeF48e79" },
|
|
1033
|
+
"8453": { "address": "0x43a5C292A453A3bF3606fa856197f09D7B74251a" },
|
|
1034
|
+
"42161": { "address": "0xb523AE262D20A936BC152e6023996e46FDC2A95D" }
|
|
1031
1035
|
}
|
|
1032
1036
|
},
|
|
1033
1037
|
"MorphoBlueView": {
|
|
@@ -1073,6 +1077,7 @@ module.exports = {
|
|
|
1073
1077
|
"abi": [{ "inputs": [], "name": "NonContractCall", "type": "error" }, { "inputs": [], "name": "SenderNotAdmin", "type": "error" }, { "inputs": [], "name": "SenderNotOwner", "type": "error" }, { "inputs": [], "name": "adminVault", "outputs": [{ "internalType": "contract AdminVault", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }], "name": "aggregators", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getFeed", "outputs": [{ "internalType": "address", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "kill", "outputs": [], "stateMutability": "nonpayable", "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" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "setFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "bases", "type": "address[]" }, { "internalType": "address[]", "name": "quotes", "type": "address[]" }, { "internalType": "address[]", "name": "aggregator", "type": "address[]" }], "name": "setFeeds", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_token", "type": "address" }, { "internalType": "address", "name": "_receiver", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "withdrawStuckFunds", "outputs": [], "stateMutability": "nonpayable", "type": "function" }],
|
|
1074
1078
|
"networks": {
|
|
1075
1079
|
"8453": { "address": "0x7dFF34190d0307fC234fc7E8C152C9715083eB02" },
|
|
1080
|
+
"42161": { "address": "0x158E27De8B5E5bC3FA1C6D5b365a291c54f6b0Fd" }
|
|
1076
1081
|
}
|
|
1077
1082
|
},
|
|
1078
1083
|
"LlamaLendView": {
|
package/cjs/fluid/index.d.ts
CHANGED
|
@@ -44,4 +44,18 @@ export declare const getFluidTokenData: (web3: Web3, network: NetworkNumber, tok
|
|
|
44
44
|
totalDeposited: string;
|
|
45
45
|
withdrawable: string;
|
|
46
46
|
apy: string;
|
|
47
|
+
depositRate: string;
|
|
48
|
+
withdrawRate: string;
|
|
49
|
+
}>;
|
|
50
|
+
export declare const getFluidDepositData: (web3: Web3, network: NetworkNumber, token: string, address: EthAddress) => Promise<{
|
|
51
|
+
fTokenAddress: any;
|
|
52
|
+
fTokenSymbol: string;
|
|
53
|
+
decimals: string;
|
|
54
|
+
totalDeposited: string;
|
|
55
|
+
withdrawable: string;
|
|
56
|
+
apy: string;
|
|
57
|
+
depositRate: string;
|
|
58
|
+
withdrawRate: string;
|
|
59
|
+
deposited: string;
|
|
60
|
+
depositedShares: string;
|
|
47
61
|
}>;
|
package/cjs/fluid/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getFluidTokenData = exports.getAllFluidMarketDataChunked = exports.getFluidPositionWithMarket = exports.getFluidPosition = exports.getFluidVaultIdsForUser = exports.getFluidMarketData = exports.EMPTY_FLUID_DATA = exports.EMPTY_USED_ASSET = void 0;
|
|
15
|
+
exports.getFluidDepositData = exports.getFluidTokenData = exports.getAllFluidMarketDataChunked = exports.getFluidPositionWithMarket = exports.getFluidPosition = exports.getFluidVaultIdsForUser = exports.getFluidMarketData = exports.EMPTY_FLUID_DATA = exports.EMPTY_USED_ASSET = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const common_1 = require("../types/common");
|
|
@@ -44,8 +44,8 @@ const parseVaultType = (vaultType) => {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0);
|
|
48
|
-
const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0);
|
|
47
|
+
const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
48
|
+
const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
49
49
|
const supplyRate = new decimal_js_1.default(data.supplyRateVault).div(100).toString();
|
|
50
50
|
const borrowRate = new decimal_js_1.default(data.borrowRateVault).div(100).toString();
|
|
51
51
|
const oracleScaleFactor = new decimal_js_1.default(27).add(debtAsset.decimals).sub(collAsset.decimals).toString();
|
|
@@ -57,7 +57,7 @@ const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void
|
|
|
57
57
|
let loanTokenPrice;
|
|
58
58
|
if (debtAsset.symbol === 'wstETH') {
|
|
59
59
|
// need to handle wstETH for l2s inside getWstETHPrice
|
|
60
|
-
loanTokenPrice = yield (0, priceService_1.
|
|
60
|
+
loanTokenPrice = yield (0, priceService_1.getWstETHPriceFluid)(web3, network);
|
|
61
61
|
}
|
|
62
62
|
else if (isMainnet) {
|
|
63
63
|
const feedRegistryContract = (0, contracts_1.FeedRegistryContract)(web3, common_1.NetworkNumber.Eth);
|
|
@@ -222,8 +222,10 @@ const getFluidTokenData = (web3, network, token) => __awaiter(void 0, void 0, vo
|
|
|
222
222
|
const fTokenAddress = (0, markets_1.getFTokenAddress)(token, network);
|
|
223
223
|
const data = yield view.methods.getFTokenData(fTokenAddress).call();
|
|
224
224
|
const supplyRate = new decimal_js_1.default(data.supplyRate).div(100).toString();
|
|
225
|
+
const rewardsRate = new decimal_js_1.default(data.rewardsRate).div(1e12).toString();
|
|
225
226
|
const decimals = data.decimals;
|
|
226
|
-
const
|
|
227
|
+
const depositRate = new decimal_js_1.default((0, utils_1.getEthAmountForDecimals)(data.convertToShares, decimals)).toString();
|
|
228
|
+
const withdrawRate = new decimal_js_1.default((0, utils_1.getEthAmountForDecimals)(data.convertToAssets, decimals)).toString();
|
|
227
229
|
return {
|
|
228
230
|
fTokenAddress,
|
|
229
231
|
fTokenSymbol: data.symbol,
|
|
@@ -231,6 +233,31 @@ const getFluidTokenData = (web3, network, token) => __awaiter(void 0, void 0, vo
|
|
|
231
233
|
totalDeposited: (0, utils_1.getEthAmountForDecimals)(data.totalAssets, decimals),
|
|
232
234
|
withdrawable: (0, utils_1.getEthAmountForDecimals)(data.withdrawable, decimals),
|
|
233
235
|
apy: new decimal_js_1.default(supplyRate).add(rewardsRate).toString(),
|
|
236
|
+
depositRate,
|
|
237
|
+
withdrawRate,
|
|
234
238
|
};
|
|
235
239
|
});
|
|
236
240
|
exports.getFluidTokenData = getFluidTokenData;
|
|
241
|
+
const getFluidDepositData = (web3, network, token, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
242
|
+
const view = (0, contracts_1.FluidViewContract)(web3, network);
|
|
243
|
+
const fTokenAddress = (0, markets_1.getFTokenAddress)(token, network);
|
|
244
|
+
const { fTokenData, userPosition } = yield view.methods.getUserEarnPositionWithFToken(fTokenAddress, address).call();
|
|
245
|
+
const supplyRate = new decimal_js_1.default(fTokenData.supplyRate).div(100).toString();
|
|
246
|
+
const rewardsRate = new decimal_js_1.default(fTokenData.rewardsRate).div(1e12).toString();
|
|
247
|
+
const decimals = fTokenData.decimals;
|
|
248
|
+
const depositRate = new decimal_js_1.default((0, utils_1.getEthAmountForDecimals)(fTokenData.convertToShares, decimals)).toString();
|
|
249
|
+
const withdrawRate = new decimal_js_1.default((0, utils_1.getEthAmountForDecimals)(fTokenData.convertToAssets, decimals)).toString();
|
|
250
|
+
return {
|
|
251
|
+
fTokenAddress,
|
|
252
|
+
fTokenSymbol: fTokenData.symbol,
|
|
253
|
+
decimals,
|
|
254
|
+
totalDeposited: (0, utils_1.getEthAmountForDecimals)(fTokenData.totalAssets, decimals),
|
|
255
|
+
withdrawable: (0, utils_1.getEthAmountForDecimals)(fTokenData.withdrawable, decimals),
|
|
256
|
+
apy: new decimal_js_1.default(supplyRate).add(rewardsRate).toString(),
|
|
257
|
+
depositRate,
|
|
258
|
+
withdrawRate,
|
|
259
|
+
deposited: (0, utils_1.getEthAmountForDecimals)(userPosition.underlyingAssets, decimals),
|
|
260
|
+
depositedShares: (0, utils_1.getEthAmountForDecimals)(userPosition.fTokenShares, decimals),
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
exports.getFluidDepositData = getFluidDepositData;
|
|
@@ -115,73 +115,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
|
|
|
115
115
|
});
|
|
116
116
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
117
117
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
118
|
-
const MARKET_QUERY = `
|
|
119
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
120
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
121
|
-
reallocatableLiquidityAssets
|
|
122
|
-
targetBorrowUtilization
|
|
123
|
-
loanAsset {
|
|
124
|
-
address
|
|
125
|
-
decimals
|
|
126
|
-
priceUsd
|
|
127
|
-
}
|
|
128
|
-
state {
|
|
129
|
-
liquidityAssets
|
|
130
|
-
borrowAssets
|
|
131
|
-
supplyAssets
|
|
132
|
-
}
|
|
133
|
-
publicAllocatorSharedLiquidity {
|
|
134
|
-
assets
|
|
135
|
-
vault {
|
|
136
|
-
address
|
|
137
|
-
name
|
|
138
|
-
}
|
|
139
|
-
allocationMarket {
|
|
140
|
-
uniqueKey
|
|
141
|
-
loanAsset {
|
|
142
|
-
address
|
|
143
|
-
}
|
|
144
|
-
collateralAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
irmAddress
|
|
148
|
-
oracle {
|
|
149
|
-
address
|
|
150
|
-
}
|
|
151
|
-
lltv
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
loanAsset {
|
|
155
|
-
address
|
|
156
|
-
}
|
|
157
|
-
collateralAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
oracle {
|
|
161
|
-
address
|
|
162
|
-
}
|
|
163
|
-
irmAddress
|
|
164
|
-
lltv
|
|
165
|
-
}
|
|
166
|
-
}
|
|
118
|
+
const MARKET_QUERY = `
|
|
119
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
120
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
121
|
+
reallocatableLiquidityAssets
|
|
122
|
+
targetBorrowUtilization
|
|
123
|
+
loanAsset {
|
|
124
|
+
address
|
|
125
|
+
decimals
|
|
126
|
+
priceUsd
|
|
127
|
+
}
|
|
128
|
+
state {
|
|
129
|
+
liquidityAssets
|
|
130
|
+
borrowAssets
|
|
131
|
+
supplyAssets
|
|
132
|
+
}
|
|
133
|
+
publicAllocatorSharedLiquidity {
|
|
134
|
+
assets
|
|
135
|
+
vault {
|
|
136
|
+
address
|
|
137
|
+
name
|
|
138
|
+
}
|
|
139
|
+
allocationMarket {
|
|
140
|
+
uniqueKey
|
|
141
|
+
loanAsset {
|
|
142
|
+
address
|
|
143
|
+
}
|
|
144
|
+
collateralAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
irmAddress
|
|
148
|
+
oracle {
|
|
149
|
+
address
|
|
150
|
+
}
|
|
151
|
+
lltv
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
loanAsset {
|
|
155
|
+
address
|
|
156
|
+
}
|
|
157
|
+
collateralAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
oracle {
|
|
161
|
+
address
|
|
162
|
+
}
|
|
163
|
+
irmAddress
|
|
164
|
+
lltv
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
167
|
`;
|
|
168
|
-
const REWARDS_QUERY = `
|
|
169
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
170
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
171
|
-
uniqueKey
|
|
172
|
-
state {
|
|
173
|
-
rewards {
|
|
174
|
-
amountPerSuppliedToken
|
|
175
|
-
supplyApr
|
|
176
|
-
amountPerBorrowedToken
|
|
177
|
-
borrowApr
|
|
178
|
-
asset {
|
|
179
|
-
address
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
168
|
+
const REWARDS_QUERY = `
|
|
169
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
170
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
171
|
+
uniqueKey
|
|
172
|
+
state {
|
|
173
|
+
rewards {
|
|
174
|
+
amountPerSuppliedToken
|
|
175
|
+
supplyApr
|
|
176
|
+
amountPerBorrowedToken
|
|
177
|
+
borrowApr
|
|
178
|
+
asset {
|
|
179
|
+
address
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
185
|
`;
|
|
186
186
|
/**
|
|
187
187
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -94,9 +94,6 @@ export declare const CBBTC_ETH_13_BASE: (networkId?: NetworkNumber) => FluidMark
|
|
|
94
94
|
export declare const ETH_CBBTC_14_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
95
95
|
export declare const WEETH_CBBTC_15_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
96
96
|
export declare const WSTETH_CBBTC_16_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
97
|
-
export declare const ETH_SUSDS_17_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
98
|
-
export declare const WSTETH_SUSDS_18_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
99
|
-
export declare const CBBTC_SUSDS_19_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
|
|
100
97
|
export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
101
98
|
ETH_USDC_1: FluidMarketInfo;
|
|
102
99
|
ETH_USDT_2: FluidMarketInfo;
|
|
@@ -192,9 +189,6 @@ export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
|
192
189
|
ETH_CBBTC_14_BASE: FluidMarketInfo;
|
|
193
190
|
WEETH_CBBTC_15_BASE: FluidMarketInfo;
|
|
194
191
|
WSTETH_CBBTC_16_BASE: FluidMarketInfo;
|
|
195
|
-
ETH_SUSDS_17_BASE: FluidMarketInfo;
|
|
196
|
-
WSTETH_SUSDS_18_BASE: FluidMarketInfo;
|
|
197
|
-
CBBTC_SUSDS_19_BASE: FluidMarketInfo;
|
|
198
192
|
};
|
|
199
193
|
export declare const getFluidVersionsDataForNetwork: (network: NetworkNumber) => FluidMarketInfo[];
|
|
200
194
|
export declare const getFluidMarketInfoById: (vaultId: number, network?: NetworkNumber) => FluidMarketInfo | undefined;
|