@defisaver/positions-sdk 1.0.11-dev → 1.0.11-fluid-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/config/contracts.d.ts +113 -49
- package/cjs/config/contracts.js +10 -2
- package/cjs/contracts.d.ts +1 -0
- package/cjs/contracts.js +2 -1
- package/cjs/fluid/index.d.ts +2 -0
- package/cjs/fluid/index.js +636 -13
- package/cjs/helpers/fluidHelpers/index.d.ts +59 -2
- package/cjs/helpers/fluidHelpers/index.js +142 -4
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/fluid/index.js +276 -245
- package/cjs/services/priceService.d.ts +23 -0
- package/cjs/services/priceService.js +44 -5
- package/cjs/types/contracts/generated/FluidView.d.ts +220 -3
- package/cjs/types/contracts/generated/WeETHPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/WeETHPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -0
- package/cjs/types/fluid.d.ts +39 -10
- package/esm/config/contracts.d.ts +113 -49
- package/esm/config/contracts.js +10 -2
- package/esm/contracts.d.ts +1 -0
- package/esm/contracts.js +1 -0
- package/esm/fluid/index.d.ts +2 -0
- package/esm/fluid/index.js +639 -16
- package/esm/helpers/fluidHelpers/index.d.ts +59 -2
- package/esm/helpers/fluidHelpers/index.js +137 -3
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/fluid/index.js +276 -245
- package/esm/services/priceService.d.ts +23 -0
- package/esm/services/priceService.js +40 -5
- package/esm/types/contracts/generated/FluidView.d.ts +220 -3
- package/esm/types/contracts/generated/WeETHPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/WeETHPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +1 -0
- package/esm/types/fluid.d.ts +39 -10
- package/package.json +54 -54
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +624 -624
- 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 +1155 -1147
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +135 -134
- package/src/curveUsd/index.ts +239 -239
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/fluid/index.ts +1216 -354
- package/src/helpers/aaveHelpers/index.ts +203 -203
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +248 -248
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +234 -234
- package/src/helpers/fluidHelpers/index.ts +295 -57
- package/src/helpers/index.ts +11 -11
- package/src/helpers/liquityV2Helpers/index.ts +80 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +367 -367
- package/src/helpers/sparkHelpers/index.ts +154 -154
- package/src/index.ts +52 -52
- package/src/liquity/index.ts +116 -116
- package/src/liquityV2/index.ts +295 -295
- 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 +46 -46
- 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 +2043 -2012
- package/src/markets/index.ts +27 -27
- package/src/markets/liquityV2/index.ts +54 -54
- 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 +630 -630
- package/src/morphoBlue/index.ts +202 -202
- package/src/multicall/index.ts +33 -33
- package/src/services/priceService.ts +130 -91
- package/src/services/utils.ts +59 -59
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +460 -460
- package/src/staking/staking.ts +217 -217
- package/src/types/aave.ts +275 -275
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +133 -133
- package/src/types/contracts/generated/FluidView.ts +263 -2
- package/src/types/contracts/generated/WeETHPriceFeed.ts +202 -0
- package/src/types/contracts/generated/index.ts +1 -0
- package/src/types/curveUsd.ts +119 -119
- package/src/types/euler.ts +173 -173
- package/src/types/fluid.ts +299 -268
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +119 -119
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/spark.ts +135 -135
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import Web3 from 'web3';
|
|
2
|
-
import Dec from 'decimal.js';
|
|
3
|
-
import { Blockish, NetworkNumber } from '../../types/common';
|
|
4
|
-
import {
|
|
5
|
-
McdDogContract, McdJugContract, McdSpotterContract, McdVatContract,
|
|
6
|
-
} from '../../contracts';
|
|
7
|
-
import { multicall } from '../../multicall';
|
|
8
|
-
import { SECONDS_PER_YEAR } from '../../constants';
|
|
9
|
-
import { bytesToString } from '../../services/utils';
|
|
10
|
-
import { IlkInfo } from '../../types';
|
|
11
|
-
|
|
12
|
-
export const getUnclaimedCollateral = async (web3: Web3, network: NetworkNumber, urn: string, ilk: string) => {
|
|
13
|
-
const vatContract = McdVatContract(web3, network);
|
|
14
|
-
const coll = await vatContract.methods.gem(ilk, urn).call();
|
|
15
|
-
return coll;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const getCollateralInfo = async (ilk: string, web3: Web3, network: NetworkNumber, block: Blockish = 'latest'): Promise<IlkInfo> => {
|
|
19
|
-
const spotterContract = McdSpotterContract(web3, network);
|
|
20
|
-
const vatContract = McdVatContract(web3, network);
|
|
21
|
-
const dogContract = McdDogContract(web3, network);
|
|
22
|
-
const jugContract = McdJugContract(web3, network);
|
|
23
|
-
|
|
24
|
-
const multicallData = [
|
|
25
|
-
{
|
|
26
|
-
target: spotterContract.options.address,
|
|
27
|
-
abiItem: spotterContract.options.jsonInterface.find(({ name }) => name === 'par'),
|
|
28
|
-
params: [],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
target: spotterContract.options.address,
|
|
32
|
-
abiItem: spotterContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
33
|
-
params: [ilk],
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
target: vatContract.options.address,
|
|
37
|
-
abiItem: vatContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
38
|
-
params: [ilk],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
target: jugContract.options.address,
|
|
42
|
-
abiItem: jugContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
43
|
-
params: [ilk],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
target: jugContract.options.address,
|
|
47
|
-
abiItem: jugContract.options.jsonInterface.find(({ name }) => name === 'drip'),
|
|
48
|
-
params: [ilk],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
target: dogContract.options.address,
|
|
52
|
-
abiItem: dogContract.options.jsonInterface.find(({ name }) => name === 'chop'),
|
|
53
|
-
params: [ilk],
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const multiRes = await multicall(multicallData, web3, network, block);
|
|
58
|
-
|
|
59
|
-
const par = new Dec(multiRes[0][0].toString()).div(1e27).toString();
|
|
60
|
-
const mat = new Dec(multiRes[1][1].toString()).div(1e27).toString();
|
|
61
|
-
const art = new Dec(multiRes[2][0].toString()).toString();
|
|
62
|
-
const rate = new Dec(multiRes[2][1].toString()).toString();
|
|
63
|
-
const spot = new Dec(multiRes[2][2].toString()).div(1e27).toString();
|
|
64
|
-
const line = new Dec(multiRes[2][3].toString()).div(1e45).toString();
|
|
65
|
-
const dust = new Dec(multiRes[2][1].toString()).div(1e45).toString();
|
|
66
|
-
const duty = new Dec(multiRes[3][0].toString()).toString();
|
|
67
|
-
const futureRate = new Dec(multiRes[4][0].toString()).toString();
|
|
68
|
-
const chop = new Dec(multiRes[5][0].toString()).div(1e18).toString();
|
|
69
|
-
|
|
70
|
-
const stabilityFee = new Dec(duty.toString())
|
|
71
|
-
.div(1e27)
|
|
72
|
-
.pow(SECONDS_PER_YEAR)
|
|
73
|
-
.minus(1)
|
|
74
|
-
.mul(100)
|
|
75
|
-
.toNumber();
|
|
76
|
-
const liquidationFee = new Dec(chop).mul(100).sub(100).toString();
|
|
77
|
-
const globalDebtCurrent = new Dec(art).div(1e18).mul(new Dec(futureRate).div(1e27)).toString();
|
|
78
|
-
const globalDebtCeiling = line;
|
|
79
|
-
const creatableDebt = new Dec(globalDebtCeiling).sub(globalDebtCurrent).toString();
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
ilkLabel: bytesToString(ilk),
|
|
83
|
-
currentRate: rate,
|
|
84
|
-
futureRate,
|
|
85
|
-
minDebt: dust,
|
|
86
|
-
globalDebtCurrent,
|
|
87
|
-
globalDebtCeiling,
|
|
88
|
-
assetPrice: new Dec(spot).times(par).times(mat).toString(),
|
|
89
|
-
liqRatio: mat,
|
|
90
|
-
liqPercent: +mat * 100,
|
|
91
|
-
stabilityFee,
|
|
92
|
-
liquidationFee: new Dec(liquidationFee).lt(0) ? '0' : liquidationFee,
|
|
93
|
-
creatableDebt,
|
|
94
|
-
};
|
|
1
|
+
import Web3 from 'web3';
|
|
2
|
+
import Dec from 'decimal.js';
|
|
3
|
+
import { Blockish, NetworkNumber } from '../../types/common';
|
|
4
|
+
import {
|
|
5
|
+
McdDogContract, McdJugContract, McdSpotterContract, McdVatContract,
|
|
6
|
+
} from '../../contracts';
|
|
7
|
+
import { multicall } from '../../multicall';
|
|
8
|
+
import { SECONDS_PER_YEAR } from '../../constants';
|
|
9
|
+
import { bytesToString } from '../../services/utils';
|
|
10
|
+
import { IlkInfo } from '../../types';
|
|
11
|
+
|
|
12
|
+
export const getUnclaimedCollateral = async (web3: Web3, network: NetworkNumber, urn: string, ilk: string) => {
|
|
13
|
+
const vatContract = McdVatContract(web3, network);
|
|
14
|
+
const coll = await vatContract.methods.gem(ilk, urn).call();
|
|
15
|
+
return coll;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getCollateralInfo = async (ilk: string, web3: Web3, network: NetworkNumber, block: Blockish = 'latest'): Promise<IlkInfo> => {
|
|
19
|
+
const spotterContract = McdSpotterContract(web3, network);
|
|
20
|
+
const vatContract = McdVatContract(web3, network);
|
|
21
|
+
const dogContract = McdDogContract(web3, network);
|
|
22
|
+
const jugContract = McdJugContract(web3, network);
|
|
23
|
+
|
|
24
|
+
const multicallData = [
|
|
25
|
+
{
|
|
26
|
+
target: spotterContract.options.address,
|
|
27
|
+
abiItem: spotterContract.options.jsonInterface.find(({ name }) => name === 'par'),
|
|
28
|
+
params: [],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
target: spotterContract.options.address,
|
|
32
|
+
abiItem: spotterContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
33
|
+
params: [ilk],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
target: vatContract.options.address,
|
|
37
|
+
abiItem: vatContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
38
|
+
params: [ilk],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
target: jugContract.options.address,
|
|
42
|
+
abiItem: jugContract.options.jsonInterface.find(({ name }) => name === 'ilks'),
|
|
43
|
+
params: [ilk],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
target: jugContract.options.address,
|
|
47
|
+
abiItem: jugContract.options.jsonInterface.find(({ name }) => name === 'drip'),
|
|
48
|
+
params: [ilk],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: dogContract.options.address,
|
|
52
|
+
abiItem: dogContract.options.jsonInterface.find(({ name }) => name === 'chop'),
|
|
53
|
+
params: [ilk],
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const multiRes = await multicall(multicallData, web3, network, block);
|
|
58
|
+
|
|
59
|
+
const par = new Dec(multiRes[0][0].toString()).div(1e27).toString();
|
|
60
|
+
const mat = new Dec(multiRes[1][1].toString()).div(1e27).toString();
|
|
61
|
+
const art = new Dec(multiRes[2][0].toString()).toString();
|
|
62
|
+
const rate = new Dec(multiRes[2][1].toString()).toString();
|
|
63
|
+
const spot = new Dec(multiRes[2][2].toString()).div(1e27).toString();
|
|
64
|
+
const line = new Dec(multiRes[2][3].toString()).div(1e45).toString();
|
|
65
|
+
const dust = new Dec(multiRes[2][1].toString()).div(1e45).toString();
|
|
66
|
+
const duty = new Dec(multiRes[3][0].toString()).toString();
|
|
67
|
+
const futureRate = new Dec(multiRes[4][0].toString()).toString();
|
|
68
|
+
const chop = new Dec(multiRes[5][0].toString()).div(1e18).toString();
|
|
69
|
+
|
|
70
|
+
const stabilityFee = new Dec(duty.toString())
|
|
71
|
+
.div(1e27)
|
|
72
|
+
.pow(SECONDS_PER_YEAR)
|
|
73
|
+
.minus(1)
|
|
74
|
+
.mul(100)
|
|
75
|
+
.toNumber();
|
|
76
|
+
const liquidationFee = new Dec(chop).mul(100).sub(100).toString();
|
|
77
|
+
const globalDebtCurrent = new Dec(art).div(1e18).mul(new Dec(futureRate).div(1e27)).toString();
|
|
78
|
+
const globalDebtCeiling = line;
|
|
79
|
+
const creatableDebt = new Dec(globalDebtCeiling).sub(globalDebtCurrent).toString();
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
ilkLabel: bytesToString(ilk),
|
|
83
|
+
currentRate: rate,
|
|
84
|
+
futureRate,
|
|
85
|
+
minDebt: dust,
|
|
86
|
+
globalDebtCurrent,
|
|
87
|
+
globalDebtCeiling,
|
|
88
|
+
assetPrice: new Dec(spot).times(par).times(mat).toString(),
|
|
89
|
+
liqRatio: mat,
|
|
90
|
+
liqPercent: +mat * 100,
|
|
91
|
+
stabilityFee,
|
|
92
|
+
liquidationFee: new Dec(liquidationFee).lt(0) ? '0' : liquidationFee,
|
|
93
|
+
creatableDebt,
|
|
94
|
+
};
|
|
95
95
|
};
|