impermax-sdk 1.0.1 → 1.0.3

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