@defisaver/positions-sdk 0.0.201-fluid-dev-8 → 0.0.201-fluid-dev-10
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/fluid/index.d.ts +25 -2
- package/cjs/fluid/index.js +1 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/fluid/index.js +11 -11
- package/esm/fluid/index.d.ts +25 -2
- package/esm/fluid/index.js +1 -1
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/fluid/index.js +11 -11
- 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 -1122
- 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 +343 -343
- 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 +2010 -2010
- 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 -91
- 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 +264 -264
- 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
|
package/cjs/fluid/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
3
|
-
import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidVaultData, InnerFluidMarketData } from '../types';
|
|
3
|
+
import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidUsedAssets, FluidVaultData, InnerFluidMarketData } from '../types';
|
|
4
4
|
export declare const EMPTY_USED_ASSET: {
|
|
5
5
|
isSupplied: boolean;
|
|
6
6
|
isBorrowed: boolean;
|
|
@@ -61,5 +61,28 @@ export declare const getFluidDepositData: (web3: Web3, network: NetworkNumber, t
|
|
|
61
61
|
}>;
|
|
62
62
|
export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<{
|
|
63
63
|
marketData: FluidMarketData;
|
|
64
|
-
userData:
|
|
64
|
+
userData: {
|
|
65
|
+
nftId: string;
|
|
66
|
+
suppliedUsd: string;
|
|
67
|
+
borrowedUsd: string;
|
|
68
|
+
borrowLimitUsd: string;
|
|
69
|
+
liquidationLimitUsd: string;
|
|
70
|
+
leftToBorrowUsd: string;
|
|
71
|
+
netApy: string;
|
|
72
|
+
incentiveUsd: string;
|
|
73
|
+
ratio: string;
|
|
74
|
+
collRatio: string;
|
|
75
|
+
minRatio: string;
|
|
76
|
+
totalInterestUsd: string;
|
|
77
|
+
leveragedType?: string | undefined;
|
|
78
|
+
leveragedAsset?: string | undefined;
|
|
79
|
+
liquidationPrice?: string | undefined;
|
|
80
|
+
leveragedLsdAssetRatio?: string | undefined;
|
|
81
|
+
owner: string;
|
|
82
|
+
vaultId: number;
|
|
83
|
+
usedAssets: FluidUsedAssets;
|
|
84
|
+
isSubscribedToAutomation: boolean;
|
|
85
|
+
automationResubscribeRequired: boolean;
|
|
86
|
+
lastUpdated: number;
|
|
87
|
+
};
|
|
65
88
|
}[]>;
|
package/cjs/fluid/index.js
CHANGED
|
@@ -265,7 +265,7 @@ const getUserPositions = (web3, network, user) => __awaiter(void 0, void 0, void
|
|
|
265
265
|
const view = (0, contracts_1.FluidViewContract)(web3, network);
|
|
266
266
|
const data = yield view.methods.getUserPositions(user).call();
|
|
267
267
|
const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network); })));
|
|
268
|
-
const userData = data.positions.map((position, i) => parseUserData(position, parsedMarketData[i]));
|
|
268
|
+
const userData = data.positions.map((position, i) => (Object.assign(Object.assign({}, parseUserData(position, parsedMarketData[i])), { nftId: position.nftId })));
|
|
269
269
|
return parsedMarketData.map((market, i) => ({
|
|
270
270
|
marketData: market,
|
|
271
271
|
userData: userData[i],
|
|
@@ -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
|
|
@@ -1257,7 +1257,7 @@ const WBTC_USDC_12_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1257
1257
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1258
1258
|
label: 'WBTC / USDC Market 12',
|
|
1259
1259
|
shortLabel: 'WBTC/USDC',
|
|
1260
|
-
value: types_1.FluidArbitrumVersion.
|
|
1260
|
+
value: types_1.FluidArbitrumVersion.WBTC_USDC_12_ARB,
|
|
1261
1261
|
url: 'wbtc_usdc_12_arb',
|
|
1262
1262
|
marketAddress: '0xE16A6f5359ABB1f61cE71e25dD0932e3E00B00eB',
|
|
1263
1263
|
hasSmartCollateral: false,
|
|
@@ -1276,7 +1276,7 @@ const WBTC_USDT_13_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1276
1276
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1277
1277
|
label: 'WBTC / USDT Market 13',
|
|
1278
1278
|
shortLabel: 'WBTC/USDT',
|
|
1279
|
-
value: types_1.FluidArbitrumVersion.
|
|
1279
|
+
value: types_1.FluidArbitrumVersion.WBTC_USDT_13_ARB,
|
|
1280
1280
|
url: 'wbtc_usdc_13_arb',
|
|
1281
1281
|
marketAddress: '0x82B27fA821419F5689381b565a8B0786aA2548De',
|
|
1282
1282
|
hasSmartCollateral: false,
|
|
@@ -1333,7 +1333,7 @@ const WBTC_ETH_18_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1333
1333
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1334
1334
|
label: 'WBTC / ETH Market 18',
|
|
1335
1335
|
shortLabel: 'WBTC/ETH',
|
|
1336
|
-
value: types_1.FluidArbitrumVersion.
|
|
1336
|
+
value: types_1.FluidArbitrumVersion.WBTC_ETH_18_ARB,
|
|
1337
1337
|
url: 'wbtc_eth_18_arb',
|
|
1338
1338
|
marketAddress: '0xBc345229C1b52e4c30530C614BB487323BA38Da5',
|
|
1339
1339
|
hasSmartCollateral: false,
|
|
@@ -1352,7 +1352,7 @@ const ETH_WBTC_19_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1352
1352
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1353
1353
|
label: 'ETH / WBTC Market 19',
|
|
1354
1354
|
shortLabel: 'ETH/WBTC',
|
|
1355
|
-
value: types_1.FluidArbitrumVersion.
|
|
1355
|
+
value: types_1.FluidArbitrumVersion.ETH_WBTC_19_ARB,
|
|
1356
1356
|
url: 'eth_wbtc_19_arb',
|
|
1357
1357
|
marketAddress: '0xF2c8F54447cbd591C396b0Dd7ac15FAF552d0FA4',
|
|
1358
1358
|
hasSmartCollateral: false,
|
|
@@ -1371,7 +1371,7 @@ const WSTETH_WBTC_20_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1371
1371
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1372
1372
|
label: 'wstETH / WBTC Market 20',
|
|
1373
1373
|
shortLabel: 'wstETH/WBTC',
|
|
1374
|
-
value: types_1.FluidArbitrumVersion.
|
|
1374
|
+
value: types_1.FluidArbitrumVersion.WSTETH_WBTC_20_ARB,
|
|
1375
1375
|
url: 'wsteth_wbtc_20_arb',
|
|
1376
1376
|
marketAddress: '0x92643E964CA4b2c165a95CA919b0A819acA6D5F1',
|
|
1377
1377
|
hasSmartCollateral: false,
|
|
@@ -1390,7 +1390,7 @@ const WEETH_WBTC_21_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1390
1390
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1391
1391
|
label: 'weETH / WBTC Market 21',
|
|
1392
1392
|
shortLabel: 'weETH/WBTC',
|
|
1393
|
-
value: types_1.FluidArbitrumVersion.
|
|
1393
|
+
value: types_1.FluidArbitrumVersion.WEETH_WBTC_21_ARB,
|
|
1394
1394
|
url: 'weeth_wbtc_21_arb',
|
|
1395
1395
|
marketAddress: '0x6F72895Cf6904489Bcd862c941c3D02a3eE4f03e',
|
|
1396
1396
|
hasSmartCollateral: false,
|
|
@@ -1409,7 +1409,7 @@ const USDC_ETH_USDC_ETH_22_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1409
1409
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1410
1410
|
label: 'weETH / WBTC Market 22',
|
|
1411
1411
|
shortLabel: 'weETH/WBTC',
|
|
1412
|
-
value: types_1.FluidArbitrumVersion.
|
|
1412
|
+
value: types_1.FluidArbitrumVersion.USDC_ETH_USDC_ETH_22_ARB,
|
|
1413
1413
|
url: 'usdc_eth_usdc_eth_22_arb',
|
|
1414
1414
|
marketAddress: '0x3A0b7c8840D74D39552EF53F586dD8c3d1234C40',
|
|
1415
1415
|
hasSmartCollateral: false,
|
|
@@ -1428,7 +1428,7 @@ const ETH_USDC_USDT_23_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1428
1428
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1429
1429
|
label: 'ETH / USDC-USDT Market 23',
|
|
1430
1430
|
shortLabel: 'ETH/USDC-USDT',
|
|
1431
|
-
value: types_1.FluidArbitrumVersion.
|
|
1431
|
+
value: types_1.FluidArbitrumVersion.ETH_USDC_USDT_23_ARB,
|
|
1432
1432
|
url: 'eth_usdc_usdt_23_arb',
|
|
1433
1433
|
marketAddress: '0xaD439b9D61b25af1ca4Cd211E3eCb9AfBaAEd84a',
|
|
1434
1434
|
hasSmartCollateral: false,
|
|
@@ -1447,7 +1447,7 @@ const WSTETH_USDC_USDT_24_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1447
1447
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1448
1448
|
label: 'wstETH / USDC-USDT Market 23',
|
|
1449
1449
|
shortLabel: 'wstETH/USDC-USDT',
|
|
1450
|
-
value: types_1.FluidArbitrumVersion.
|
|
1450
|
+
value: types_1.FluidArbitrumVersion.WSTETH_USDC_USDT_24_ARB,
|
|
1451
1451
|
url: 'wsteth_usdc_usdt_23_arb',
|
|
1452
1452
|
marketAddress: '0x991416539E9DA46db233bCcbaEA38C4f852776D4',
|
|
1453
1453
|
hasSmartCollateral: false,
|
|
@@ -1466,7 +1466,7 @@ const WEETH_USDC_USDT_25_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1466
1466
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1467
1467
|
label: 'weETH / USDC-USDT Market 25',
|
|
1468
1468
|
shortLabel: 'weETH/USDC-USDT',
|
|
1469
|
-
value: types_1.FluidArbitrumVersion.
|
|
1469
|
+
value: types_1.FluidArbitrumVersion.WEETH_USDC_USDT_25_ARB,
|
|
1470
1470
|
url: 'weeth_usdc_usdt_25_arb',
|
|
1471
1471
|
marketAddress: '0x03271C337c86a6Fd89625A2820e48621DC2a128b',
|
|
1472
1472
|
hasSmartCollateral: false,
|
|
@@ -1485,7 +1485,7 @@ const WBTC_USDC_USDT_26_ARB = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
1485
1485
|
chainIds: [common_1.NetworkNumber.Arb],
|
|
1486
1486
|
label: 'WBTC / USDC-USDT Market 26',
|
|
1487
1487
|
shortLabel: 'WBTC/USDC-USDT',
|
|
1488
|
-
value: types_1.FluidArbitrumVersion.
|
|
1488
|
+
value: types_1.FluidArbitrumVersion.WBTC_USDC_USDT_26_ARB,
|
|
1489
1489
|
url: 'wbtc_usdc_usdt_26_arb',
|
|
1490
1490
|
marketAddress: '0xF74cb9D69ada3559903149CFD60fD57cEAF95F30',
|
|
1491
1491
|
hasSmartCollateral: false,
|
package/esm/fluid/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
3
|
-
import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidVaultData, InnerFluidMarketData } from '../types';
|
|
3
|
+
import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidUsedAssets, FluidVaultData, InnerFluidMarketData } from '../types';
|
|
4
4
|
export declare const EMPTY_USED_ASSET: {
|
|
5
5
|
isSupplied: boolean;
|
|
6
6
|
isBorrowed: boolean;
|
|
@@ -61,5 +61,28 @@ export declare const getFluidDepositData: (web3: Web3, network: NetworkNumber, t
|
|
|
61
61
|
}>;
|
|
62
62
|
export declare const getUserPositions: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<{
|
|
63
63
|
marketData: FluidMarketData;
|
|
64
|
-
userData:
|
|
64
|
+
userData: {
|
|
65
|
+
nftId: string;
|
|
66
|
+
suppliedUsd: string;
|
|
67
|
+
borrowedUsd: string;
|
|
68
|
+
borrowLimitUsd: string;
|
|
69
|
+
liquidationLimitUsd: string;
|
|
70
|
+
leftToBorrowUsd: string;
|
|
71
|
+
netApy: string;
|
|
72
|
+
incentiveUsd: string;
|
|
73
|
+
ratio: string;
|
|
74
|
+
collRatio: string;
|
|
75
|
+
minRatio: string;
|
|
76
|
+
totalInterestUsd: string;
|
|
77
|
+
leveragedType?: string | undefined;
|
|
78
|
+
leveragedAsset?: string | undefined;
|
|
79
|
+
liquidationPrice?: string | undefined;
|
|
80
|
+
leveragedLsdAssetRatio?: string | undefined;
|
|
81
|
+
owner: string;
|
|
82
|
+
vaultId: number;
|
|
83
|
+
usedAssets: FluidUsedAssets;
|
|
84
|
+
isSubscribedToAutomation: boolean;
|
|
85
|
+
automationResubscribeRequired: boolean;
|
|
86
|
+
lastUpdated: number;
|
|
87
|
+
};
|
|
65
88
|
}[]>;
|
package/esm/fluid/index.js
CHANGED
|
@@ -252,7 +252,7 @@ export const getUserPositions = (web3, network, user) => __awaiter(void 0, void
|
|
|
252
252
|
const view = FluidViewContract(web3, network);
|
|
253
253
|
const data = yield view.methods.getUserPositions(user).call();
|
|
254
254
|
const parsedMarketData = yield Promise.all(data.vaults.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, vaultData, network); })));
|
|
255
|
-
const userData = data.positions.map((position, i) => parseUserData(position, parsedMarketData[i]));
|
|
255
|
+
const userData = data.positions.map((position, i) => (Object.assign(Object.assign({}, parseUserData(position, parsedMarketData[i])), { nftId: position.nftId })));
|
|
256
256
|
return parsedMarketData.map((market, i) => ({
|
|
257
257
|
marketData: market,
|
|
258
258
|
userData: userData[i],
|
|
@@ -105,73 +105,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, web3, netwo
|
|
|
105
105
|
return { borrowRate, supplyRate };
|
|
106
106
|
});
|
|
107
107
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
108
|
-
const MARKET_QUERY = `
|
|
109
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
110
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
111
|
-
reallocatableLiquidityAssets
|
|
112
|
-
targetBorrowUtilization
|
|
113
|
-
loanAsset {
|
|
114
|
-
address
|
|
115
|
-
decimals
|
|
116
|
-
priceUsd
|
|
117
|
-
}
|
|
118
|
-
state {
|
|
119
|
-
liquidityAssets
|
|
120
|
-
borrowAssets
|
|
121
|
-
supplyAssets
|
|
122
|
-
}
|
|
123
|
-
publicAllocatorSharedLiquidity {
|
|
124
|
-
assets
|
|
125
|
-
vault {
|
|
126
|
-
address
|
|
127
|
-
name
|
|
128
|
-
}
|
|
129
|
-
allocationMarket {
|
|
130
|
-
uniqueKey
|
|
131
|
-
loanAsset {
|
|
132
|
-
address
|
|
133
|
-
}
|
|
134
|
-
collateralAsset {
|
|
135
|
-
address
|
|
136
|
-
}
|
|
137
|
-
irmAddress
|
|
138
|
-
oracle {
|
|
139
|
-
address
|
|
140
|
-
}
|
|
141
|
-
lltv
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
loanAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
collateralAsset {
|
|
148
|
-
address
|
|
149
|
-
}
|
|
150
|
-
oracle {
|
|
151
|
-
address
|
|
152
|
-
}
|
|
153
|
-
irmAddress
|
|
154
|
-
lltv
|
|
155
|
-
}
|
|
156
|
-
}
|
|
108
|
+
const MARKET_QUERY = `
|
|
109
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
110
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
111
|
+
reallocatableLiquidityAssets
|
|
112
|
+
targetBorrowUtilization
|
|
113
|
+
loanAsset {
|
|
114
|
+
address
|
|
115
|
+
decimals
|
|
116
|
+
priceUsd
|
|
117
|
+
}
|
|
118
|
+
state {
|
|
119
|
+
liquidityAssets
|
|
120
|
+
borrowAssets
|
|
121
|
+
supplyAssets
|
|
122
|
+
}
|
|
123
|
+
publicAllocatorSharedLiquidity {
|
|
124
|
+
assets
|
|
125
|
+
vault {
|
|
126
|
+
address
|
|
127
|
+
name
|
|
128
|
+
}
|
|
129
|
+
allocationMarket {
|
|
130
|
+
uniqueKey
|
|
131
|
+
loanAsset {
|
|
132
|
+
address
|
|
133
|
+
}
|
|
134
|
+
collateralAsset {
|
|
135
|
+
address
|
|
136
|
+
}
|
|
137
|
+
irmAddress
|
|
138
|
+
oracle {
|
|
139
|
+
address
|
|
140
|
+
}
|
|
141
|
+
lltv
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
loanAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
collateralAsset {
|
|
148
|
+
address
|
|
149
|
+
}
|
|
150
|
+
oracle {
|
|
151
|
+
address
|
|
152
|
+
}
|
|
153
|
+
irmAddress
|
|
154
|
+
lltv
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
157
|
`;
|
|
158
|
-
const REWARDS_QUERY = `
|
|
159
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
160
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
161
|
-
uniqueKey
|
|
162
|
-
state {
|
|
163
|
-
rewards {
|
|
164
|
-
amountPerSuppliedToken
|
|
165
|
-
supplyApr
|
|
166
|
-
amountPerBorrowedToken
|
|
167
|
-
borrowApr
|
|
168
|
-
asset {
|
|
169
|
-
address
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
158
|
+
const REWARDS_QUERY = `
|
|
159
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
160
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
161
|
+
uniqueKey
|
|
162
|
+
state {
|
|
163
|
+
rewards {
|
|
164
|
+
amountPerSuppliedToken
|
|
165
|
+
supplyApr
|
|
166
|
+
amountPerBorrowedToken
|
|
167
|
+
borrowApr
|
|
168
|
+
asset {
|
|
169
|
+
address
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
175
|
`;
|
|
176
176
|
/**
|
|
177
177
|
* Get reallocatable liquidity to a given market and target borrow utilization
|