impermax-sdk 1.0.3 → 1.0.4

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 (108) hide show
  1. package/lib/abis/ImpermaxABI.d.ts +2 -0
  2. package/lib/abis/ImpermaxABI.js +3 -0
  3. package/lib/abis/contracts/ClaimAggregator.json +2015 -0
  4. package/lib/abis/contracts/IBorrowable.json +13207 -0
  5. package/lib/abis/contracts/IClaimable.json +406 -0
  6. package/lib/abis/contracts/ICollateral.json +8952 -0
  7. package/lib/abis/contracts/IERC20.json +2376 -0
  8. package/lib/abis/contracts/IFactory.json +3660 -0
  9. package/lib/abis/contracts/IFarmingPool.json +3584 -0
  10. package/lib/abis/contracts/IMerkleDistributor.json +1134 -0
  11. package/lib/abis/contracts/IRouter02.json +7283 -0
  12. package/lib/abis/contracts/ISimpleUniswapOracle.json +1469 -0
  13. package/lib/abis/contracts/IStakedLPToken.json +7309 -0
  14. package/lib/abis/contracts/IStakingRewards.json +1036 -0
  15. package/lib/abis/contracts/IUniswapV2Factory.json +1690 -0
  16. package/lib/abis/contracts/IUniswapV2Pair.json +6761 -0
  17. package/lib/abis/contracts/ImpermaxChef.json +20945 -0
  18. package/lib/config/amms.d.ts +25 -0
  19. package/lib/config/amms.js +196 -0
  20. package/lib/config/contracts/claim-aggregators.d.ts +2 -0
  21. package/lib/config/contracts/claim-aggregators.js +18 -0
  22. package/lib/config/contracts/impermax-chef.d.ts +2 -0
  23. package/lib/config/contracts/impermax-chef.js +18 -0
  24. package/lib/config/contracts/imxes.d.ts +2 -0
  25. package/lib/config/contracts/imxes.js +18 -0
  26. package/lib/config/contracts/merkle-distributors.d.ts +4 -0
  27. package/lib/config/contracts/merkle-distributors.js +13 -0
  28. package/lib/config/contracts/routers.d.ts +2 -0
  29. package/lib/config/contracts/routers.js +38 -0
  30. package/lib/config/contracts/simple-uniswap-oracles.d.ts +2 -0
  31. package/lib/config/contracts/simple-uniswap-oracles.js +35 -0
  32. package/lib/config/contracts/weths.d.ts +2 -0
  33. package/lib/config/contracts/weths.js +19 -0
  34. package/lib/config/debank-ids.d.ts +2 -0
  35. package/lib/config/debank-ids.js +17 -0
  36. package/lib/config/endpoints/merkle-distributors.d.ts +4 -0
  37. package/lib/config/endpoints/merkle-distributors.js +13 -0
  38. package/lib/config/eth.d.ts +3 -0
  39. package/lib/config/eth.js +32 -0
  40. package/lib/config/factories.d.ts +6 -0
  41. package/lib/config/factories.js +24 -0
  42. package/lib/config/farms.d.ts +59 -0
  43. package/lib/config/farms.js +114 -0
  44. package/lib/config/general.d.ts +3 -0
  45. package/lib/config/general.js +8 -0
  46. package/lib/config/subgraphs.d.ts +5 -0
  47. package/lib/config/subgraphs.js +68 -0
  48. package/lib/config/types.d.ts +67 -0
  49. package/lib/config/types.js +54 -0
  50. package/lib/impermax-router/Account.d.ts +31 -0
  51. package/lib/impermax-router/Account.js +154 -0
  52. package/lib/impermax-router/AccountBorrowable.d.ts +22 -0
  53. package/lib/impermax-router/AccountBorrowable.js +141 -0
  54. package/lib/impermax-router/AccountCollateral.d.ts +11 -0
  55. package/lib/impermax-router/AccountCollateral.js +63 -0
  56. package/lib/impermax-router/AccountLendingPool.d.ts +57 -0
  57. package/lib/impermax-router/AccountLendingPool.js +266 -0
  58. package/lib/impermax-router/AccountPoolToken.d.ts +29 -0
  59. package/lib/impermax-router/AccountPoolToken.js +89 -0
  60. package/lib/impermax-router/Borrowable.d.ts +27 -0
  61. package/lib/impermax-router/Borrowable.js +128 -0
  62. package/lib/impermax-router/Collateral.d.ts +9 -0
  63. package/lib/impermax-router/Collateral.js +45 -0
  64. package/lib/impermax-router/ContractsHelper.d.ts +28 -0
  65. package/lib/impermax-router/ContractsHelper.js +50 -0
  66. package/lib/impermax-router/ImpermaxFactory.d.ts +15 -0
  67. package/lib/impermax-router/ImpermaxFactory.js +42 -0
  68. package/lib/impermax-router/Interactions.d.ts +16 -0
  69. package/lib/impermax-router/Interactions.js +105 -0
  70. package/lib/impermax-router/InteractionsLendingPool.d.ts +43 -0
  71. package/lib/impermax-router/InteractionsLendingPool.js +124 -0
  72. package/lib/impermax-router/InteractionsPoolToken.d.ts +23 -0
  73. package/lib/impermax-router/InteractionsPoolToken.js +194 -0
  74. package/lib/impermax-router/LendingPool.d.ts +69 -0
  75. package/lib/impermax-router/LendingPool.js +291 -0
  76. package/lib/impermax-router/PoolToken.d.ts +36 -0
  77. package/lib/impermax-router/PoolToken.js +140 -0
  78. package/lib/impermax-router/index.d.ts +20 -0
  79. package/lib/impermax-router/index.js +34 -0
  80. package/lib/impermax-router/interfaces.d.ts +218 -0
  81. package/lib/impermax-router/interfaces.js +15 -0
  82. package/lib/index.d.ts +3 -0
  83. package/lib/index.js +10 -0
  84. package/lib/subgraph/Account.d.ts +18 -0
  85. package/lib/subgraph/Account.js +111 -0
  86. package/lib/subgraph/AccountLendingPool.d.ts +19 -0
  87. package/lib/subgraph/AccountLendingPool.js +71 -0
  88. package/lib/subgraph/AccountPoolToken.d.ts +14 -0
  89. package/lib/subgraph/AccountPoolToken.js +75 -0
  90. package/lib/subgraph/LendingPool.d.ts +38 -0
  91. package/lib/subgraph/LendingPool.js +204 -0
  92. package/lib/subgraph/PoolToken.d.ts +64 -0
  93. package/lib/subgraph/PoolToken.js +462 -0
  94. package/lib/subgraph/PriceHelper.d.ts +21 -0
  95. package/lib/subgraph/PriceHelper.js +166 -0
  96. package/lib/subgraph/SolidexHelper.d.ts +16 -0
  97. package/lib/subgraph/SolidexHelper.js +58 -0
  98. package/lib/subgraph/index.d.ts +73 -0
  99. package/lib/subgraph/index.js +185 -0
  100. package/lib/subgraph/initializer.d.ts +34 -0
  101. package/lib/subgraph/initializer.js +517 -0
  102. package/lib/subgraph/query.d.ts +10 -0
  103. package/lib/subgraph/query.js +229 -0
  104. package/lib/utils/ether-utils.d.ts +5 -0
  105. package/lib/utils/ether-utils.js +26 -0
  106. package/lib/utils/index.d.ts +3 -0
  107. package/lib/utils/index.js +16 -0
  108. package/package.json +2 -2
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFarmByStakedLPFactory = exports.STAKED_LP_FACTORY = exports.hrFarms = exports.Farms = void 0;
4
+ const types_1 = require("./types");
5
+ var Farms;
6
+ (function (Farms) {
7
+ Farms["quickswapOld"] = "quickswapOld";
8
+ Farms["quickswap"] = "quickswap";
9
+ Farms["quickswapDual"] = "quickswapDual";
10
+ Farms["sushiswap"] = "sushiswap";
11
+ Farms["arbinyan"] = "arbinyan";
12
+ Farms["swapr"] = "swapr";
13
+ Farms["swapfish"] = "swapfish";
14
+ Farms["zyberswap"] = "zyberswap";
15
+ Farms["radiant"] = "";
16
+ Farms["plutusDao"] = "";
17
+ Farms["pangolin"] = "pangolin";
18
+ Farms["pangolinV2"] = "pangolinV2";
19
+ Farms["traderJoeV2"] = "traderJoeV2";
20
+ Farms["traderJoeV3"] = "traderJoeV3";
21
+ Farms["traderJoeV4"] = "traderJoeV4";
22
+ Farms["solarbeam"] = "solarbeam";
23
+ Farms["solarbeam2"] = "solarbeam2";
24
+ Farms["thorus"] = "thorus";
25
+ Farms["tetuswap"] = "tetuswap";
26
+ Farms["solidex"] = "solidex";
27
+ Farms["solidexB"] = "solidexB";
28
+ Farms["solidexUSDC"] = "solidexUSDC";
29
+ Farms["solidexUSDCB"] = "solidexUSDCB";
30
+ Farms["oxdao"] = "oxdao";
31
+ })(Farms = exports.Farms || (exports.Farms = {}));
32
+ exports.hrFarms = {
33
+ [Farms.quickswapOld]: 'QuickSwap',
34
+ [Farms.quickswap]: 'QuickSwap',
35
+ [Farms.quickswapDual]: 'QuickSwap',
36
+ [Farms.sushiswap]: 'SushiSwap',
37
+ [Farms.arbinyan]: 'ArbyNYAN',
38
+ [Farms.swapr]: 'Swapr',
39
+ [Farms.swapfish]: 'SwapFish',
40
+ [Farms.zyberswap]: 'ZyberSwap',
41
+ [Farms.radiant]: 'Radiant',
42
+ [Farms.plutusDao]: 'Plutus DAO',
43
+ [Farms.pangolin]: 'Pangolin',
44
+ [Farms.pangolinV2]: 'Pangolin',
45
+ [Farms.traderJoeV2]: 'TraderJoe',
46
+ [Farms.traderJoeV3]: 'TraderJoe',
47
+ [Farms.traderJoeV4]: 'TraderJoe',
48
+ [Farms.solarbeam]: 'Solarbeam',
49
+ [Farms.solarbeam2]: 'Solarbeam',
50
+ [Farms.thorus]: 'Thorus',
51
+ [Farms.tetuswap]: 'TetuSwap',
52
+ [Farms.solidex]: 'Solidex',
53
+ [Farms.solidexB]: 'Solidex',
54
+ [Farms.solidexUSDC]: 'Solidex',
55
+ [Farms.solidexUSDCB]: 'Solidex',
56
+ [Farms.oxdao]: '0xDAO',
57
+ };
58
+ exports.STAKED_LP_FACTORY = {
59
+ [types_1.Networks.Ropsten]: {},
60
+ [types_1.Networks.Mainnet]: {},
61
+ [types_1.Networks.Polygon]: {
62
+ [Farms.quickswapOld]: '0xF47B652cDE9b30D6aDd0b13027Bb7AD2F7AF04f4',
63
+ [Farms.quickswap]: '0x846019FB6f136fC98b80e527C3d34F39D16a38c4',
64
+ [Farms.quickswapDual]: '0xC4505Cc6125d61E2A352ce5cf2129f2fb19259a8',
65
+ [Farms.sushiswap]: '0xcb30A66e72Ed90D1b34f78fc0655895FC28bB6CF',
66
+ [Farms.tetuswap]: '0x8E45622663Bb01dc285B4F51Eb8F9FE4fa7b5899',
67
+ },
68
+ [types_1.Networks.Arbitrum]: {
69
+ [Farms.arbinyan]: '0x6659a9c5cD313974343E30b4fDfFD95bD4b4dCd2',
70
+ [Farms.sushiswap]: '0x270250F59C1ffA06C9e3234D528858Ff59aFCE68',
71
+ [Farms.swapr]: '0x5643C3aCEC0D4970a385fb9Cc1555bec1d912bb8',
72
+ //[Farms.swapfish]: '0xcDAeC65495Fa5c0545c5a405224214e3594f30d8',
73
+ [Farms.swapfish]: '0x3bE7B59Ab6558845FfA1f026Dff40b305dd47b37',
74
+ [Farms.zyberswap]: '0xBCE93e2D822CfDD70F106e32FCB266457cece45F',
75
+ [Farms.radiant]: '0x4aE11dC7D7e70eE16d7eaE32851302e55f6CA85e',
76
+ [Farms.plutusDao]: '0x4dC48B93855F42cCcc54f65615AeF6FFC12EC1DF',
77
+ },
78
+ [types_1.Networks.Avalanche]: {
79
+ [Farms.pangolin]: '0xBB92270716C8c424849F17cCc12F4F24AD4064D6',
80
+ [Farms.pangolinV2]: '0xC596f6455054D8cdDE627096bE671e377791E295',
81
+ [Farms.traderJoeV2]: '0x16ED59ffbfbe62ebA9a69a304D38901F86461282',
82
+ [Farms.traderJoeV3]: '0x58Fde5bdB2C6Bd828Bc41c12a68189C7cd93dCE2',
83
+ [Farms.traderJoeV4]: '0xbc1bb900e34adbb99957672361433c6ad62a0cac',
84
+ [Farms.thorus]: '0x9141B3d02443a84793794f661Ae1e6607A03A201',
85
+ },
86
+ [types_1.Networks.Moonriver]: {
87
+ [Farms.sushiswap]: '0xBB92270716C8c424849F17cCc12F4F24AD4064D6',
88
+ [Farms.solarbeam]: '0x95887654d8646c26fab33f344576e2e74b211256',
89
+ [Farms.solarbeam2]: '0x23bdECdB7073D5f899708f33FCaFff787b81e287',
90
+ },
91
+ [types_1.Networks.Aurora]: {},
92
+ [types_1.Networks.Cronos]: {},
93
+ [types_1.Networks.Fantom]: {
94
+ [Farms.solidex]: '0x95887654d8646C26fAb33F344576E2E74b211256',
95
+ [Farms.solidexB]: '0x8610Dc1912a55761a713D827a1a1ad131bE8f579',
96
+ [Farms.solidexUSDC]: '0xF14f98E6F34C12Bd74fcEAC1668aF749fc269cFf',
97
+ [Farms.solidexUSDCB]: '0x9B1434a02Ee86302d463bB6B365EbdFAc56e067A',
98
+ [Farms.oxdao]: '0xB83D21F60B73B21506c69DEcdBcF7Ab5AB737eB2',
99
+ },
100
+ [types_1.Networks.Harmony]: {},
101
+ [types_1.Networks.Moonbeam]: {},
102
+ [types_1.Networks.Sxnetwork]: {},
103
+ };
104
+ function getFarmByStakedLPFactory(network, address) {
105
+ if (!address)
106
+ return null;
107
+ for (const farm of Object.keys(Farms)) {
108
+ if (exports.STAKED_LP_FACTORY[network][farm] &&
109
+ address.toLowerCase() == exports.STAKED_LP_FACTORY[network][farm].toLowerCase())
110
+ return farm;
111
+ }
112
+ return null;
113
+ }
114
+ exports.getFarmByStakedLPFactory = getFarmByStakedLPFactory;
@@ -0,0 +1,3 @@
1
+ import { BigNumber } from 'ethers';
2
+ export declare const NOT_SYNCED = false;
3
+ export declare const DEADLINE: BigNumber;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEADLINE = exports.NOT_SYNCED = void 0;
4
+ const ethers_1 = require("ethers");
5
+ exports.NOT_SYNCED = false;
6
+ exports.DEADLINE = ethers_1.BigNumber.from(Math.floor(Date.now() / 1000) + 3600 * 24 * 365); //1 year deadline
7
+ const ZERO = ethers_1.ethers.constants.Zero;
8
+ const APPROVE_AMOUNT = ethers_1.ethers.constants.MaxUint256;
@@ -0,0 +1,5 @@
1
+ import { Address, NetworkFactoryIndex, NetworkIndex } from './types';
2
+ export declare const IMPERMAX_SUBGRAPH_URL: NetworkFactoryIndex<Address>;
3
+ export declare const IMPERMAX_CHEF_SUBGRAPH_URL: NetworkIndex<string>;
4
+ export declare const BLOCKS_SUBGRAPH_URL: NetworkIndex<string>;
5
+ export declare const XIMX_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/impermax-finance/imx-staking";
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XIMX_SUBGRAPH_URL = exports.BLOCKS_SUBGRAPH_URL = exports.IMPERMAX_CHEF_SUBGRAPH_URL = exports.IMPERMAX_SUBGRAPH_URL = void 0;
4
+ const types_1 = require("./types");
5
+ exports.IMPERMAX_SUBGRAPH_URL = {
6
+ [types_1.Networks.Ropsten]: {
7
+ [types_1.Factory.V2V1]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-ropsten'
8
+ },
9
+ [types_1.Networks.Mainnet]: {
10
+ [types_1.Factory.V2V1]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap1'
11
+ },
12
+ [types_1.Networks.Polygon]: {
13
+ [types_1.Factory.V2V1_1]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-polygon',
14
+ [types_1.Factory.V2V2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-polygon-v2',
15
+ },
16
+ [types_1.Networks.Arbitrum]: {
17
+ [types_1.Factory.V2V1_1]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-arbitrum',
18
+ [types_1.Factory.V2V2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-arbitrum-v2',
19
+ //[F.V2V1_1]: 'https://api.impermax.finance/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-arbitrum02'
20
+ },
21
+ [types_1.Networks.Avalanche]: {
22
+ [types_1.Factory.V2V1_2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-avalanche1',
23
+ [types_1.Factory.V2V2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-avalanche-v2',
24
+ },
25
+ [types_1.Networks.Moonriver]: {
26
+ [types_1.Factory.V2V1_2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-moonriver'
27
+ },
28
+ [types_1.Networks.Aurora]: {
29
+ [types_1.Factory.V2V1_2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-aurora'
30
+ },
31
+ [types_1.Networks.Cronos]: {},
32
+ [types_1.Networks.Fantom]: {
33
+ [types_1.Factory.SOLV1_2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-fantom',
34
+ //[Factory.SOLV2]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-x-uniswap-v2-fantom-v2',
35
+ },
36
+ [types_1.Networks.Harmony]: {},
37
+ [types_1.Networks.Moonbeam]: {},
38
+ [types_1.Networks.Sxnetwork]: {},
39
+ };
40
+ exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
41
+ [types_1.Networks.Ropsten]: '',
42
+ [types_1.Networks.Mainnet]: '',
43
+ [types_1.Networks.Polygon]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-polygon',
44
+ [types_1.Networks.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-arbitrum',
45
+ [types_1.Networks.Avalanche]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-avalanche',
46
+ [types_1.Networks.Moonriver]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-moonriver',
47
+ [types_1.Networks.Fantom]: 'https://api.thegraph.com/subgraphs/name/impermax-finance/impermax-chef-fantom',
48
+ [types_1.Networks.Aurora]: '',
49
+ [types_1.Networks.Cronos]: '',
50
+ [types_1.Networks.Harmony]: '',
51
+ [types_1.Networks.Moonbeam]: '',
52
+ [types_1.Networks.Sxnetwork]: '',
53
+ };
54
+ exports.BLOCKS_SUBGRAPH_URL = {
55
+ [types_1.Networks.Ropsten]: '',
56
+ [types_1.Networks.Mainnet]: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks',
57
+ [types_1.Networks.Polygon]: 'https://api.thegraph.com/subgraphs/name/matthewlilley/polygon-blocks',
58
+ [types_1.Networks.Arbitrum]: 'https://api.thegraph.com/subgraphs/name/sushiswap/arbitrum-blocks',
59
+ [types_1.Networks.Avalanche]: 'https://api.thegraph.com/subgraphs/name/dasconnor/avalanche-blocks',
60
+ [types_1.Networks.Moonriver]: 'https://api.thegraph.com/subgraphs/name/sushiswap/moonriver-blocks',
61
+ [types_1.Networks.Aurora]: '',
62
+ [types_1.Networks.Cronos]: '',
63
+ [types_1.Networks.Fantom]: 'https://api.thegraph.com/subgraphs/name/matthewlilley/fantom-blocks',
64
+ [types_1.Networks.Harmony]: '',
65
+ [types_1.Networks.Moonbeam]: '',
66
+ [types_1.Networks.Sxnetwork]: '',
67
+ };
68
+ exports.XIMX_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/impermax-finance/imx-staking";
@@ -0,0 +1,67 @@
1
+ export declare enum Networks {
2
+ Ropsten = "ropsten",
3
+ Mainnet = "mainnet",
4
+ Polygon = "polygon",
5
+ Arbitrum = "arbitrum",
6
+ Avalanche = "avalanche",
7
+ Moonriver = "moonriver",
8
+ Aurora = "aurora",
9
+ Cronos = "cronos",
10
+ Fantom = "fantom",
11
+ Harmony = "harmony",
12
+ Moonbeam = "moonbeam",
13
+ Sxnetwork = "sxnetwork"
14
+ }
15
+ export declare enum Factory {
16
+ V2V1 = "1",
17
+ V2V1_1 = "2",
18
+ V2V1_2 = "3",
19
+ V2V2 = "4",
20
+ SOLV1_2 = "5",
21
+ SOLV2 = "6"
22
+ }
23
+ export declare enum PoolTokenType {
24
+ Collateral = "collateral",
25
+ BorrowableA = "borrowable0",
26
+ BorrowableB = "borrowable1"
27
+ }
28
+ export declare enum Amms {
29
+ uniswap = "uniswap",
30
+ quickswap = "quickswap",
31
+ sushiswap = "sushiswap",
32
+ swapr = "swapr",
33
+ swapfish = "swapfish",
34
+ zyberswap = "zyberswap",
35
+ pangolin = "pangolin",
36
+ traderJoe = "traderJoe",
37
+ solarbeam = "solarbeam",
38
+ thorus = "thorus",
39
+ tetuswap = "tetuswap",
40
+ solidly = "solidly",
41
+ solidlyB = "solidlyB",
42
+ solidlyUSDC = "solidlyUSDC",
43
+ solidlyUSDCB = "solidlyUSDCB",
44
+ solidly091 = "solidly091",
45
+ solidlyOxd = "solidlyOxd"
46
+ }
47
+ export type Address = string;
48
+ export type NetworkIndex<Type> = {
49
+ [key in Networks]?: Type;
50
+ };
51
+ export type FactoryIndex<Type> = {
52
+ [key in Factory]?: Type;
53
+ };
54
+ export type AddressIndex<Type> = {
55
+ [key in Address]: Type;
56
+ };
57
+ export type NetworkFactoryIndex<Type> = NetworkIndex<FactoryIndex<Type>>;
58
+ export type LendingPoolIndex<Type> = FactoryIndex<AddressIndex<Type>>;
59
+ export type AmmIndex = {
60
+ [key in Networks]: {
61
+ [key in Amms]?: any;
62
+ };
63
+ };
64
+ export type DistributorDetails = {
65
+ claimableAddress: Address;
66
+ name: string;
67
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Amms = exports.PoolTokenType = exports.Factory = exports.Networks = void 0;
4
+ var Networks;
5
+ (function (Networks) {
6
+ Networks["Ropsten"] = "ropsten";
7
+ Networks["Mainnet"] = "mainnet";
8
+ Networks["Polygon"] = "polygon";
9
+ Networks["Arbitrum"] = "arbitrum";
10
+ Networks["Avalanche"] = "avalanche";
11
+ Networks["Moonriver"] = "moonriver";
12
+ Networks["Aurora"] = "aurora";
13
+ Networks["Cronos"] = "cronos";
14
+ Networks["Fantom"] = "fantom";
15
+ Networks["Harmony"] = "harmony";
16
+ Networks["Moonbeam"] = "moonbeam";
17
+ Networks["Sxnetwork"] = "sxnetwork";
18
+ })(Networks = exports.Networks || (exports.Networks = {}));
19
+ // FACTORIES
20
+ var Factory;
21
+ (function (Factory) {
22
+ Factory["V2V1"] = "1";
23
+ Factory["V2V1_1"] = "2";
24
+ Factory["V2V1_2"] = "3";
25
+ Factory["V2V2"] = "4";
26
+ Factory["SOLV1_2"] = "5";
27
+ Factory["SOLV2"] = "6";
28
+ })(Factory = exports.Factory || (exports.Factory = {}));
29
+ var PoolTokenType;
30
+ (function (PoolTokenType) {
31
+ PoolTokenType["Collateral"] = "collateral";
32
+ PoolTokenType["BorrowableA"] = "borrowable0";
33
+ PoolTokenType["BorrowableB"] = "borrowable1";
34
+ })(PoolTokenType = exports.PoolTokenType || (exports.PoolTokenType = {}));
35
+ var Amms;
36
+ (function (Amms) {
37
+ Amms["uniswap"] = "uniswap";
38
+ Amms["quickswap"] = "quickswap";
39
+ Amms["sushiswap"] = "sushiswap";
40
+ Amms["swapr"] = "swapr";
41
+ Amms["swapfish"] = "swapfish";
42
+ Amms["zyberswap"] = "zyberswap";
43
+ Amms["pangolin"] = "pangolin";
44
+ Amms["traderJoe"] = "traderJoe";
45
+ Amms["solarbeam"] = "solarbeam";
46
+ Amms["thorus"] = "thorus";
47
+ Amms["tetuswap"] = "tetuswap";
48
+ Amms["solidly"] = "solidly";
49
+ Amms["solidlyB"] = "solidlyB";
50
+ Amms["solidlyUSDC"] = "solidlyUSDC";
51
+ Amms["solidlyUSDCB"] = "solidlyUSDCB";
52
+ Amms["solidly091"] = "solidly091";
53
+ Amms["solidlyOxd"] = "solidlyOxd";
54
+ })(Amms = exports.Amms || (exports.Amms = {}));
@@ -0,0 +1,31 @@
1
+ import { AirdropData, PendingRewardUI } from "./interfaces";
2
+ import ImpermaxRouter from "./index";
3
+ import AccountLendingPool from "./AccountLendingPool";
4
+ import { Address, Factory, FactoryIndex, LendingPoolIndex } from '../config/types';
5
+ export default class Account {
6
+ router: ImpermaxRouter;
7
+ account: Address;
8
+ accountLLPs: LendingPoolIndex<Promise<AccountLendingPool>>;
9
+ cache: {
10
+ airdropData: {
11
+ [key in string]?: Promise<AirdropData>;
12
+ };
13
+ claimableIBEX?: {
14
+ [key in Address]?: Promise<number>;
15
+ };
16
+ };
17
+ constructor(router: ImpermaxRouter, account: Address);
18
+ cleanCache(): Promise<void>;
19
+ private initializeAccountLendingPool;
20
+ getAccountLendingPool(factory: Factory, pair: Address): Promise<AccountLendingPool>;
21
+ getMassAvailableReward(pairs: FactoryIndex<Address[]>): Promise<LendingPoolIndex<PendingRewardUI[]>>;
22
+ private initializeAirdropData;
23
+ private getAirdropData;
24
+ getIbexAirdropData(): Promise<AirdropData>;
25
+ getIbex2AirdropData(): Promise<AirdropData>;
26
+ getEthAirdropData(): Promise<AirdropData>;
27
+ hasIbexClaimableAirdrop(): Promise<boolean>;
28
+ hasEthClaimableAirdrop(): Promise<boolean>;
29
+ initializeClaimableIBEX(claimableAddress: Address): Promise<number>;
30
+ getClaimableIBEX(claimableAddress: Address): Promise<number>;
31
+ }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const AccountLendingPool_1 = __importDefault(require("./AccountLendingPool"));
16
+ const ethers_1 = require("ethers");
17
+ const merkle_distributors_1 = require("../config/endpoints/merkle-distributors");
18
+ class Account {
19
+ constructor(router, account) {
20
+ this.cache = { airdropData: {} };
21
+ this.router = router;
22
+ this.account = account;
23
+ this.accountLLPs = {};
24
+ this.cache.claimableIBEX = {};
25
+ }
26
+ cleanCache() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ this.cache = { airdropData: {} };
29
+ this.cache.claimableIBEX = {};
30
+ for (const factory of Object.keys(this.accountLLPs)) {
31
+ for (const pairAddress of Object.keys(this.accountLLPs[factory])) {
32
+ (yield this.accountLLPs[factory][pairAddress]).cleanCache();
33
+ }
34
+ }
35
+ });
36
+ }
37
+ initializeAccountLendingPool(factory, pair) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const lendingPool = yield this.router.getFactory(factory).getLendingPool(pair);
40
+ return new AccountLendingPool_1.default(this, lendingPool);
41
+ });
42
+ }
43
+ getAccountLendingPool(factory, pair) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ if (!this.accountLLPs[factory])
46
+ this.accountLLPs[factory] = {};
47
+ if (!this.accountLLPs[factory][pair])
48
+ this.accountLLPs[factory][pair] = this.initializeAccountLendingPool(factory, pair);
49
+ return this.accountLLPs[factory][pair];
50
+ });
51
+ }
52
+ // Mass Available Reward (only supports ImpermaxChef)
53
+ getMassAvailableReward(pairs) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const result = {};
56
+ if (!pairs)
57
+ return result;
58
+ const requests = [];
59
+ const factories = Object.keys(pairs);
60
+ for (const factory of factories) {
61
+ const requestsLocal = [];
62
+ for (const pairAddress of pairs[factory]) {
63
+ requestsLocal.push((yield this.getAccountLendingPool(factory, pairAddress)).getAvailableReward());
64
+ }
65
+ requests.push(Promise.all(requestsLocal));
66
+ }
67
+ const data = yield Promise.all(requests);
68
+ for (let i = 0; i < factories.length; i++) {
69
+ const factory = factories[i];
70
+ result[factory] = {};
71
+ for (let j = 0; j < pairs[factory].length; j++) {
72
+ result[factory][pairs[factory][j]] = data[i][j];
73
+ }
74
+ }
75
+ return result;
76
+ });
77
+ }
78
+ // Airdrop Data
79
+ initializeAirdropData(airdropURL, merkleDistributor) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ if (airdropURL && airdropURL !== '') {
82
+ try {
83
+ const json = yield fetch(airdropURL + '/' + this.account);
84
+ const data = yield json.json();
85
+ if (data) {
86
+ data.amount = ethers_1.BigNumber.from(data.amount);
87
+ const isClaimed = yield merkleDistributor.methods.isClaimed(data.index).call();
88
+ if (!isClaimed)
89
+ return data;
90
+ }
91
+ }
92
+ catch (e) { }
93
+ }
94
+ return {
95
+ index: -1,
96
+ amount: null,
97
+ proof: [],
98
+ };
99
+ });
100
+ }
101
+ getAirdropData(airdropURL, merkleDistributor) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ if (!this.cache.airdropData[airdropURL])
104
+ this.cache.airdropData[airdropURL] = this.initializeAirdropData(airdropURL, merkleDistributor);
105
+ return this.cache.airdropData[airdropURL];
106
+ });
107
+ }
108
+ getIbexAirdropData() {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ return this.getAirdropData(merkle_distributors_1.MERKLE_URL_IBEX[this.router.network], this.router.contractsHelper.merkleDistributorIbex);
111
+ });
112
+ }
113
+ getIbex2AirdropData() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ return this.getAirdropData(merkle_distributors_1.MERKLE_URL_IBEX_2[this.router.network], this.router.contractsHelper.merkleDistributorIbex2);
116
+ });
117
+ }
118
+ getEthAirdropData() {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ return this.getAirdropData(merkle_distributors_1.MERKLE_URL_ETH[this.router.network], this.router.contractsHelper.merkleDistributorEth);
121
+ });
122
+ }
123
+ hasIbexClaimableAirdrop() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const airdropData = yield this.getIbexAirdropData();
126
+ if (airdropData.amount)
127
+ return true;
128
+ return false;
129
+ });
130
+ }
131
+ hasEthClaimableAirdrop() {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const airdropData = yield this.getEthAirdropData();
134
+ if (airdropData.amount)
135
+ return true;
136
+ return false;
137
+ });
138
+ }
139
+ // Claim Claimable IBEX
140
+ initializeClaimableIBEX(claimableAddress) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const claimable = this.router.contractsHelper.newClaimable(claimableAddress);
143
+ return (yield claimable.methods.claim().call({ from: this.account })) / 1e18;
144
+ });
145
+ }
146
+ getClaimableIBEX(claimableAddress) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ if (!this.cache.claimableIBEX[claimableAddress])
149
+ this.cache.claimableIBEX[claimableAddress] = this.initializeClaimableIBEX(claimableAddress);
150
+ return this.cache.claimableIBEX[claimableAddress];
151
+ });
152
+ }
153
+ }
154
+ exports.default = Account;
@@ -0,0 +1,22 @@
1
+ import AccountPoolToken from "./AccountPoolToken";
2
+ import Borrowable from "./Borrowable";
3
+ export default class AccountBorrowable extends AccountPoolToken {
4
+ poolToken: Borrowable;
5
+ borrowableCache: {
6
+ borrowed?: Promise<number>;
7
+ farmingShares?: Promise<number>;
8
+ availableIMXReward?: Promise<number>;
9
+ availableRewarderReward?: Promise<number>;
10
+ };
11
+ cleanCache(): void;
12
+ private initializeBorrowed;
13
+ getBorrowed(): Promise<number>;
14
+ getBorrowedUSD(): Promise<number>;
15
+ getMaxBorrowable(): Promise<number>;
16
+ private initializeFarmingShares;
17
+ getFarmingShares(): Promise<number>;
18
+ private initializeAvailableIMXReward;
19
+ getAvailableIMXReward(): Promise<number>;
20
+ private initializeAvailableRewarderReward;
21
+ getAvailableRewarderReward(): Promise<number>;
22
+ }