@defisaver/positions-sdk 0.0.201-fluid-dev → 0.0.201-fluid-dev-1
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/cjs/config/contracts.d.ts +5 -5
- package/cjs/config/contracts.js +2 -2
- package/cjs/fluid/index.d.ts +1 -0
- package/cjs/fluid/index.js +65 -12
- package/cjs/markets/fluid/index.d.ts +2 -0
- package/cjs/markets/fluid/index.js +345 -1
- package/cjs/markets/index.d.ts +1 -1
- package/cjs/markets/index.js +3 -1
- package/cjs/morphoBlue/index.js +1 -2
- package/cjs/multicall/index.d.ts +1 -0
- package/cjs/multicall/index.js +8 -1
- package/cjs/services/utils.d.ts +1 -0
- package/cjs/services/utils.js +3 -1
- package/cjs/types/contracts/generated/FluidView.d.ts +0 -42
- package/cjs/types/fluid.d.ts +11 -0
- package/esm/config/contracts.d.ts +5 -5
- package/esm/config/contracts.js +2 -2
- package/esm/fluid/index.d.ts +1 -0
- package/esm/fluid/index.js +65 -13
- package/esm/markets/fluid/index.d.ts +2 -0
- package/esm/markets/fluid/index.js +343 -1
- package/esm/markets/index.d.ts +1 -1
- package/esm/markets/index.js +1 -1
- package/esm/morphoBlue/index.js +1 -2
- package/esm/multicall/index.d.ts +1 -0
- package/esm/multicall/index.js +6 -0
- package/esm/services/utils.d.ts +1 -0
- package/esm/services/utils.js +1 -0
- package/esm/types/contracts/generated/FluidView.d.ts +0 -42
- package/esm/types/fluid.d.ts +11 -0
- package/package.json +5 -3
- package/src/config/contracts.js +2 -2
- package/src/fluid/index.ts +69 -12
- package/src/markets/fluid/index.ts +347 -2
- package/src/markets/index.ts +1 -1
- package/src/morphoBlue/index.ts +1 -3
- package/src/multicall/index.ts +10 -1
- package/src/services/utils.ts +3 -1
- package/src/types/contracts/generated/FluidView.ts +0 -82
- package/src/types/fluid.ts +11 -0
package/cjs/markets/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
|
6
6
|
export { LlamaLendMarkets } from './llamaLend';
|
|
7
7
|
export { LiquityV2Markets } from './liquityV2';
|
|
8
8
|
export { EulerV2Markets } from './euler';
|
|
9
|
-
export { FluidMarkets } from './fluid';
|
|
9
|
+
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById } from './fluid';
|
package/cjs/markets/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FluidMarkets = exports.EulerV2Markets = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.morphoAaveV3AssetEthMarket = exports.morphoAaveV2AssetDefaultMarket = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
3
|
+
exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.EulerV2Markets = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.morphoAaveV3AssetEthMarket = exports.morphoAaveV2AssetDefaultMarket = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = 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
|
Object.defineProperty(exports, "aaveV1AssetsDefaultMarket", { enumerable: true, get: function () { return aave_1.aaveV1AssetsDefaultMarket; } });
|
|
@@ -32,3 +32,5 @@ var euler_1 = require("./euler");
|
|
|
32
32
|
Object.defineProperty(exports, "EulerV2Markets", { enumerable: true, get: function () { return euler_1.EulerV2Markets; } });
|
|
33
33
|
var fluid_1 = require("./fluid");
|
|
34
34
|
Object.defineProperty(exports, "FluidMarkets", { enumerable: true, get: function () { return fluid_1.FluidMarkets; } });
|
|
35
|
+
Object.defineProperty(exports, "getFluidVersionsDataForNetwork", { enumerable: true, get: function () { return fluid_1.getFluidVersionsDataForNetwork; } });
|
|
36
|
+
Object.defineProperty(exports, "getFluidMarketInfoById", { enumerable: true, get: function () { return fluid_1.getFluidMarketInfoById; } });
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -22,7 +22,6 @@ const staking_1 = require("../staking");
|
|
|
22
22
|
const utils_1 = require("../services/utils");
|
|
23
23
|
const morphoBlueHelpers_1 = require("../helpers/morphoBlueHelpers");
|
|
24
24
|
const priceService_1 = require("../services/priceService");
|
|
25
|
-
const isMainnetNetwork = (network) => network === common_1.NetworkNumber.Eth;
|
|
26
25
|
function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
27
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
27
|
const { loanToken, collateralToken, oracle, irm, lltv, oracleType, } = selectedMarket;
|
|
@@ -34,7 +33,7 @@ function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
|
34
33
|
let marketInfo;
|
|
35
34
|
let loanTokenPrice;
|
|
36
35
|
const isTokenUSDA = loanTokenInfo.symbol === 'USDA';
|
|
37
|
-
const isMainnet = isMainnetNetwork(network);
|
|
36
|
+
const isMainnet = (0, utils_1.isMainnetNetwork)(network);
|
|
38
37
|
if (isMainnet) {
|
|
39
38
|
const feedRegistryContract = (0, contracts_1.FeedRegistryContract)(mainnetWeb3, common_1.NetworkNumber.Eth);
|
|
40
39
|
const [_loanTokenPrice, _marketInfo] = yield Promise.all([
|
package/cjs/multicall/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { NetworkNumber } from '../types/common';
|
|
3
3
|
export declare const multicall: (calls: any[], web3: Web3, network?: NetworkNumber, blockNumber?: 'latest' | number) => Promise<any[]>;
|
|
4
|
+
export declare const chunkAndMulticall: (calls: any[], chunkSize: number, blockNumber: number | "latest" | undefined, web3: Web3, network?: NetworkNumber) => Promise<any[]>;
|
package/cjs/multicall/index.js
CHANGED
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.multicall = void 0;
|
|
12
|
+
exports.chunkAndMulticall = exports.multicall = void 0;
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
13
14
|
const contracts_1 = require("../contracts");
|
|
14
15
|
const common_1 = require("../types/common");
|
|
15
16
|
const multicall = (calls, web3, network = common_1.NetworkNumber.Eth, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -29,3 +30,9 @@ const multicall = (calls, web3, network = common_1.NetworkNumber.Eth, blockNumbe
|
|
|
29
30
|
return formattedResult;
|
|
30
31
|
});
|
|
31
32
|
exports.multicall = multicall;
|
|
33
|
+
const chunkAndMulticall = (calls, chunkSize, blockNumber = 'latest', web3, network = common_1.NetworkNumber.Eth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const chunkedCalls = (0, lodash_1.chunk)(calls, chunkSize);
|
|
35
|
+
const results = yield Promise.all(chunkedCalls.map((cnk) => (0, exports.multicall)(cnk, web3, network, blockNumber)));
|
|
36
|
+
return results.flat(1);
|
|
37
|
+
});
|
|
38
|
+
exports.chunkAndMulticall = chunkAndMulticall;
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export declare const mapRange: (input: number | string, minInput: number | strin
|
|
|
22
22
|
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) => bigint;
|
|
23
23
|
export declare const MAXUINT: string;
|
|
24
24
|
export declare const isMaxuint: (amount: string) => boolean;
|
|
25
|
+
export declare const isMainnetNetwork: (network: NetworkNumber) => boolean;
|
package/cjs/services/utils.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.isMaxuint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
6
|
+
exports.isMainnetNetwork = exports.isMaxuint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const tokens_1 = require("@defisaver/tokens");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -59,3 +59,5 @@ exports.isEnabledOnBitmap = isEnabledOnBitmap;
|
|
|
59
59
|
exports.MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
60
60
|
const isMaxuint = (amount) => (0, exports.compareAddresses)(exports.MAXUINT, amount);
|
|
61
61
|
exports.isMaxuint = isMaxuint;
|
|
62
|
+
const isMainnetNetwork = (network) => network === common_1.NetworkNumber.Eth;
|
|
63
|
+
exports.isMainnetNetwork = isMainnetNetwork;
|
|
@@ -100,10 +100,6 @@ export declare namespace FluidView {
|
|
|
100
100
|
number | string | BN,
|
|
101
101
|
number | string | BN,
|
|
102
102
|
number | string | BN,
|
|
103
|
-
number | string | BN,
|
|
104
|
-
number | string | BN,
|
|
105
|
-
number | string | BN,
|
|
106
|
-
number | string | BN,
|
|
107
103
|
number | string | BN
|
|
108
104
|
] | {
|
|
109
105
|
vault: string;
|
|
@@ -128,10 +124,6 @@ export declare namespace FluidView {
|
|
|
128
124
|
oracle: string;
|
|
129
125
|
oraclePriceOperate: number | string | BN;
|
|
130
126
|
oraclePriceLiquidate: number | string | BN;
|
|
131
|
-
priceOfSupplyToken0InUSD: number | string | BN;
|
|
132
|
-
priceOfSupplyToken1InUSD: number | string | BN;
|
|
133
|
-
priceOfBorrowToken0InUSD: number | string | BN;
|
|
134
|
-
priceOfBorrowToken1InUSD: number | string | BN;
|
|
135
127
|
vaultSupplyExchangePrice: number | string | BN;
|
|
136
128
|
vaultBorrowExchangePrice: number | string | BN;
|
|
137
129
|
supplyRateVault: number | string | BN;
|
|
@@ -203,10 +195,6 @@ export declare namespace FluidView {
|
|
|
203
195
|
string,
|
|
204
196
|
string,
|
|
205
197
|
string,
|
|
206
|
-
string,
|
|
207
|
-
string,
|
|
208
|
-
string,
|
|
209
|
-
string,
|
|
210
198
|
string
|
|
211
199
|
];
|
|
212
200
|
type VaultDataStructOutputStruct = {
|
|
@@ -232,10 +220,6 @@ export declare namespace FluidView {
|
|
|
232
220
|
oracle: string;
|
|
233
221
|
oraclePriceOperate: string;
|
|
234
222
|
oraclePriceLiquidate: string;
|
|
235
|
-
priceOfSupplyToken0InUSD: string;
|
|
236
|
-
priceOfSupplyToken1InUSD: string;
|
|
237
|
-
priceOfBorrowToken0InUSD: string;
|
|
238
|
-
priceOfBorrowToken1InUSD: string;
|
|
239
223
|
vaultSupplyExchangePrice: string;
|
|
240
224
|
vaultBorrowExchangePrice: string;
|
|
241
225
|
supplyRateVault: string;
|
|
@@ -267,14 +251,6 @@ export interface FluidView extends BaseContract {
|
|
|
267
251
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): FluidView;
|
|
268
252
|
clone(): FluidView;
|
|
269
253
|
methods: {
|
|
270
|
-
feedRegistry(): NonPayableTransactionObject<string>;
|
|
271
|
-
getAaveTokenPriceInETH(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
272
|
-
getAaveTokenPriceInUSD(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
273
|
-
getAaveV3TokenPriceInETH(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
274
|
-
getAaveV3TokenPriceInUSD(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
275
|
-
getAddrForChainlinkOracle(_inputTokenAddr: string): NonPayableTransactionObject<string>;
|
|
276
|
-
getChainlinkPriceInETH(_inputTokenAddr: string): NonPayableTransactionObject<string>;
|
|
277
|
-
getChainlinkPriceInUSD(_inputTokenAddr: string, _useFallback: boolean): NonPayableTransactionObject<string>;
|
|
278
254
|
getPositionByNftId(_nftId: number | string | BN): NonPayableTransactionObject<[
|
|
279
255
|
FluidView.UserPositionStructOutput,
|
|
280
256
|
FluidView.VaultDataStructOutput
|
|
@@ -282,23 +258,7 @@ export interface FluidView extends BaseContract {
|
|
|
282
258
|
position: FluidView.UserPositionStructOutput;
|
|
283
259
|
vault: FluidView.VaultDataStructOutput;
|
|
284
260
|
}>;
|
|
285
|
-
getPriceInETH(_inputTokenAddr: string): NonPayableTransactionObject<string>;
|
|
286
|
-
getPriceInUSD(_inputTokenAddr: string): NonPayableTransactionObject<string>;
|
|
287
261
|
getRatio(_nftId: number | string | BN): NonPayableTransactionObject<string>;
|
|
288
|
-
"getRoundInfo(address,uint80,address)"(_inputTokenAddr: string, _roundId: number | string | BN, aggregator: string): NonPayableTransactionObject<[
|
|
289
|
-
string,
|
|
290
|
-
string
|
|
291
|
-
] & {
|
|
292
|
-
updateTimestamp: string;
|
|
293
|
-
}>;
|
|
294
|
-
"getRoundInfo(address,uint80)"(_inputTokenAddr: string, _roundId: number | string | BN): NonPayableTransactionObject<[
|
|
295
|
-
string,
|
|
296
|
-
string
|
|
297
|
-
] & {
|
|
298
|
-
updateTimestamp: string;
|
|
299
|
-
}>;
|
|
300
|
-
getSparkTokenPriceInETH(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
301
|
-
getSparkTokenPriceInUSD(_tokenAddr: string): NonPayableTransactionObject<string>;
|
|
302
262
|
getUserNftIds(_user: string): NonPayableTransactionObject<string[]>;
|
|
303
263
|
getUserPositions(_user: string): NonPayableTransactionObject<[
|
|
304
264
|
FluidView.UserPositionStructOutput[],
|
|
@@ -309,8 +269,6 @@ export interface FluidView extends BaseContract {
|
|
|
309
269
|
}>;
|
|
310
270
|
getVaultAddresses(_ids: number | string | BN[], _fetchAll: boolean): NonPayableTransactionObject<string[]>;
|
|
311
271
|
getVaultData(_vault: string): NonPayableTransactionObject<FluidView.VaultDataStructOutput>;
|
|
312
|
-
getWBtcPrice(_btcPrice: number | string | BN): NonPayableTransactionObject<string>;
|
|
313
|
-
getWStEthPrice(_stEthPrice: number | string | BN): NonPayableTransactionObject<string>;
|
|
314
272
|
};
|
|
315
273
|
events: {
|
|
316
274
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
package/cjs/types/fluid.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface FluidMarketInfo {
|
|
|
11
11
|
hasSmartDebt: boolean;
|
|
12
12
|
collateralAsset: string;
|
|
13
13
|
debtAsset: string;
|
|
14
|
+
ethBased?: boolean;
|
|
15
|
+
btcBased?: boolean;
|
|
16
|
+
wstETHBased?: boolean;
|
|
17
|
+
type: FluidVaultType;
|
|
14
18
|
}
|
|
15
19
|
export declare enum FluidMainnetVersion {
|
|
16
20
|
ETH_USDC_1 = "ETH_USDC_1",
|
|
@@ -158,17 +162,22 @@ export interface InnerFluidMarketData {
|
|
|
158
162
|
isSmartDebt: boolean;
|
|
159
163
|
marketAddress: string;
|
|
160
164
|
vaultType: FluidVaultType;
|
|
165
|
+
vaultValue?: FluidVersions;
|
|
161
166
|
oracle: string;
|
|
162
167
|
liquidationPenaltyPercent: string;
|
|
163
168
|
collFactor: string;
|
|
164
169
|
liquidationRatio: string;
|
|
170
|
+
liqFactor: string;
|
|
171
|
+
minRatio: string;
|
|
165
172
|
collAsset0: string;
|
|
166
173
|
collAsset1?: string;
|
|
167
174
|
debtAsset0: string;
|
|
168
175
|
debtAsset1?: string;
|
|
169
176
|
totalPositions: string;
|
|
170
177
|
totalSupplyVault: string;
|
|
178
|
+
totalSupplyVaultUsd: string;
|
|
171
179
|
totalBorrowVault: string;
|
|
180
|
+
totalBorrowVaultUsd: string;
|
|
172
181
|
withdrawalLimit: string;
|
|
173
182
|
withdrawableUntilLimit: string;
|
|
174
183
|
withdrawable: string;
|
|
@@ -179,6 +188,8 @@ export interface InnerFluidMarketData {
|
|
|
179
188
|
maxBorrowLimit: string;
|
|
180
189
|
baseBorrowLimit: string;
|
|
181
190
|
minimumBorrowing: string;
|
|
191
|
+
supplyRate: string;
|
|
192
|
+
borrowRate: string;
|
|
182
193
|
}
|
|
183
194
|
export interface FluidMarketData {
|
|
184
195
|
assetsData: FluidAssetsData;
|
|
@@ -7608,6 +7608,11 @@ export namespace FluidView {
|
|
|
7608
7608
|
}[];
|
|
7609
7609
|
name: string;
|
|
7610
7610
|
outputs: {
|
|
7611
|
+
components: {
|
|
7612
|
+
internalType: string;
|
|
7613
|
+
name: string;
|
|
7614
|
+
type: string;
|
|
7615
|
+
}[];
|
|
7611
7616
|
internalType: string;
|
|
7612
7617
|
name: string;
|
|
7613
7618
|
type: string;
|
|
@@ -7622,11 +7627,6 @@ export namespace FluidView {
|
|
|
7622
7627
|
}[];
|
|
7623
7628
|
name: string;
|
|
7624
7629
|
outputs: {
|
|
7625
|
-
components: {
|
|
7626
|
-
internalType: string;
|
|
7627
|
-
name: string;
|
|
7628
|
-
type: string;
|
|
7629
|
-
}[];
|
|
7630
7630
|
internalType: string;
|
|
7631
7631
|
name: string;
|
|
7632
7632
|
type: string;
|
package/esm/config/contracts.js
CHANGED
|
@@ -1106,9 +1106,9 @@ module.exports = {
|
|
|
1106
1106
|
}
|
|
1107
1107
|
},
|
|
1108
1108
|
"FluidView": {
|
|
1109
|
-
"abi": [{ "inputs": [], "name": "feedRegistry", "outputs": [{ "internalType": "contract IFeedRegistry", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveTokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveTokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveV3TokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveV3TokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getAddrForChainlinkOracle", "outputs": [{ "internalType": "address", "name": "tokenAddrForChainlinkUsage", "type": "address" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getChainlinkPriceInETH", "outputs": [{ "internalType": "int256", "name": "chainlinkPriceInETH", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "bool", "name": "_useFallback", "type": "bool" }], "name": "getChainlinkPriceInUSD", "outputs": [{ "internalType": "int256", "name": "chainlinkPriceInUSD", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getPositionByNftId", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition", "name": "position", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vault", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }, { "internalType": "contract IAggregatorV3", "name": "aggregator", "type": "address" }], "name": "getRoundInfo", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "updateTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundInfo", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "updateTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getSparkTokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getSparkTokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserNftIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserPositions", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition[]", "name": "positions", "type": "tuple[]" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData[]", "name": "vaults", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }, { "internalType": "bool", "name": "_fetchAll", "type": "bool" }], "name": "getVaultAddresses", "outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_vault", "type": "address" }], "name": "getVaultData", "outputs": [{ "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vaultData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int256", "name": "_btcPrice", "type": "int256" }], "name": "getWBtcPrice", "outputs": [{ "internalType": "int256", "name": "wBtcPrice", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int256", "name": "_stEthPrice", "type": "int256" }], "name": "getWStEthPrice", "outputs": [{ "internalType": "int256", "name": "wStEthPrice", "type": "int256" }], "stateMutability": "view", "type": "function" }],
|
|
1109
|
+
"abi": [{ "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getPositionByNftId", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition", "name": "position", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vault", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserNftIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserPositions", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition[]", "name": "positions", "type": "tuple[]" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData[]", "name": "vaults", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }, { "internalType": "bool", "name": "_fetchAll", "type": "bool" }], "name": "getVaultAddresses", "outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_vault", "type": "address" }], "name": "getVaultData", "outputs": [{ "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vaultData", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
|
|
1110
1110
|
"networks": {
|
|
1111
|
-
"1": { "address": "
|
|
1111
|
+
"1": { "address": "0x72B2A658d2009fF3c3e133d3a042fFE705808aC5" }
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
1114
|
};
|
package/esm/fluid/index.d.ts
CHANGED
package/esm/fluid/index.js
CHANGED
|
@@ -9,10 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
|
+
import { NetworkNumber } from '../types/common';
|
|
12
13
|
import { FluidVaultType, } from '../types';
|
|
13
|
-
import { FluidViewContract } from '../contracts';
|
|
14
|
-
import { getEthAmountForDecimals } from '../services/utils';
|
|
14
|
+
import { DFSFeedRegistryContract, FeedRegistryContract, FluidViewContract } from '../contracts';
|
|
15
|
+
import { getEthAmountForDecimals, isMainnetNetwork } from '../services/utils';
|
|
15
16
|
import { getFluidAggregatedData } from '../helpers/fluidHelpers';
|
|
17
|
+
import { chunkAndMulticall } from '../multicall';
|
|
18
|
+
import { getFluidMarketInfoById, getFluidVersionsDataForNetwork } from '../markets/fluid';
|
|
19
|
+
import { USD_QUOTE } from '../constants';
|
|
20
|
+
import { getChainlinkAssetAddress, getWstETHPrice } from '../services/priceService';
|
|
16
21
|
export const EMPTY_USED_ASSET = {
|
|
17
22
|
isSupplied: false,
|
|
18
23
|
isBorrowed: false,
|
|
@@ -32,37 +37,67 @@ const parseVaultType = (vaultType) => {
|
|
|
32
37
|
default: return FluidVaultType.Unknown;
|
|
33
38
|
}
|
|
34
39
|
};
|
|
35
|
-
const parseMarketData = (data) => {
|
|
40
|
+
const parseMarketData = (web3, data, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
41
|
const collAsset = getAssetInfoByAddress(data.supplyToken0);
|
|
37
42
|
const debtAsset = getAssetInfoByAddress(data.borrowToken0);
|
|
43
|
+
const supplyRate = new Dec(data.supplyRateVault).div(100).toString();
|
|
44
|
+
const borrowRate = new Dec(data.borrowRateVault).div(100).toString();
|
|
45
|
+
const oracleScaleFactor = new Dec(27).add(debtAsset.decimals).sub(collAsset.decimals).toString();
|
|
46
|
+
const oracleScale = new Dec(10).pow(oracleScaleFactor).toString();
|
|
47
|
+
const oraclePrice = new Dec(data.oraclePriceOperate).div(oracleScale).toString();
|
|
48
|
+
const isTokenUSDA = debtAsset.symbol === 'USDA';
|
|
49
|
+
const isMainnet = isMainnetNetwork(network);
|
|
50
|
+
const loanTokenFeedAddress = getChainlinkAssetAddress(debtAsset.symbol, network);
|
|
51
|
+
let loanTokenPrice;
|
|
52
|
+
if (debtAsset.symbol === 'wstETH') {
|
|
53
|
+
// need to handle wstETH for l2s inside getWstETHPrice
|
|
54
|
+
loanTokenPrice = yield getWstETHPrice(web3);
|
|
55
|
+
}
|
|
56
|
+
else if (isMainnet) {
|
|
57
|
+
const feedRegistryContract = FeedRegistryContract(web3, NetworkNumber.Eth);
|
|
58
|
+
loanTokenPrice = isTokenUSDA ? '100000000' : yield feedRegistryContract.methods.latestAnswer(loanTokenFeedAddress, USD_QUOTE).call();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Currently only base network is supported
|
|
62
|
+
const feedRegistryContract = DFSFeedRegistryContract(web3, network);
|
|
63
|
+
const roundPriceData = isTokenUSDA ? { answer: '100000000' } : yield feedRegistryContract.methods.latestRoundData(loanTokenFeedAddress, USD_QUOTE).call();
|
|
64
|
+
loanTokenPrice = roundPriceData.answer;
|
|
65
|
+
}
|
|
66
|
+
const debtPriceParsed = new Dec(loanTokenPrice).div(1e8).toString();
|
|
38
67
|
const collAssetData = {
|
|
39
68
|
symbol: collAsset.symbol,
|
|
40
69
|
address: collAsset.address,
|
|
41
|
-
price:
|
|
70
|
+
price: new Dec(debtPriceParsed).mul(oraclePrice).toString(),
|
|
42
71
|
totalSupply: data.totalSupplyVault,
|
|
43
72
|
totalBorrow: data.totalBorrowVault,
|
|
44
73
|
canBeSupplied: true,
|
|
45
74
|
canBeBorrowed: false,
|
|
46
|
-
supplyRate
|
|
75
|
+
supplyRate,
|
|
47
76
|
borrowRate: '0',
|
|
48
77
|
};
|
|
49
78
|
const debtAssetData = {
|
|
50
79
|
symbol: debtAsset.symbol,
|
|
51
80
|
address: debtAsset.address,
|
|
52
|
-
price:
|
|
81
|
+
price: debtPriceParsed,
|
|
53
82
|
totalSupply: data.totalSupplyVault,
|
|
54
83
|
totalBorrow: data.totalBorrowVault,
|
|
55
84
|
canBeSupplied: false,
|
|
56
85
|
canBeBorrowed: true,
|
|
57
86
|
supplyRate: '0',
|
|
58
|
-
borrowRate
|
|
87
|
+
borrowRate,
|
|
59
88
|
};
|
|
60
89
|
const assetsData = {
|
|
61
90
|
[collAsset.symbol]: collAssetData,
|
|
62
91
|
[debtAsset.symbol]: debtAssetData,
|
|
63
92
|
};
|
|
93
|
+
const marketInfo = getFluidMarketInfoById(+data.vaultId, network);
|
|
94
|
+
const totalSupplyVault = getEthAmountForDecimals(data.totalSupplyVault, collAsset.decimals);
|
|
95
|
+
const totalBorrowVault = getEthAmountForDecimals(data.totalBorrowVault, debtAsset.decimals);
|
|
96
|
+
const liqRatio = new Dec(data.liquidationThreshold).div(100).toString();
|
|
97
|
+
const liqFactor = new Dec(data.liquidationThreshold).div(10000).toString();
|
|
64
98
|
const marketData = {
|
|
65
99
|
vaultId: +data.vaultId,
|
|
100
|
+
vaultValue: marketInfo === null || marketInfo === void 0 ? void 0 : marketInfo.value,
|
|
66
101
|
isSmartColl: data.isSmartColl,
|
|
67
102
|
isSmartDebt: data.isSmartDebt,
|
|
68
103
|
marketAddress: data.vault,
|
|
@@ -70,12 +105,16 @@ const parseMarketData = (data) => {
|
|
|
70
105
|
oracle: data.oracle,
|
|
71
106
|
liquidationPenaltyPercent: new Dec(data.liquidationPenalty).div(100).toString(),
|
|
72
107
|
collFactor: new Dec(data.collateralFactor).div(10000).toString(),
|
|
73
|
-
liquidationRatio:
|
|
108
|
+
liquidationRatio: liqRatio,
|
|
109
|
+
liqFactor,
|
|
110
|
+
minRatio: new Dec(1).div(liqFactor).mul(100).toString(),
|
|
74
111
|
collAsset0: collAsset.symbol,
|
|
75
112
|
debtAsset0: debtAsset.symbol,
|
|
76
113
|
totalPositions: data.totalPositions,
|
|
77
|
-
totalSupplyVault
|
|
78
|
-
totalBorrowVault
|
|
114
|
+
totalSupplyVault,
|
|
115
|
+
totalBorrowVault,
|
|
116
|
+
totalSupplyVaultUsd: new Dec(totalSupplyVault).mul(collAssetData.price).toString(),
|
|
117
|
+
totalBorrowVaultUsd: new Dec(totalSupplyVault).mul(debtAssetData.price).toString(),
|
|
79
118
|
withdrawalLimit: getEthAmountForDecimals(data.withdrawalLimit, collAsset.decimals),
|
|
80
119
|
withdrawableUntilLimit: getEthAmountForDecimals(data.withdrawableUntilLimit, collAsset.decimals),
|
|
81
120
|
withdrawable: getEthAmountForDecimals(data.withdrawable, collAsset.decimals),
|
|
@@ -86,12 +125,14 @@ const parseMarketData = (data) => {
|
|
|
86
125
|
maxBorrowLimit: getEthAmountForDecimals(data.maxBorrowLimit, debtAsset.decimals),
|
|
87
126
|
baseBorrowLimit: getEthAmountForDecimals(data.baseBorrowLimit, debtAsset.decimals),
|
|
88
127
|
minimumBorrowing: getEthAmountForDecimals(data.minimumBorrowing, debtAsset.decimals),
|
|
128
|
+
borrowRate,
|
|
129
|
+
supplyRate,
|
|
89
130
|
};
|
|
90
131
|
return {
|
|
91
132
|
assetsData,
|
|
92
133
|
marketData,
|
|
93
134
|
};
|
|
94
|
-
};
|
|
135
|
+
});
|
|
95
136
|
export const EMPTY_FLUID_DATA = {
|
|
96
137
|
usedAssets: {},
|
|
97
138
|
suppliedUsd: '0',
|
|
@@ -129,7 +170,7 @@ const parseUserData = (userPositionData, vaultData) => {
|
|
|
129
170
|
export const getFluidMarketData = (web3, network, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
171
|
const view = FluidViewContract(web3, network);
|
|
131
172
|
const data = yield view.methods.getVaultData(market.marketAddress).call();
|
|
132
|
-
return parseMarketData(data);
|
|
173
|
+
return parseMarketData(web3, data, network);
|
|
133
174
|
});
|
|
134
175
|
export const getFluidVaultIdsForUser = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
176
|
const view = FluidViewContract(web3, network);
|
|
@@ -144,10 +185,21 @@ export const getFluidPosition = (web3, network, vaultId, extractedState) => __aw
|
|
|
144
185
|
export const getFluidPositionWithMarket = (web3, network, vaultId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
186
|
const view = FluidViewContract(web3, network);
|
|
146
187
|
const data = yield view.methods.getPositionByNftId(vaultId).call();
|
|
147
|
-
const marketData = parseMarketData(data.vault);
|
|
188
|
+
const marketData = yield parseMarketData(web3, data.vault, network);
|
|
148
189
|
const userData = parseUserData(data.position, marketData);
|
|
149
190
|
return {
|
|
150
191
|
userData,
|
|
151
192
|
marketData,
|
|
152
193
|
};
|
|
153
194
|
});
|
|
195
|
+
export const getAllFluidMarketDataChunked = (network, web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
+
const versions = getFluidVersionsDataForNetwork(network);
|
|
197
|
+
const view = FluidViewContract(web3, network);
|
|
198
|
+
const calls = versions.map((version) => ({
|
|
199
|
+
target: view.options.address,
|
|
200
|
+
abiItem: view.options.jsonInterface.find((item) => item.name === 'getVaultData'),
|
|
201
|
+
params: [version.marketAddress],
|
|
202
|
+
}));
|
|
203
|
+
const data = yield chunkAndMulticall(calls, 10, 'latest', web3, network);
|
|
204
|
+
return Promise.all(data.map((item, i) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(web3, item.vaultData, network); })));
|
|
205
|
+
});
|
|
@@ -172,3 +172,5 @@ export declare const FluidMarkets: (networkId: NetworkNumber) => {
|
|
|
172
172
|
WEETH_CBBTC_15_BASE: FluidMarketInfo;
|
|
173
173
|
WSTETH_CBBTC_16_BASE: FluidMarketInfo;
|
|
174
174
|
};
|
|
175
|
+
export declare const getFluidVersionsDataForNetwork: (network: NetworkNumber) => FluidMarketInfo[];
|
|
176
|
+
export declare const getFluidMarketInfoById: (vaultId: number, network?: NetworkNumber) => FluidMarketInfo | undefined;
|