@defisaver/positions-sdk 0.0.69 → 0.0.71
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/aaveV3/index.js +1 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/markets/llamaLend/index.js +1 -1
- package/cjs/markets/morphoBlue/index.d.ts +24 -2
- package/cjs/markets/morphoBlue/index.js +221 -40
- package/cjs/morphoBlue/index.js +2 -1
- package/cjs/staking/staking.js +11 -4
- package/cjs/types/llamaLend.js +2 -2
- package/cjs/types/morphoBlue.d.ts +18 -2
- package/cjs/types/morphoBlue.js +19 -2
- package/esm/aaveV3/index.js +1 -1
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/markets/llamaLend/index.js +1 -1
- package/esm/markets/morphoBlue/index.d.ts +24 -2
- package/esm/markets/morphoBlue/index.js +209 -39
- package/esm/morphoBlue/index.js +2 -1
- package/esm/staking/staking.js +11 -4
- package/esm/types/llamaLend.js +2 -2
- package/esm/types/morphoBlue.d.ts +18 -2
- package/esm/types/morphoBlue.js +18 -1
- package/package.json +41 -41
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +562 -562
- 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 +273 -273
- package/src/config/contracts.js +845 -845
- package/src/constants/index.ts +5 -5
- package/src/contracts.ts +128 -128
- package/src/curveUsd/index.ts +229 -229
- 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 +40 -40
- package/src/helpers/index.ts +7 -7
- package/src/helpers/llamaLendHelpers/index.ts +45 -45
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +56 -56
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +46 -46
- package/src/liquity/index.ts +116 -116
- package/src/llamaLend/index.ts +268 -268
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +25 -25
- package/src/markets/compound/index.ts +142 -142
- package/src/markets/compound/marketsAssets.ts +50 -50
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +5 -5
- package/src/markets/llamaLend/contractAddresses.ts +95 -95
- package/src/markets/llamaLend/index.ts +150 -150
- package/src/markets/morphoBlue/index.ts +431 -262
- 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 +256 -256
- package/src/morphoAaveV3/index.ts +619 -619
- package/src/morphoBlue/index.ts +178 -177
- 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 +51 -51
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +422 -422
- package/src/staking/staking.ts +198 -198
- package/src/types/aave.ts +256 -256
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +128 -128
- package/src/types/curveUsd.ts +118 -118
- package/src/types/index.ts +8 -8
- package/src/types/liquity.ts +30 -30
- package/src/types/llamaLend.ts +143 -143
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +125 -107
- package/src/types/spark.ts +106 -106
- package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
- package/.yarn/releases/yarn-1.22.1.js +0 -147386
- package/.yarnrc.yml +0 -1
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)
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
140
140
|
if (nativeAsset && facilitatorsList && discountRate && minDiscountTokenBalance && minGhoBalanceForDiscount && ghoDiscountedPerDiscountToken) {
|
|
141
141
|
const facilitatorBucket = yield ghoContract.methods.getFacilitatorBucket(facilitatorsList[0]).call();
|
|
142
142
|
const availableFacilitatorCap = (0, tokens_1.assetAmountInEth)(new decimal_js_1.default(facilitatorBucket[0]).sub(facilitatorBucket[1]).toString(), 'GHO');
|
|
143
|
-
borrowCap = decimal_js_1.default.min(borrowCap,
|
|
143
|
+
borrowCap = decimal_js_1.default.min(borrowCap, (0, tokens_1.assetAmountInEth)(facilitatorBucket[0], 'GHO')).toString();
|
|
144
144
|
discountRateOnBorrow = (0, exports.aaveV3CalculateDiscountRate)(tokenMarket.totalBorrow.toString(), '3160881469228662060510133', // stkAAVE total supply
|
|
145
145
|
discountRate, minDiscountTokenBalance, minGhoBalanceForDiscount, ghoDiscountedPerDiscountToken);
|
|
146
146
|
}
|
|
@@ -7,7 +7,7 @@ exports.morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WBTC',
|
|
|
7
7
|
exports.morphoAaveV3AssetEthMarket = [
|
|
8
8
|
'ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT',
|
|
9
9
|
];
|
|
10
|
-
exports.aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH'];
|
|
10
|
+
exports.aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH'];
|
|
11
11
|
exports.aaveV3AssetsDefaultMarketOpt = [
|
|
12
12
|
'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
|
|
13
13
|
];
|
|
@@ -44,7 +44,7 @@ const getLlamaLendMarketData = (market, network = 1) => (0, exports.LlamaLendMar
|
|
|
44
44
|
exports.getLlamaLendMarketData = getLlamaLendMarketData;
|
|
45
45
|
const getLlamaLendMarketFromControllerAddress = (controllerAddress, network) => {
|
|
46
46
|
const markets = (0, exports.LlamaLendMarkets)(network);
|
|
47
|
-
const market = Object.values(markets).find((
|
|
47
|
+
const market = Object.values(markets).find((tempMarket) => tempMarket.controllerAddress === controllerAddress);
|
|
48
48
|
if (!market)
|
|
49
49
|
throw new Error('Market not found');
|
|
50
50
|
return market;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { MorphoBlueMarketData } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const MORPHO_BLUE_WSTETH_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
4
3
|
export declare const MORPHO_BLUE_WSTETH_USDC: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
5
4
|
export declare const MORPHO_BLUE_SDAI_USDC: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
6
5
|
export declare const MORPHO_BLUE_WBTC_USDC: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
7
6
|
export declare const MORPHO_BLUE_ETH_USDC: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
8
7
|
export declare const MORPHO_BLUE_WBTC_USDT: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
8
|
+
export declare const MORPHO_BLUE_WBTC_PYUSD: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
9
|
+
export declare const MORPHO_BLUE_WBTC_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
9
10
|
export declare const MORPHO_BLUE_WSTETH_USDT: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
11
|
+
export declare const MORPHO_BLUE_WSTETH_USDA_EXCHANGE_RATE: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
12
|
+
export declare const MORPHO_BLUE_WSTETH_PYUSD: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
13
|
+
export declare const MORPHO_BLUE_WEETH_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
14
|
+
export declare const MORPHO_BLUE_USDE_USDT: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
15
|
+
export declare const MORPHO_BLUE_SUSDE_USDT: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
16
|
+
export declare const MORPHO_BLUE_SDAI_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
17
|
+
export declare const MORPHO_BLUE_EZETH_ETH: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
18
|
+
export declare const MORPHO_BLUE_WSTETH_ETH_945: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
19
|
+
export declare const MORPHO_BLUE_WSTETH_ETH_945_EXCHANGE_RATE: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
20
|
+
export declare const MORPHO_BLUE_WSTETH_ETH_965_EXCHANGE_RATE: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
10
21
|
export declare const MORPHO_BLUE_SUSDE_DAI_770: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
11
22
|
export declare const MORPHO_BLUE_SUSDE_DAI_860: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
12
23
|
export declare const MORPHO_BLUE_SUSDE_DAI_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
@@ -16,13 +27,24 @@ export declare const MORPHO_BLUE_USDE_DAI_860: (networkId?: NetworkNumber) => Mo
|
|
|
16
27
|
export declare const MORPHO_BLUE_USDE_DAI_915: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
17
28
|
export declare const MORPHO_BLUE_USDE_DAI_945: (networkId?: NetworkNumber) => MorphoBlueMarketData;
|
|
18
29
|
export declare const MorphoBlueMarkets: (networkId: NetworkNumber) => {
|
|
19
|
-
readonly morphobluewstetheth: MorphoBlueMarketData;
|
|
20
30
|
readonly morphobluewstethusdc: MorphoBlueMarketData;
|
|
21
31
|
readonly morphobluesdaiusdc: MorphoBlueMarketData;
|
|
22
32
|
readonly morphobluewbtcusdc: MorphoBlueMarketData;
|
|
23
33
|
readonly morphoblueethusdc: MorphoBlueMarketData;
|
|
24
34
|
readonly morphobluewbtcusdt: MorphoBlueMarketData;
|
|
25
35
|
readonly morphobluewstethusdt: MorphoBlueMarketData;
|
|
36
|
+
readonly morphobluewstethusda_exchange_rate: MorphoBlueMarketData;
|
|
37
|
+
readonly morphobluwstethpyusd: MorphoBlueMarketData;
|
|
38
|
+
readonly morphoblueweetheth: MorphoBlueMarketData;
|
|
39
|
+
readonly morphobluewbtcpyusd: MorphoBlueMarketData;
|
|
40
|
+
readonly morphobluewbtceth: MorphoBlueMarketData;
|
|
41
|
+
readonly morphoblueusdeusdt: MorphoBlueMarketData;
|
|
42
|
+
readonly morphobluesusdeusdt: MorphoBlueMarketData;
|
|
43
|
+
readonly morphobluesdaieth: MorphoBlueMarketData;
|
|
44
|
+
readonly morphoblueezetheth: MorphoBlueMarketData;
|
|
45
|
+
readonly morphobluewstetheth_945: MorphoBlueMarketData;
|
|
46
|
+
readonly morphobluewstetheth_945_exchange_rate: MorphoBlueMarketData;
|
|
47
|
+
readonly morphobluewstetheth_965_exchange_rate: MorphoBlueMarketData;
|
|
26
48
|
readonly morphobluesusdedai_770: MorphoBlueMarketData;
|
|
27
49
|
readonly morphobluesusdedai_860: MorphoBlueMarketData;
|
|
28
50
|
readonly morphobluesusdedai_915: MorphoBlueMarketData;
|