impermax-sdk 1.0.1 → 1.0.2
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/lib/esm/abis/ImpermaxABI.d.ts +2 -0
- package/lib/esm/abis/ImpermaxABI.js +3 -0
- package/lib/esm/abis/contracts/ClaimAggregator.json +2015 -0
- package/lib/esm/abis/contracts/IBorrowable.json +13207 -0
- package/lib/esm/abis/contracts/IClaimable.json +406 -0
- package/lib/esm/abis/contracts/ICollateral.json +8952 -0
- package/lib/esm/abis/contracts/IERC20.json +2376 -0
- package/lib/esm/abis/contracts/IFactory.json +3660 -0
- package/lib/esm/abis/contracts/IFarmingPool.json +3584 -0
- package/lib/esm/abis/contracts/IMerkleDistributor.json +1134 -0
- package/lib/esm/abis/contracts/IRouter02.json +7283 -0
- package/lib/esm/abis/contracts/ISimpleUniswapOracle.json +1469 -0
- package/lib/esm/abis/contracts/IStakedLPToken.json +7309 -0
- package/lib/esm/abis/contracts/IStakingRewards.json +1036 -0
- package/lib/esm/abis/contracts/IUniswapV2Factory.json +1690 -0
- package/lib/esm/abis/contracts/IUniswapV2Pair.json +6761 -0
- package/lib/esm/abis/contracts/ImpermaxChef.json +20945 -0
- package/lib/esm/config/amms.d.ts +25 -0
- package/lib/esm/config/amms.js +196 -0
- package/lib/esm/config/contracts/claim-aggregators.d.ts +2 -0
- package/lib/esm/config/contracts/claim-aggregators.js +18 -0
- package/lib/esm/config/contracts/impermax-chef.d.ts +2 -0
- package/lib/esm/config/contracts/impermax-chef.js +18 -0
- package/lib/esm/config/contracts/imxes.d.ts +2 -0
- package/lib/esm/config/contracts/imxes.js +18 -0
- package/lib/esm/config/contracts/merkle-distributors.d.ts +4 -0
- package/lib/esm/config/contracts/merkle-distributors.js +13 -0
- package/lib/esm/config/contracts/routers.d.ts +2 -0
- package/lib/esm/config/contracts/routers.js +38 -0
- package/lib/esm/config/contracts/simple-uniswap-oracles.d.ts +2 -0
- package/lib/esm/config/contracts/simple-uniswap-oracles.js +35 -0
- package/lib/esm/config/contracts/weths.d.ts +2 -0
- package/lib/esm/config/contracts/weths.js +19 -0
- package/lib/esm/config/debank-ids.d.ts +2 -0
- package/lib/esm/config/debank-ids.js +17 -0
- package/lib/esm/config/endpoints/merkle-distributors.d.ts +4 -0
- package/lib/esm/config/endpoints/merkle-distributors.js +13 -0
- package/lib/esm/config/eth.d.ts +3 -0
- package/lib/esm/config/eth.js +32 -0
- package/lib/esm/config/factories.d.ts +6 -0
- package/lib/esm/config/factories.js +24 -0
- package/lib/esm/config/farms.d.ts +59 -0
- package/lib/esm/config/farms.js +114 -0
- package/lib/esm/config/general.d.ts +3 -0
- package/lib/esm/config/general.js +8 -0
- package/lib/esm/config/subgraphs.d.ts +5 -0
- package/lib/esm/config/subgraphs.js +68 -0
- package/lib/esm/config/types.d.ts +67 -0
- package/lib/esm/config/types.js +54 -0
- package/lib/esm/impermax-router/Account.d.ts +31 -0
- package/lib/esm/impermax-router/Account.js +154 -0
- package/lib/esm/impermax-router/AccountBorrowable.d.ts +22 -0
- package/lib/esm/impermax-router/AccountBorrowable.js +141 -0
- package/lib/esm/impermax-router/AccountCollateral.d.ts +11 -0
- package/lib/esm/impermax-router/AccountCollateral.js +63 -0
- package/lib/esm/impermax-router/AccountLendingPool.d.ts +57 -0
- package/lib/esm/impermax-router/AccountLendingPool.js +266 -0
- package/lib/esm/impermax-router/AccountPoolToken.d.ts +29 -0
- package/lib/esm/impermax-router/AccountPoolToken.js +89 -0
- package/lib/esm/impermax-router/Borrowable.d.ts +27 -0
- package/lib/esm/impermax-router/Borrowable.js +128 -0
- package/lib/esm/impermax-router/Collateral.d.ts +9 -0
- package/lib/esm/impermax-router/Collateral.js +45 -0
- package/lib/esm/impermax-router/ContractsHelper.d.ts +28 -0
- package/lib/esm/impermax-router/ContractsHelper.js +50 -0
- package/lib/esm/impermax-router/ImpermaxFactory.d.ts +15 -0
- package/lib/esm/impermax-router/ImpermaxFactory.js +42 -0
- package/lib/esm/impermax-router/Interactions.d.ts +16 -0
- package/lib/esm/impermax-router/Interactions.js +105 -0
- package/lib/esm/impermax-router/InteractionsLendingPool.d.ts +43 -0
- package/lib/esm/impermax-router/InteractionsLendingPool.js +124 -0
- package/lib/esm/impermax-router/InteractionsPoolToken.d.ts +23 -0
- package/lib/esm/impermax-router/InteractionsPoolToken.js +194 -0
- package/lib/esm/impermax-router/LendingPool.d.ts +69 -0
- package/lib/esm/impermax-router/LendingPool.js +291 -0
- package/lib/esm/impermax-router/PoolToken.d.ts +36 -0
- package/lib/esm/impermax-router/PoolToken.js +140 -0
- package/lib/esm/impermax-router/index.d.ts +20 -0
- package/lib/esm/impermax-router/index.js +34 -0
- package/lib/esm/impermax-router/interfaces.d.ts +218 -0
- package/lib/esm/impermax-router/interfaces.js +15 -0
- package/{index.ts → lib/esm/index.d.ts} +1 -3
- package/lib/esm/index.js +10 -0
- package/lib/esm/subgraph/Account.d.ts +18 -0
- package/lib/esm/subgraph/Account.js +111 -0
- package/lib/esm/subgraph/AccountLendingPool.d.ts +19 -0
- package/lib/esm/subgraph/AccountLendingPool.js +71 -0
- package/lib/esm/subgraph/AccountPoolToken.d.ts +14 -0
- package/lib/esm/subgraph/AccountPoolToken.js +75 -0
- package/lib/esm/subgraph/LendingPool.d.ts +38 -0
- package/lib/esm/subgraph/LendingPool.js +204 -0
- package/lib/esm/subgraph/PoolToken.d.ts +64 -0
- package/lib/esm/subgraph/PoolToken.js +462 -0
- package/lib/esm/subgraph/PriceHelper.d.ts +21 -0
- package/lib/esm/subgraph/PriceHelper.js +166 -0
- package/lib/esm/subgraph/SolidexHelper.d.ts +16 -0
- package/lib/esm/subgraph/SolidexHelper.js +58 -0
- package/lib/esm/subgraph/index.d.ts +73 -0
- package/lib/esm/subgraph/index.js +185 -0
- package/lib/esm/subgraph/initializer.d.ts +34 -0
- package/lib/esm/subgraph/initializer.js +517 -0
- package/lib/esm/subgraph/query.d.ts +10 -0
- package/lib/esm/subgraph/query.js +229 -0
- package/lib/esm/utils/ether-utils.d.ts +5 -0
- package/lib/esm/utils/ether-utils.js +26 -0
- package/lib/esm/utils/index.d.ts +3 -0
- package/lib/esm/utils/index.js +16 -0
- package/package.json +9 -3
- package/.idea/impermax-sdk.iml +0 -12
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/workspace.xml +0 -642
- package/abis/ImpermaxABI.ts +0 -3
- package/abis/contracts/BAllowance.json +0 -4735
- package/abis/contracts/BDeployer.json +0 -1195
- package/abis/contracts/BInterestRateModel.json +0 -10796
- package/abis/contracts/BSetter.json +0 -6219
- package/abis/contracts/BStorage.json +0 -2613
- package/abis/contracts/Borrowable.json +0 -19937
- package/abis/contracts/CDeployer.json +0 -1104
- package/abis/contracts/CSetter.json +0 -5094
- package/abis/contracts/CStorage.json +0 -516
- package/abis/contracts/ClaimAggregator.json +0 -2015
- package/abis/contracts/Collateral.json +0 -21615
- package/abis/contracts/ERC20.json +0 -819
- package/abis/contracts/Factory.json +0 -21986
- package/abis/contracts/FarmingPool.json +0 -8601
- package/abis/contracts/IBDeployer.json +0 -351
- package/abis/contracts/IBorrowTracker.json +0 -346
- package/abis/contracts/IBorrowable.json +0 -13207
- package/abis/contracts/ICDeployer.json +0 -294
- package/abis/contracts/IClaimable.json +0 -406
- package/abis/contracts/ICollateral.json +0 -8952
- package/abis/contracts/IERC20.json +0 -2376
- package/abis/contracts/IFactory.json +0 -3660
- package/abis/contracts/IFarmingPool.json +0 -3584
- package/abis/contracts/IImpermaxCallee.json +0 -679
- package/abis/contracts/IMerkleDistributor.json +0 -1134
- package/abis/contracts/IPoolToken.json +0 -5343
- package/abis/contracts/IRouter01.json +0 -6891
- package/abis/contracts/IRouter02.json +0 -7283
- package/abis/contracts/ISimpleUniswapOracle.json +0 -1469
- package/abis/contracts/IStakedLPToken.json +0 -7309
- package/abis/contracts/IStakingRewards.json +0 -1036
- package/abis/contracts/IUniswapV2Callee.json +0 -403
- package/abis/contracts/IUniswapV2ERC20.json +0 -3155
- package/abis/contracts/IUniswapV2Factory.json +0 -1690
- package/abis/contracts/IUniswapV2Pair.json +0 -6761
- package/abis/contracts/IWETH.json +0 -561
- package/abis/contracts/ImpermaxChef.json +0 -20945
- package/abis/contracts/ImpermaxERC20.json +0 -12095
- package/abis/contracts/Math.json +0 -1966
- package/abis/contracts/MockERC20.json +0 -8884
- package/abis/contracts/PoolToken.json +0 -10784
- package/abis/contracts/Router01.json +0 -43963
- package/abis/contracts/SafeMath.json +0 -6828
- package/abis/contracts/SimpleUniswapOracle.json +0 -9640
- package/abis/contracts/TransferHelper.json +0 -4875
- package/abis/contracts/UQ112x112.json +0 -1201
- package/abis/contracts/UniswapV2ERC20.json +0 -10969
- package/abis/contracts/UniswapV2Factory.json +0 -5521
- package/abis/contracts/UniswapV2Library.json +0 -13789
- package/abis/contracts/UniswapV2Pair.json +0 -30782
- package/abis/contracts/WETH9.json +0 -6613
- package/config/amms.ts +0 -199
- package/config/contracts/claim-aggregators.ts +0 -16
- package/config/contracts/impermax-chef.ts +0 -16
- package/config/contracts/imxes.ts +0 -16
- package/config/contracts/merkle-distributors.ts +0 -13
- package/config/contracts/routers.ts +0 -36
- package/config/contracts/simple-uniswap-oracles.ts +0 -33
- package/config/contracts/weths.ts +0 -18
- package/config/debank-ids.ts +0 -15
- package/config/endpoints/merkle-distributors.ts +0 -13
- package/config/eth.ts +0 -32
- package/config/factories.ts +0 -26
- package/config/farms.ts +0 -119
- package/config/general.ts +0 -8
- package/config/subgraphs.ts +0 -69
- package/config/types.ts +0 -81
- package/impermax-router/Account.ts +0 -123
- package/impermax-router/AccountBorrowable.ts +0 -110
- package/impermax-router/AccountCollateral.ts +0 -40
- package/impermax-router/AccountLendingPool.ts +0 -231
- package/impermax-router/AccountPoolToken.ts +0 -76
- package/impermax-router/Borrowable.ts +0 -86
- package/impermax-router/Collateral.ts +0 -26
- package/impermax-router/ContractsHelper.ts +0 -64
- package/impermax-router/ImpermaxFactory.ts +0 -47
- package/impermax-router/Interactions.ts +0 -94
- package/impermax-router/InteractionsLendingPool.ts +0 -129
- package/impermax-router/InteractionsPoolToken.ts +0 -187
- package/impermax-router/LendingPool.ts +0 -256
- package/impermax-router/PoolToken.ts +0 -112
- package/impermax-router/index.ts +0 -49
- package/impermax-router/interfaces.ts +0 -233
- package/subgraph/Account.ts +0 -93
- package/subgraph/AccountLendingPool.ts +0 -60
- package/subgraph/AccountPoolToken.ts +0 -60
- package/subgraph/LendingPool.ts +0 -179
- package/subgraph/PoolToken.ts +0 -381
- package/subgraph/PriceHelper.ts +0 -150
- package/subgraph/SolidexHelper.ts +0 -54
- package/subgraph/index.ts +0 -166
- package/subgraph/initializer.ts +0 -509
- package/subgraph/query.ts +0 -224
- package/tsconfig.json +0 -16
- package/utils/ether-utils.ts +0 -22
- package/utils/index.ts +0 -12
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ximxQuery = exports.userQuery = exports.tvlQuery = exports.currentVolumeAndReservesQuery = exports.pastVolumeQuery = exports.impermaxChefQuery = exports.lendingPoolsPastQuery = exports.lendingPoolsQuery = exports.blockQuery = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const factories_1 = require("../config/factories");
|
|
9
|
+
function blockQuery(timestamp) {
|
|
10
|
+
return (0, graphql_tag_1.default) `{
|
|
11
|
+
blocks (first: 1, orderBy: timestamp, orderDirection: desc, where: { timestamp_gt: ${timestamp}, timestamp_lt: ${timestamp + 600} }) {
|
|
12
|
+
number
|
|
13
|
+
}
|
|
14
|
+
_meta {
|
|
15
|
+
block {
|
|
16
|
+
number
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}`;
|
|
20
|
+
}
|
|
21
|
+
exports.blockQuery = blockQuery;
|
|
22
|
+
function lendingPoolsQuery(factory, addressesFilter) {
|
|
23
|
+
const tokenStr = `{
|
|
24
|
+
id
|
|
25
|
+
symbol
|
|
26
|
+
name
|
|
27
|
+
decimals
|
|
28
|
+
derivedUSD
|
|
29
|
+
}`;
|
|
30
|
+
const distributorStr = `{
|
|
31
|
+
id
|
|
32
|
+
}`;
|
|
33
|
+
const farmingPoolStr = `{
|
|
34
|
+
epochAmount
|
|
35
|
+
epochBegin
|
|
36
|
+
segmentLength
|
|
37
|
+
vestingBegin
|
|
38
|
+
sharePercentage
|
|
39
|
+
distributor ${distributorStr}
|
|
40
|
+
}`;
|
|
41
|
+
const borrowableStr = `{
|
|
42
|
+
id
|
|
43
|
+
underlying ${tokenStr}
|
|
44
|
+
totalBalance
|
|
45
|
+
totalBorrows
|
|
46
|
+
borrowRate
|
|
47
|
+
reserveFactor
|
|
48
|
+
kinkBorrowRate
|
|
49
|
+
kinkUtilizationRate
|
|
50
|
+
borrowIndex
|
|
51
|
+
accrualTimestamp
|
|
52
|
+
exchangeRate
|
|
53
|
+
totalBalanceUSD
|
|
54
|
+
totalSupplyUSD
|
|
55
|
+
totalBorrowsUSD
|
|
56
|
+
farmingPool ${farmingPoolStr}
|
|
57
|
+
}`;
|
|
58
|
+
const collateralStr = `{
|
|
59
|
+
id
|
|
60
|
+
totalBalance
|
|
61
|
+
totalBalanceUSD
|
|
62
|
+
safetyMargin
|
|
63
|
+
liquidationIncentive
|
|
64
|
+
${factories_1.LIQUIDATION_FEE_FACTORIES.includes(factory) ? "liquidationFee" : ""}
|
|
65
|
+
exchangeRate
|
|
66
|
+
}`;
|
|
67
|
+
const pairStr = `{
|
|
68
|
+
factory
|
|
69
|
+
reserve0
|
|
70
|
+
reserve1
|
|
71
|
+
totalSupply
|
|
72
|
+
reserveUSD
|
|
73
|
+
token0Price
|
|
74
|
+
token1Price
|
|
75
|
+
derivedUSD
|
|
76
|
+
uniswapV2PairAddress
|
|
77
|
+
uniswapV2Factory
|
|
78
|
+
isStakedLPToken
|
|
79
|
+
exchangeRate
|
|
80
|
+
stakingRewards
|
|
81
|
+
masterChef
|
|
82
|
+
pid
|
|
83
|
+
stakedTotalSupply
|
|
84
|
+
rewards {
|
|
85
|
+
id
|
|
86
|
+
rewardRate
|
|
87
|
+
rewardsToken ${tokenStr}
|
|
88
|
+
periodFinish
|
|
89
|
+
}
|
|
90
|
+
}`;
|
|
91
|
+
const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
|
|
92
|
+
return (0, graphql_tag_1.default) `{
|
|
93
|
+
lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc ${id_in_string}) {
|
|
94
|
+
id
|
|
95
|
+
borrowable0 ${borrowableStr}
|
|
96
|
+
borrowable1 ${borrowableStr}
|
|
97
|
+
collateral ${collateralStr}
|
|
98
|
+
pair ${pairStr}
|
|
99
|
+
}
|
|
100
|
+
_meta {
|
|
101
|
+
block {
|
|
102
|
+
number
|
|
103
|
+
}
|
|
104
|
+
hasIndexingErrors
|
|
105
|
+
}
|
|
106
|
+
}`;
|
|
107
|
+
}
|
|
108
|
+
exports.lendingPoolsQuery = lendingPoolsQuery;
|
|
109
|
+
function lendingPoolsPastQuery(blockNumber, addressesFilter) {
|
|
110
|
+
const borrowablePastStr = `{
|
|
111
|
+
borrowIndex
|
|
112
|
+
accrualTimestamp
|
|
113
|
+
exchangeRate
|
|
114
|
+
}`;
|
|
115
|
+
const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
|
|
116
|
+
return (0, graphql_tag_1.default) `{
|
|
117
|
+
lendingPools(first: 1000, orderBy: totalBorrowsUSD, orderDirection: desc, block: {number: ${blockNumber}} ${id_in_string}) {
|
|
118
|
+
id
|
|
119
|
+
borrowable0 ${borrowablePastStr}
|
|
120
|
+
borrowable1 ${borrowablePastStr}
|
|
121
|
+
}
|
|
122
|
+
}`;
|
|
123
|
+
}
|
|
124
|
+
exports.lendingPoolsPastQuery = lendingPoolsPastQuery;
|
|
125
|
+
function impermaxChefQuery() {
|
|
126
|
+
return (0, graphql_tag_1.default) `{
|
|
127
|
+
impermaxChefs(first: 1) {
|
|
128
|
+
id
|
|
129
|
+
rewardToken
|
|
130
|
+
rewardPerSec
|
|
131
|
+
totalAllocPoint
|
|
132
|
+
}
|
|
133
|
+
pools(first: 1000) {
|
|
134
|
+
id
|
|
135
|
+
allocPoint
|
|
136
|
+
rewarder {id}
|
|
137
|
+
}
|
|
138
|
+
impermaxRewarders(first: 1000) {
|
|
139
|
+
rewardToken
|
|
140
|
+
rewardPerSec
|
|
141
|
+
totalAllocPoint
|
|
142
|
+
pools(first: 1000) {
|
|
143
|
+
borrowable
|
|
144
|
+
allocPoint
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}`;
|
|
148
|
+
}
|
|
149
|
+
exports.impermaxChefQuery = impermaxChefQuery;
|
|
150
|
+
function pastVolumeQuery(blockNumber, addressesFilter) {
|
|
151
|
+
const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
|
|
152
|
+
return (0, graphql_tag_1.default) `{
|
|
153
|
+
pairs (block: {number: ${blockNumber}} ${id_in_string}) {
|
|
154
|
+
id
|
|
155
|
+
volumeUSD
|
|
156
|
+
}
|
|
157
|
+
}`;
|
|
158
|
+
}
|
|
159
|
+
exports.pastVolumeQuery = pastVolumeQuery;
|
|
160
|
+
function currentVolumeAndReservesQuery(addressesFilter) {
|
|
161
|
+
const id_in_string = addressesFilter.length > 0 ? `where: {id_in: ["${addressesFilter.join('","').toLowerCase()}"]}` : "";
|
|
162
|
+
return (0, graphql_tag_1.default) `{
|
|
163
|
+
pairs (${id_in_string}) {
|
|
164
|
+
id
|
|
165
|
+
reserveUSD
|
|
166
|
+
volumeUSD
|
|
167
|
+
}
|
|
168
|
+
}`;
|
|
169
|
+
}
|
|
170
|
+
exports.currentVolumeAndReservesQuery = currentVolumeAndReservesQuery;
|
|
171
|
+
function tvlQuery() {
|
|
172
|
+
return (0, graphql_tag_1.default) `{
|
|
173
|
+
impermaxFactories(first: 1) {
|
|
174
|
+
totalBalanceUSD
|
|
175
|
+
totalSupplyUSD
|
|
176
|
+
totalBorrowsUSD
|
|
177
|
+
}
|
|
178
|
+
}`;
|
|
179
|
+
}
|
|
180
|
+
exports.tvlQuery = tvlQuery;
|
|
181
|
+
function userQuery(account) {
|
|
182
|
+
return (0, graphql_tag_1.default) `{
|
|
183
|
+
user(id: "${account.toLowerCase()}") {
|
|
184
|
+
collateralPositions(first:1000) {
|
|
185
|
+
balance
|
|
186
|
+
collateral {
|
|
187
|
+
lendingPool {
|
|
188
|
+
id
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
supplyPositions(first:1000) {
|
|
193
|
+
balance
|
|
194
|
+
borrowable {
|
|
195
|
+
underlying {
|
|
196
|
+
id
|
|
197
|
+
}
|
|
198
|
+
lendingPool {
|
|
199
|
+
id
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
borrowPositions(first:1000) {
|
|
204
|
+
borrowBalance
|
|
205
|
+
borrowIndex
|
|
206
|
+
borrowable {
|
|
207
|
+
underlying {
|
|
208
|
+
id
|
|
209
|
+
}
|
|
210
|
+
lendingPool {
|
|
211
|
+
id
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}`;
|
|
217
|
+
}
|
|
218
|
+
exports.userQuery = userQuery;
|
|
219
|
+
function ximxQuery() {
|
|
220
|
+
return (0, graphql_tag_1.default) `{
|
|
221
|
+
ximxes(first: 1) {
|
|
222
|
+
totalSupply
|
|
223
|
+
totalBalance
|
|
224
|
+
exchangeRate
|
|
225
|
+
dailyAPR
|
|
226
|
+
}
|
|
227
|
+
}`;
|
|
228
|
+
}
|
|
229
|
+
exports.ximxQuery = ximxQuery;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
export declare function balanceToDecimal(s: string): string;
|
|
3
|
+
export declare function formatToDecimals(n: number, decimals?: number): string;
|
|
4
|
+
export declare function decimalToBalance(d: string | number, decimals?: number): BigNumber;
|
|
5
|
+
export declare function address(n: number): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.address = exports.decimalToBalance = exports.formatToDecimals = exports.balanceToDecimal = void 0;
|
|
4
|
+
const utils_1 = require("ethers/lib/utils");
|
|
5
|
+
function balanceToDecimal(s) {
|
|
6
|
+
return (0, utils_1.formatUnits)(s);
|
|
7
|
+
}
|
|
8
|
+
exports.balanceToDecimal = balanceToDecimal;
|
|
9
|
+
function formatToDecimals(n, decimals = 2) {
|
|
10
|
+
if (n === null || n === undefined || isNaN(n))
|
|
11
|
+
return "-";
|
|
12
|
+
if (n == Infinity)
|
|
13
|
+
return "Infinity"; //return "∞";
|
|
14
|
+
return (Math.round(n * (Math.pow(10, decimals))) / (Math.pow(10, decimals))).toFixed(decimals);
|
|
15
|
+
}
|
|
16
|
+
exports.formatToDecimals = formatToDecimals;
|
|
17
|
+
function decimalToBalance(d, decimals = 18) {
|
|
18
|
+
const n = parseFloat(d.toString());
|
|
19
|
+
const s = formatToDecimals(Math.max(n, 0), decimals);
|
|
20
|
+
return (0, utils_1.parseUnits)(s, decimals);
|
|
21
|
+
}
|
|
22
|
+
exports.decimalToBalance = decimalToBalance;
|
|
23
|
+
function address(n) {
|
|
24
|
+
return `0x${n.toString(16).padStart(40, '0')}`;
|
|
25
|
+
}
|
|
26
|
+
exports.address = address;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidNumber = exports.impermanentLoss = exports.toAPR = void 0;
|
|
4
|
+
function toAPR(n) {
|
|
5
|
+
const SECONDS_IN_YEAR = 365 * 24 * 3600;
|
|
6
|
+
return n * SECONDS_IN_YEAR;
|
|
7
|
+
}
|
|
8
|
+
exports.toAPR = toAPR;
|
|
9
|
+
function impermanentLoss(priceSwing) {
|
|
10
|
+
return Math.sqrt(priceSwing) / (priceSwing + 1) * 2;
|
|
11
|
+
}
|
|
12
|
+
exports.impermanentLoss = impermanentLoss;
|
|
13
|
+
function isValidNumber(n) {
|
|
14
|
+
return !(n === null || n === undefined || isNaN(n));
|
|
15
|
+
}
|
|
16
|
+
exports.isValidNumber = isValidNumber;
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impermax-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"tsc": "tsc -p tsconfig.json",
|
|
13
|
+
"prepublish": "npm run tsc"
|
|
8
14
|
},
|
|
9
15
|
"author": "",
|
|
10
16
|
"license": "ISC",
|
package/.idea/impermax-sdk.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/impermax-sdk.iml" filepath="$PROJECT_DIR$/.idea/impermax-sdk.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|