@paraswap/dex-lib 3.7.2 → 3.7.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 (236) hide show
  1. package/build/abi/Redstone.json +739 -0
  2. package/build/abi/aavev3stata/Factory.json +128 -0
  3. package/build/abi/aavev3stata/Token.json +735 -0
  4. package/build/abi/angle-transmuter/MorphoOracle.json +193 -0
  5. package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
  6. package/build/abi/angle-transmuter/Pyth.json +1534 -0
  7. package/build/abi/angle-transmuter/Transmuter.json +1711 -0
  8. package/build/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
  9. package/build/abi/idle-dao/idle-cdo-factory.json +38 -0
  10. package/build/abi/idle-dao/idle-cdo.json +1245 -0
  11. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  12. package/build/dex/aave-v1/aave-v1.js +22 -0
  13. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  14. package/build/dex/aave-v3-stata/aave-v3-stata.d.ts +50 -0
  15. package/build/dex/aave-v3-stata/aave-v3-stata.js +365 -0
  16. package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -0
  17. package/build/dex/aave-v3-stata/config.d.ts +4 -0
  18. package/build/dex/aave-v3-stata/config.js +50 -0
  19. package/build/dex/aave-v3-stata/config.js.map +1 -0
  20. package/build/dex/aave-v3-stata/tokens.d.ts +9 -0
  21. package/build/dex/aave-v3-stata/tokens.js +37 -0
  22. package/build/dex/aave-v3-stata/tokens.js.map +1 -0
  23. package/build/dex/aave-v3-stata/types.d.ts +46 -0
  24. package/build/dex/aave-v3-stata/types.js +23 -0
  25. package/build/dex/aave-v3-stata/types.js.map +1 -0
  26. package/build/dex/aave-v3-stata/utils.d.ts +4 -0
  27. package/build/dex/aave-v3-stata/utils.js +67 -0
  28. package/build/dex/aave-v3-stata/utils.js.map +1 -0
  29. package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +67 -0
  30. package/build/dex/angle-transmuter/angle-transmuter-pool.js +448 -0
  31. package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
  32. package/build/dex/angle-transmuter/angle-transmuter.d.ts +59 -0
  33. package/build/dex/angle-transmuter/angle-transmuter.js +264 -0
  34. package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
  35. package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
  36. package/build/dex/angle-transmuter/backedOracle.js +56 -0
  37. package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
  38. package/build/dex/angle-transmuter/config.d.ts +4 -0
  39. package/build/dex/angle-transmuter/config.js +50 -0
  40. package/build/dex/angle-transmuter/config.js.map +1 -0
  41. package/build/dex/angle-transmuter/constants.d.ts +9 -0
  42. package/build/dex/angle-transmuter/constants.js +136 -0
  43. package/build/dex/angle-transmuter/constants.js.map +1 -0
  44. package/build/dex/angle-transmuter/morphoOracle.d.ts +42 -0
  45. package/build/dex/angle-transmuter/morphoOracle.js +179 -0
  46. package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
  47. package/build/dex/angle-transmuter/morphoVault.d.ts +20 -0
  48. package/build/dex/angle-transmuter/morphoVault.js +84 -0
  49. package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
  50. package/build/dex/angle-transmuter/pyth.d.ts +19 -0
  51. package/build/dex/angle-transmuter/pyth.js +70 -0
  52. package/build/dex/angle-transmuter/pyth.js.map +1 -0
  53. package/build/dex/angle-transmuter/redstone.d.ts +20 -0
  54. package/build/dex/angle-transmuter/redstone.js +64 -0
  55. package/build/dex/angle-transmuter/redstone.js.map +1 -0
  56. package/build/dex/angle-transmuter/transmuter.d.ts +55 -0
  57. package/build/dex/angle-transmuter/transmuter.js +398 -0
  58. package/build/dex/angle-transmuter/transmuter.js.map +1 -0
  59. package/build/dex/angle-transmuter/types.d.ts +189 -0
  60. package/build/dex/angle-transmuter/types.js +33 -0
  61. package/build/dex/angle-transmuter/types.js.map +1 -0
  62. package/build/dex/angle-transmuter/utils.d.ts +9 -0
  63. package/build/dex/angle-transmuter/utils.js +257 -0
  64. package/build/dex/angle-transmuter/utils.js.map +1 -0
  65. package/build/dex/idle-dao/config.d.ts +6 -0
  66. package/build/dex/idle-dao/config.js +307 -0
  67. package/build/dex/idle-dao/config.js.map +1 -0
  68. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  69. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  70. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  71. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  72. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  73. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  74. package/build/dex/idle-dao/idle-dao.d.ts +41 -0
  75. package/build/dex/idle-dao/idle-dao.js +238 -0
  76. package/build/dex/idle-dao/idle-dao.js.map +1 -0
  77. package/build/dex/idle-dao/scripts.d.ts +9 -0
  78. package/build/dex/idle-dao/scripts.js +552 -0
  79. package/build/dex/idle-dao/scripts.js.map +1 -0
  80. package/build/dex/idle-dao/tokens.d.ts +9 -0
  81. package/build/dex/idle-dao/tokens.js +65 -0
  82. package/build/dex/idle-dao/tokens.js.map +1 -0
  83. package/build/dex/idle-dao/types.d.ts +35 -0
  84. package/build/dex/idle-dao/types.js +11 -0
  85. package/build/dex/idle-dao/types.js.map +1 -0
  86. package/build/dex/idle-dao/utils.d.ts +8 -0
  87. package/build/dex/idle-dao/utils.js +148 -0
  88. package/build/dex/idle-dao/utils.js.map +1 -0
  89. package/build/dex/index.js +2 -0
  90. package/build/dex/index.js.map +1 -1
  91. package/build/dex/platypus/platypus.d.ts +2 -1
  92. package/build/dex/platypus/platypus.js +31 -0
  93. package/build/dex/platypus/platypus.js.map +1 -1
  94. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  95. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  96. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  97. package/build/lib/chainlink.d.ts +2 -0
  98. package/build/lib/chainlink.js +9 -0
  99. package/build/lib/chainlink.js.map +1 -1
  100. package/build/utils.d.ts +1 -1
  101. package/package.json +1 -1
  102. package/src/abi/Redstone.json +739 -0
  103. package/src/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
  104. package/src/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
  105. package/src/abi/angle-transmuter/MorphoOracle.json +193 -0
  106. package/src/abi/angle-transmuter/MorphoVault.json +2506 -0
  107. package/src/abi/angle-transmuter/Pyth.json +1534 -0
  108. package/src/abi/angle-transmuter/Transmuter.json +1711 -0
  109. package/src/abi/angle-transmuter/TransmuterSidechain.json +1798 -0
  110. package/src/dex/angle-transmuter/angle-transmuter-e2e.test.ts +156 -0
  111. package/src/dex/angle-transmuter/angle-transmuter-events.test.ts +365 -0
  112. package/src/dex/angle-transmuter/angle-transmuter-integration.test.ts +390 -0
  113. package/src/dex/angle-transmuter/angle-transmuter-pool.ts +895 -0
  114. package/src/dex/angle-transmuter/angle-transmuter.ts +408 -0
  115. package/src/dex/angle-transmuter/backedOracle.ts +91 -0
  116. package/src/dex/angle-transmuter/config.ts +50 -0
  117. package/src/dex/angle-transmuter/constants.ts +138 -0
  118. package/src/dex/angle-transmuter/morphoOracle.ts +335 -0
  119. package/src/dex/angle-transmuter/morphoVault.ts +134 -0
  120. package/src/dex/angle-transmuter/pyth.ts +105 -0
  121. package/src/dex/angle-transmuter/redstone.ts +105 -0
  122. package/src/dex/angle-transmuter/transmuter.ts +619 -0
  123. package/src/dex/angle-transmuter/types.ts +203 -0
  124. package/src/dex/angle-transmuter/utils.ts +358 -0
  125. package/src/dex/index.ts +2 -0
  126. package/src/lib/chainlink.ts +15 -0
  127. package/tests/constants-e2e.ts +48 -3
  128. package/build/abi/Uncompressor.json +0 -250
  129. package/build/dex/bProtocol.d.ts +0 -18
  130. package/build/dex/bProtocol.js +0 -39
  131. package/build/dex/bProtocol.js.map +0 -1
  132. package/build/dex/bancor.d.ts +0 -26
  133. package/build/dex/bancor.js +0 -58
  134. package/build/dex/bancor.js.map +0 -1
  135. package/build/dex/compound.d.ts +0 -18
  136. package/build/dex/compound.js +0 -46
  137. package/build/dex/compound.js.map +0 -1
  138. package/build/dex/curve-v2.d.ts +0 -58
  139. package/build/dex/curve-v2.js +0 -180
  140. package/build/dex/curve-v2.js.map +0 -1
  141. package/build/dex/dodo-v1.d.ts +0 -33
  142. package/build/dex/dodo-v1.js +0 -63
  143. package/build/dex/dodo-v1.js.map +0 -1
  144. package/build/dex/etherfi/etherfi.d.ts +0 -26
  145. package/build/dex/etherfi/etherfi.js +0 -96
  146. package/build/dex/etherfi/etherfi.js.map +0 -1
  147. package/build/dex/lido.d.ts +0 -19
  148. package/build/dex/lido.js +0 -42
  149. package/build/dex/lido.js.map +0 -1
  150. package/build/dex/onebit.d.ts +0 -25
  151. package/build/dex/onebit.js +0 -42
  152. package/build/dex/onebit.js.map +0 -1
  153. package/build/dex/sdai/config.d.ts +0 -11
  154. package/build/dex/sdai/config.js +0 -21
  155. package/build/dex/sdai/config.js.map +0 -1
  156. package/build/dex/sdai/constants.d.ts +0 -2
  157. package/build/dex/sdai/constants.js +0 -6
  158. package/build/dex/sdai/constants.js.map +0 -1
  159. package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
  160. package/build/dex/sdai/scripts/validate-state.js +0 -102
  161. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  162. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  163. package/build/dex/sdai/sdai-pool.js +0 -85
  164. package/build/dex/sdai/sdai-pool.js.map +0 -1
  165. package/build/dex/sdai/sdai.d.ts +0 -51
  166. package/build/dex/sdai/sdai.js +0 -172
  167. package/build/dex/sdai/sdai.js.map +0 -1
  168. package/build/dex/sdai/types.d.ts +0 -21
  169. package/build/dex/sdai/types.js +0 -11
  170. package/build/dex/sdai/types.js.map +0 -1
  171. package/build/dex/sdai/utils.d.ts +0 -4
  172. package/build/dex/sdai/utils.js +0 -39
  173. package/build/dex/sdai/utils.js.map +0 -1
  174. package/build/dex/smoothy.d.ts +0 -26
  175. package/build/dex/smoothy.js +0 -48
  176. package/build/dex/smoothy.js.map +0 -1
  177. package/build/dex/stable-pool.d.ts +0 -28
  178. package/build/dex/stable-pool.js +0 -62
  179. package/build/dex/stable-pool.js.map +0 -1
  180. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  181. package/build/dex/trader-joe-v2.1.js +0 -79
  182. package/build/dex/trader-joe-v2.1.js.map +0 -1
  183. package/build/executor/compressor/Compressor.d.ts +0 -23
  184. package/build/executor/compressor/Compressor.js +0 -144
  185. package/build/executor/compressor/Compressor.js.map +0 -1
  186. package/build/executor/compressor/compress.d.ts +0 -17
  187. package/build/executor/compressor/compress.js +0 -187
  188. package/build/executor/compressor/compress.js.map +0 -1
  189. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
  190. package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
  191. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
  192. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
  193. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
  194. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
  195. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
  196. package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
  197. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
  198. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
  199. package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
  200. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
  201. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
  202. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
  203. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
  204. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
  205. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
  206. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
  207. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
  208. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
  209. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
  210. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
  211. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
  212. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
  213. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  214. package/build/executor/compressor/fetchSaved.js +0 -17
  215. package/build/executor/compressor/fetchSaved.js.map +0 -1
  216. package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
  217. package/build/executor/compressor/utils/computeCostL2.js +0 -14
  218. package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
  219. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
  220. package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
  221. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
  222. package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
  223. package/build/executor/compressor/utils/getAllIndexes.js +0 -12
  224. package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
  225. package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
  226. package/build/executor/compressor/utils/getByteForAddress.js +0 -14
  227. package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
  228. package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
  229. package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
  230. package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
  231. package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
  232. package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
  233. package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
  234. package/build/executor/compressor/utils/intToByte.d.ts +0 -2
  235. package/build/executor/compressor/utils/intToByte.js +0 -10
  236. package/build/executor/compressor/utils/intToByte.js.map +0 -1
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterDictionaryOnly = exports._quoteFees = exports._quoteBurnExactInput = exports._quoteBurnExactOutput = exports._quoteMintExactOutput = exports._quoteMintExactInput = void 0;
4
+ const types_1 = require("./types");
5
+ /// @notice Computes the `amountOut` of stablecoins to mint from `tokenIn` of a collateral with data `collatInfo`
6
+ function _quoteMintExactInput(oracleValue, amountIn, fees, stablecoinsIssued, otherStablecoinSupply, stablecoinCap) {
7
+ let amountOut = oracleValue * amountIn;
8
+ amountOut = _quoteFees(fees, types_1.QuoteType.MintExactInput, amountOut, stablecoinsIssued, otherStablecoinSupply);
9
+ if (stablecoinCap >= 0 && amountOut + stablecoinsIssued > stablecoinCap)
10
+ throw new Error('InvalidSwap');
11
+ return amountOut;
12
+ }
13
+ exports._quoteMintExactInput = _quoteMintExactInput;
14
+ /// @notice Computes the `amountIn` of collateral to get during a mint of `amountOut` of stablecoins
15
+ function _quoteMintExactOutput(oracleValue, amountOut, fees, stablecoinsIssued, otherStablecoinSupply, stablecoinCap) {
16
+ if (stablecoinCap >= 0 && amountOut + stablecoinsIssued > stablecoinCap)
17
+ throw new Error('InvalidSwap');
18
+ const amountIn = _quoteFees(fees, types_1.QuoteType.MintExactOutput, amountOut, stablecoinsIssued, otherStablecoinSupply);
19
+ return amountIn / oracleValue;
20
+ }
21
+ exports._quoteMintExactOutput = _quoteMintExactOutput;
22
+ /// @notice Computes the `amountIn` of stablecoins to burn to release `amountOut` of `collateral`
23
+ function _quoteBurnExactOutput(oracleValue, ratio, amountOut, fees, stablecoinsIssued, otherStablecoinSupply) {
24
+ const amountIn = (amountOut * oracleValue) / ratio;
25
+ return _quoteFees(fees, types_1.QuoteType.BurnExactOutput, amountIn, stablecoinsIssued, otherStablecoinSupply);
26
+ }
27
+ exports._quoteBurnExactOutput = _quoteBurnExactOutput;
28
+ /// @notice Computes the `amountOut` of `collateral` to give during a burn operation of `amountIn` of stablecoins
29
+ function _quoteBurnExactInput(oracleValue, ratio, amountIn, fees, stablecoinsIssued, otherStablecoinSupply) {
30
+ const amountOut = _quoteFees(fees, types_1.QuoteType.BurnExactInput, amountIn, stablecoinsIssued, otherStablecoinSupply);
31
+ return (amountOut * ratio) / oracleValue;
32
+ }
33
+ exports._quoteBurnExactInput = _quoteBurnExactInput;
34
+ function _quoteFees(fees, quoteType, amountStable, stablecoinsIssued, otherStablecoinSupply) {
35
+ const isMint = _isMint(quoteType);
36
+ const isExact = _isExact(quoteType);
37
+ const n = isMint ? fees.xFeeMint.length : fees.xFeeBurn.length;
38
+ let currentExposure = (stablecoinsIssued * types_1.BASE_9) / (otherStablecoinSupply + stablecoinsIssued);
39
+ let amount = 0;
40
+ // Finding in which segment the current exposure to the collateral is
41
+ let i = findLowerBound(isMint, isMint ? fees.xFeeMint : fees.xFeeBurn, types_1.BASE_9, currentExposure);
42
+ let lowerExposure;
43
+ let upperExposure;
44
+ let lowerFees;
45
+ let upperFees;
46
+ let amountToNextBreakPoint;
47
+ while (i < n - 1) {
48
+ // We compute a linear by part function on the amount swapped
49
+ // The `amountToNextBreakPoint` variable is the `b_{i+1}` value from the whitepaper
50
+ if (isMint) {
51
+ lowerExposure = fees.xFeeMint[i];
52
+ upperExposure = fees.xFeeMint[i + 1];
53
+ lowerFees = fees.yFeeMint[i];
54
+ upperFees = fees.yFeeMint[i + 1];
55
+ amountToNextBreakPoint =
56
+ (otherStablecoinSupply * upperExposure) / (types_1.BASE_9 - upperExposure) -
57
+ stablecoinsIssued;
58
+ }
59
+ else {
60
+ // The exposures in the burn case are decreasing
61
+ lowerExposure = fees.xFeeBurn[i];
62
+ upperExposure = fees.xFeeBurn[i + 1];
63
+ lowerFees = fees.yFeeBurn[i];
64
+ upperFees = fees.yFeeBurn[i + 1];
65
+ // The `b_{i+1}` value in the burn case is the opposite value of the mint case
66
+ amountToNextBreakPoint =
67
+ stablecoinsIssued -
68
+ (otherStablecoinSupply * upperExposure) / (types_1.BASE_9 - upperExposure);
69
+ }
70
+ let currentFees;
71
+ if (lowerExposure * types_1.BASE_9 === currentExposure) {
72
+ currentFees = lowerFees;
73
+ }
74
+ else if (lowerFees === upperFees) {
75
+ currentFees = lowerFees;
76
+ }
77
+ else {
78
+ // This is the opposite of the `b_i` value from the whitepaper.
79
+ const amountFromPrevBreakPoint = isMint
80
+ ? stablecoinsIssued -
81
+ (otherStablecoinSupply * lowerExposure) / (types_1.BASE_9 - lowerExposure)
82
+ : (otherStablecoinSupply * lowerExposure) / (types_1.BASE_9 - lowerExposure) -
83
+ stablecoinsIssued;
84
+ // slope = (upperFees - lowerFees) / (amountToNextBreakPoint + amountFromPrevBreakPoint)
85
+ // `currentFees` is the `g(0)` value from the whitepaper
86
+ currentFees =
87
+ lowerFees +
88
+ ((upperFees - lowerFees) * amountFromPrevBreakPoint) /
89
+ (amountToNextBreakPoint + amountFromPrevBreakPoint);
90
+ }
91
+ {
92
+ const amountToNextBreakPointNormalizer = isExact
93
+ ? amountToNextBreakPoint
94
+ : isMint
95
+ ? _invertFeeMint(amountToNextBreakPoint, (upperFees + currentFees) / 2)
96
+ : _applyFeeBurn(amountToNextBreakPoint, (upperFees + currentFees) / 2);
97
+ if (amountToNextBreakPointNormalizer >= amountStable) {
98
+ let midFee;
99
+ if (isExact) {
100
+ // `(g_i(0) + g_i(M)) / 2 = g(0) + (f_{i+1} - g(0)) * M / (2 * b_{i+1})`
101
+ midFee =
102
+ currentFees +
103
+ (amountStable * (upperFees - currentFees)) /
104
+ (2 * amountToNextBreakPointNormalizer);
105
+ }
106
+ else {
107
+ // Here instead of computing the closed form expression for `m_t` derived in the whitepaper,
108
+ // we are computing: `(g(0)+g_i(m_t))/2 = g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
109
+ // ac4 is the value of `2M(f_{i+1}-f_i)/(b_{i+1}-b_i) = 2M(f_{i+1}-g(0))/b_{i+1}` used
110
+ // in the computation of `m_t` in both the mint and burn case
111
+ const ac4 = (types_1.BASE_9 * (2 * amountStable * (upperFees - currentFees))) /
112
+ amountToNextBreakPoint;
113
+ if (isMint) {
114
+ // In the mint case:
115
+ // `m_t = (-1-g(0)+sqrt[(1+g(0))**2+2M(f_{i+1}-g(0))/b_{i+1})]/((f_{i+1}-g(0))/b_{i+1})`
116
+ // And so: g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
117
+ // = (g(0)-1+sqrt[(1+g(0))**2+2M(f_{i+1}-g(0))/b_{i+1})])
118
+ midFee = Number((Math.sqrt((types_1.BASE_9 + currentFees) ** 2 + ac4) +
119
+ currentFees -
120
+ types_1.BASE_9) /
121
+ 2);
122
+ }
123
+ else {
124
+ // In the burn case:
125
+ // `m_t = (1-g(0)+sqrt[(1-g(0))**2-2M(f_{i+1}-g(0))/b_{i+1})]/((f_{i+1}-g(0))/b_{i+1})`
126
+ // And so: g(0)+(f_{i+1}-f_i)/(b_{i+1}-b_i)m_t/2
127
+ // = (g(0)+1-sqrt[(1-g(0))**2-2M(f_{i+1}-g(0))/b_{i+1})])
128
+ const baseMinusCurrentSquared = (types_1.BASE_9 - currentFees) ** 2;
129
+ // Mathematically, this condition is always verified, but rounding errors may make this
130
+ // mathematical invariant break, in which case we consider that the square root is null
131
+ if (baseMinusCurrentSquared < ac4) {
132
+ midFee = (currentFees + types_1.BASE_9) / 2;
133
+ }
134
+ else {
135
+ midFee =
136
+ (currentFees +
137
+ types_1.BASE_9 -
138
+ Math.sqrt(baseMinusCurrentSquared - ac4)) /
139
+ 2;
140
+ }
141
+ }
142
+ }
143
+ return amount + _computeFee(quoteType, amountStable, midFee);
144
+ }
145
+ amountStable -= amountToNextBreakPointNormalizer;
146
+ amount += !isExact
147
+ ? amountToNextBreakPoint
148
+ : isMint
149
+ ? _invertFeeMint(amountToNextBreakPoint, (upperFees + currentFees) / 2)
150
+ : _applyFeeBurn(amountToNextBreakPoint, (upperFees + currentFees) / 2);
151
+ currentExposure = upperExposure * types_1.BASE_9;
152
+ ++i;
153
+ // Update for the rest of the swaps the stablecoins issued from the asset
154
+ stablecoinsIssued = isMint
155
+ ? stablecoinsIssued + amountToNextBreakPoint
156
+ : stablecoinsIssued - amountToNextBreakPoint;
157
+ }
158
+ }
159
+ return (amount +
160
+ _computeFee(quoteType, amountStable, isMint ? fees.yFeeMint[n - 1] : fees.yFeeBurn[n - 1]));
161
+ }
162
+ exports._quoteFees = _quoteFees;
163
+ function findLowerBound(increasingArray, array, normalizerArray, element) {
164
+ if (array.length === 0) {
165
+ return 0;
166
+ }
167
+ let low = 1;
168
+ let high = array.length;
169
+ if ((increasingArray && array[high - 1] * normalizerArray <= element) ||
170
+ (!increasingArray && array[high - 1] * normalizerArray >= element)) {
171
+ return high - 1;
172
+ }
173
+ while (low < high) {
174
+ const mid = Math.floor((low + high) / 2);
175
+ if (increasingArray
176
+ ? array[mid] * normalizerArray > element
177
+ : array[mid] * normalizerArray < element) {
178
+ high = mid;
179
+ }
180
+ else {
181
+ low = mid + 1;
182
+ }
183
+ }
184
+ return low - 1;
185
+ }
186
+ function _isMint(quoteType) {
187
+ return (quoteType === types_1.QuoteType.MintExactInput ||
188
+ quoteType === types_1.QuoteType.MintExactOutput);
189
+ }
190
+ function _isExact(quoteType) {
191
+ return (quoteType === types_1.QuoteType.MintExactOutput ||
192
+ quoteType === types_1.QuoteType.BurnExactInput);
193
+ }
194
+ function _applyFeeMint(amountIn, fees) {
195
+ if (fees >= 0) {
196
+ const castedFees = fees;
197
+ // Consider that if fees are above `BASE_12` this is equivalent to infinite fees
198
+ if (castedFees >= types_1.BASE_12)
199
+ throw new Error('InvalidSwap');
200
+ return (amountIn * types_1.BASE_9) / (types_1.BASE_9 + castedFees);
201
+ }
202
+ return (amountIn * types_1.BASE_9) / (types_1.BASE_9 - Math.abs(-fees));
203
+ }
204
+ function _invertFeeMint(amountOut, fees) {
205
+ if (fees >= 0) {
206
+ const castedFees = fees;
207
+ // Consider that if fees are above `BASE_12` this is equivalent to infinite fees
208
+ if (castedFees >= types_1.BASE_12)
209
+ throw new Error('InvalidSwap');
210
+ return (amountOut * (types_1.BASE_9 + castedFees)) / types_1.BASE_9;
211
+ }
212
+ return (amountOut * (types_1.BASE_9 - Math.abs(-fees))) / types_1.BASE_9;
213
+ }
214
+ function _applyFeeBurn(amountIn, fees) {
215
+ if (fees >= 0) {
216
+ const castedFees = fees;
217
+ if (castedFees >= types_1.MAX_BURN_FEE)
218
+ throw new Error('InvalidSwap');
219
+ return ((types_1.BASE_9 - castedFees) * amountIn) / types_1.BASE_9;
220
+ }
221
+ return ((types_1.BASE_9 + Math.abs(-fees)) * amountIn) / types_1.BASE_9;
222
+ }
223
+ function _invertFeeBurn(amountOut, fees) {
224
+ if (fees >= 0) {
225
+ const castedFees = fees;
226
+ if (castedFees >= types_1.MAX_BURN_FEE)
227
+ throw new Error('InvalidSwap');
228
+ return (amountOut * types_1.BASE_9) / (types_1.BASE_9 - castedFees);
229
+ }
230
+ return (amountOut * types_1.BASE_9) / (types_1.BASE_9 + Math.abs(-fees));
231
+ }
232
+ function _computeFee(quoteType, amount, fees) {
233
+ if (quoteType === types_1.QuoteType.MintExactInput) {
234
+ return _applyFeeMint(amount, fees);
235
+ }
236
+ if (quoteType === types_1.QuoteType.MintExactOutput) {
237
+ return _invertFeeMint(amount, fees);
238
+ }
239
+ if (quoteType === types_1.QuoteType.BurnExactInput) {
240
+ return _applyFeeBurn(amount, fees);
241
+ }
242
+ return _invertFeeBurn(amount, fees);
243
+ }
244
+ function filterDictionaryOnly(obj) {
245
+ const result = {};
246
+ Object.keys(obj).map(key => {
247
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
248
+ // Skip numeric keys to exclude array-like properties
249
+ if (Number.isNaN(Number(key))) {
250
+ result[key] = obj[key];
251
+ }
252
+ }
253
+ });
254
+ return result;
255
+ }
256
+ exports.filterDictionaryOnly = filterDictionaryOnly;
257
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/angle-transmuter/utils.ts"],"names":[],"mappings":";;;AAAA,mCAAyE;AAEzE,iHAAiH;AACjH,SAAgB,oBAAoB,CAClC,WAAmB,EACnB,QAAgB,EAChB,IAAU,EACV,iBAAyB,EACzB,qBAA6B,EAC7B,aAAqB;IAErB,IAAI,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvC,SAAS,GAAG,UAAU,CACpB,IAAI,EACJ,iBAAS,CAAC,cAAc,EACxB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;IACF,IAAI,aAAa,IAAI,CAAC,IAAI,SAAS,GAAG,iBAAiB,GAAG,aAAa;QACrE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,oDAmBC;AAED,oGAAoG;AACpG,SAAgB,qBAAqB,CACnC,WAAmB,EACnB,SAAiB,EACjB,IAAU,EACV,iBAAyB,EACzB,qBAA6B,EAC7B,aAAqB;IAErB,IAAI,aAAa,IAAI,CAAC,IAAI,SAAS,GAAG,iBAAiB,GAAG,aAAa;QACrE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,UAAU,CACzB,IAAI,EACJ,iBAAS,CAAC,eAAe,EACzB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;IACF,OAAO,QAAQ,GAAG,WAAW,CAAC;AAChC,CAAC;AAlBD,sDAkBC;AAED,iGAAiG;AACjG,SAAgB,qBAAqB,CACnC,WAAmB,EACnB,KAAa,EACb,SAAiB,EACjB,IAAU,EACV,iBAAyB,EACzB,qBAA6B;IAE7B,MAAM,QAAQ,GAAG,CAAC,SA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IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;YAClD,qDAAqD;YACrD,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC7B,MAAM,CAAC,GAAc,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;aACnC;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,oDAaC"}
@@ -0,0 +1,6 @@
1
+ import { DexParams, IdleToken } from './types';
2
+ import { DexConfigMap, AdapterMappings } from '../../types';
3
+ export declare const Config: DexConfigMap<DexParams>;
4
+ export declare const Adapters: Record<number, AdapterMappings>;
5
+ export declare const endpoints: Record<number, string>;
6
+ export declare const TOKEN_LISTS: IdleToken[];
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOKEN_LISTS = exports.endpoints = exports.Adapters = exports.Config = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.Config = {
6
+ IdleDao: {
7
+ [constants_1.Network.MAINNET]: {
8
+ lendingGasCost: 328 * 1000,
9
+ factoryAddress: '0x3c9916bb9498f637e2fa86c2028e26275dc9a631',
10
+ },
11
+ },
12
+ };
13
+ exports.Adapters = {
14
+ [constants_1.Network.MAINNET]: {
15
+ [constants_1.SwapSide.SELL]: [{ name: '', index: 0 }],
16
+ [constants_1.SwapSide.BUY]: [{ name: '', index: 0 }],
17
+ },
18
+ };
19
+ exports.endpoints = {
20
+ [constants_1.Network.MAINNET]: 'https://api.idle.finance/pools',
21
+ [constants_1.Network.POLYGON]: 'https://api-polygon.idle.finance/pools',
22
+ [constants_1.Network.OPTIMISM]: 'https://api-optimism.idle.finance/pools',
23
+ [constants_1.Network.ZKEVM]: 'https://api-zkevm.idle.finance/pools',
24
+ };
25
+ exports.TOKEN_LISTS = [
26
+ {
27
+ blockNumber: 0,
28
+ idleDecimals: 18,
29
+ cdoAddress: '0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8',
30
+ idleAddress: '0x2688fc68c4eac90d9e5e1b94776cf14eade8d877',
31
+ address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
32
+ decimals: 18,
33
+ idleSymbol: 'AA_wstETH',
34
+ tokenType: 'AA',
35
+ },
36
+ {
37
+ blockNumber: 0,
38
+ idleDecimals: 18,
39
+ cdoAddress: '0x34dCd573C5dE4672C8248cd12A99f875Ca112Ad8',
40
+ idleAddress: '0x3a52fa30c33caf05faee0f9c5dfe5fd5fe8b3978',
41
+ address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
42
+ decimals: 18,
43
+ idleSymbol: 'BB_wstETH',
44
+ tokenType: 'BB',
45
+ },
46
+ {
47
+ blockNumber: 0,
48
+ idleDecimals: 18,
49
+ cdoAddress: '0x8E0A8A5c1e5B3ac0670Ea5a613bB15724D51Fc37',
50
+ idleAddress: '0xdf17c739b666b259da3416d01f0310a6e429f592',
51
+ address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
52
+ decimals: 18,
53
+ idleSymbol: 'AA_iETHv2',
54
+ tokenType: 'AA',
55
+ },
56
+ {
57
+ blockNumber: 0,
58
+ idleDecimals: 18,
59
+ cdoAddress: '0x8E0A8A5c1e5B3ac0670Ea5a613bB15724D51Fc37',
60
+ idleAddress: '0x990b3af34ddb502715e1070ce6778d8eb3c8ea82',
61
+ address: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
62
+ decimals: 18,
63
+ idleSymbol: 'BB_iETHv2',
64
+ tokenType: 'BB',
65
+ },
66
+ {
67
+ blockNumber: 0,
68
+ idleDecimals: 18,
69
+ cdoAddress: '0x1329E8DB9Ed7a44726572D44729427F132Fa290D',
70
+ idleAddress: '0x9cacd44cfdf22731bc99facf3531c809d56bd4a2',
71
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
72
+ decimals: 6,
73
+ idleSymbol: 'AA_idle_cpPOR-USDC',
74
+ tokenType: 'AA',
75
+ },
76
+ {
77
+ blockNumber: 0,
78
+ idleDecimals: 18,
79
+ cdoAddress: '0x1329E8DB9Ed7a44726572D44729427F132Fa290D',
80
+ idleAddress: '0xf85fd280b301c0a6232d515001da8b6c8503d714',
81
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
82
+ decimals: 6,
83
+ idleSymbol: 'BB_idle_cpPOR-USDC',
84
+ tokenType: 'BB',
85
+ },
86
+ {
87
+ blockNumber: 0,
88
+ idleDecimals: 18,
89
+ cdoAddress: '0xc4574C60a455655864aB80fa7638561A756C5E61',
90
+ idleAddress: '0x0a6f2449c09769950cfb76f905ad11c341541f70',
91
+ address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
92
+ decimals: 6,
93
+ idleSymbol: 'AA_idle_cpFAS-USDT',
94
+ tokenType: 'AA',
95
+ },
96
+ {
97
+ blockNumber: 0,
98
+ idleDecimals: 18,
99
+ cdoAddress: '0xc4574C60a455655864aB80fa7638561A756C5E61',
100
+ idleAddress: '0x3eb6318b8d9f362a0e1d99f6032edb1c4c602500',
101
+ address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
102
+ decimals: 6,
103
+ idleSymbol: 'BB_idle_cpFAS-USDT',
104
+ tokenType: 'BB',
105
+ },
106
+ {
107
+ blockNumber: 0,
108
+ idleDecimals: 18,
109
+ cdoAddress: '0xE7C6A4525492395d65e736C3593aC933F33ee46e',
110
+ idleAddress: '0xdca1dae87f5c733c84e0593984967ed756579bee',
111
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
112
+ decimals: 6,
113
+ idleSymbol: 'AA_idle_cpFASA-USDC',
114
+ tokenType: 'AA',
115
+ },
116
+ {
117
+ blockNumber: 0,
118
+ idleDecimals: 18,
119
+ cdoAddress: '0xE7C6A4525492395d65e736C3593aC933F33ee46e',
120
+ idleAddress: '0xbcc845bb731632ebe8ac0bfacde056170aaaaa06',
121
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
122
+ decimals: 6,
123
+ idleSymbol: 'BB_idle_cpFASA-USDC',
124
+ tokenType: 'BB',
125
+ },
126
+ {
127
+ blockNumber: 0,
128
+ idleDecimals: 18,
129
+ cdoAddress: '0x5dcA0B3Ed7594A6613c1A2acd367d56E1f74F92D',
130
+ idleAddress: '0x43ed68703006add5f99ce36b5182392362369c1c',
131
+ address: '0x6b175474e89094c44da98b954eedeac495271d0f',
132
+ decimals: 18,
133
+ idleSymbol: 'AA_idle_cpPOR-USDC',
134
+ tokenType: 'AA',
135
+ },
136
+ {
137
+ blockNumber: 0,
138
+ idleDecimals: 18,
139
+ cdoAddress: '0x5dcA0B3Ed7594A6613c1A2acd367d56E1f74F92D',
140
+ idleAddress: '0x38d36353d07cfb92650822d9c31fb4ada1c73d6e',
141
+ address: '0x6b175474e89094c44da98b954eedeac495271d0f',
142
+ decimals: 18,
143
+ idleSymbol: 'BB_idle_cpPOR-USDC',
144
+ tokenType: 'BB',
145
+ },
146
+ {
147
+ blockNumber: 0,
148
+ idleDecimals: 18,
149
+ cdoAddress: '0xF87ec7e1Ee467d7d78862089B92dd40497cBa5B8',
150
+ idleAddress: '0xaef4fcc4e5f2dc270760063446d4116d24704ad1',
151
+ address: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
152
+ decimals: 18,
153
+ idleSymbol: 'AA_stMATIC',
154
+ tokenType: 'AA',
155
+ },
156
+ {
157
+ blockNumber: 0,
158
+ idleDecimals: 18,
159
+ cdoAddress: '0xF87ec7e1Ee467d7d78862089B92dd40497cBa5B8',
160
+ idleAddress: '0x077212c69a66261cf7bd1fd3b5c5db7cffa948ee',
161
+ address: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
162
+ decimals: 18,
163
+ idleSymbol: 'BB_stMATIC',
164
+ tokenType: 'BB',
165
+ },
166
+ {
167
+ blockNumber: 0,
168
+ idleDecimals: 18,
169
+ cdoAddress: '0x87E53bE99975DA318056af5c4933469a6B513768',
170
+ idleAddress: '0x2b0e31b8ee653d2077db86dea3acf3f34ae9d5d2',
171
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
172
+ decimals: 6,
173
+ idleSymbol: 'AA_steakUSDC',
174
+ tokenType: 'AA',
175
+ },
176
+ {
177
+ blockNumber: 0,
178
+ idleDecimals: 18,
179
+ cdoAddress: '0x87E53bE99975DA318056af5c4933469a6B513768',
180
+ idleAddress: '0x7b713b1cb6eafd4061064581579ffccf7df21545',
181
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
182
+ decimals: 6,
183
+ idleSymbol: 'BB_steakUSDC',
184
+ tokenType: 'BB',
185
+ },
186
+ {
187
+ blockNumber: 0,
188
+ idleDecimals: 18,
189
+ cdoAddress: '0xA8d747Ef758469e05CF505D708b2514a1aB9Cc08',
190
+ idleAddress: '0x454bb3cb427b21e1c052a080e21a57753cd6969e',
191
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
192
+ decimals: 18,
193
+ idleSymbol: 'AA_Re7WETH',
194
+ tokenType: 'AA',
195
+ },
196
+ {
197
+ blockNumber: 0,
198
+ idleDecimals: 18,
199
+ cdoAddress: '0xA8d747Ef758469e05CF505D708b2514a1aB9Cc08',
200
+ idleAddress: '0x20aa3cd83044d2903181f7ef5c2b498a017d1c4a',
201
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
202
+ decimals: 18,
203
+ idleSymbol: 'BB_Re7WETH',
204
+ tokenType: 'BB',
205
+ },
206
+ {
207
+ blockNumber: 0,
208
+ idleDecimals: 18,
209
+ cdoAddress: '0xD071EA5D2575E155E4e9c2234968D1E11B8a920E',
210
+ idleAddress: '0xb9d321b26095195610707597aab416925c598aab',
211
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
212
+ decimals: 18,
213
+ idleSymbol: 'AA_Re7WETH',
214
+ tokenType: 'AA',
215
+ },
216
+ {
217
+ blockNumber: 0,
218
+ idleDecimals: 18,
219
+ cdoAddress: '0xD071EA5D2575E155E4e9c2234968D1E11B8a920E',
220
+ idleAddress: '0xf529f10fe24367d3a123faf0e9d5f6d80980b46f',
221
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
222
+ decimals: 18,
223
+ idleSymbol: 'BB_Re7WETH',
224
+ tokenType: 'BB',
225
+ },
226
+ {
227
+ blockNumber: 0,
228
+ idleDecimals: 18,
229
+ cdoAddress: '0x9e0c5ee5e4B187Cf18B23745FCF2b6aE66a9B52f',
230
+ idleAddress: '0x28d8a22c6689ac1e2ddc43ca6f85c520457351c1',
231
+ address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
232
+ decimals: 18,
233
+ idleSymbol: 'AA_ampr-LP-ETH',
234
+ tokenType: 'AA',
235
+ },
236
+ {
237
+ blockNumber: 0,
238
+ idleDecimals: 18,
239
+ cdoAddress: '0x9e0c5ee5e4B187Cf18B23745FCF2b6aE66a9B52f',
240
+ idleAddress: '0xefc4f43737fd336fa8a8254454ced1e421804b16',
241
+ address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
242
+ decimals: 18,
243
+ idleSymbol: 'BB_ampr-LP-ETH',
244
+ tokenType: 'BB',
245
+ },
246
+ {
247
+ blockNumber: 0,
248
+ idleDecimals: 18,
249
+ cdoAddress: '0x1EB1b47D0d8BCD9D761f52D26FCD90bBa225344C',
250
+ idleAddress: '0xf3188697bd35df73e4293d04a07ebaaf1ffc4018',
251
+ address: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3',
252
+ decimals: 18,
253
+ idleSymbol: 'AA_sUSDe',
254
+ tokenType: 'AA',
255
+ },
256
+ {
257
+ blockNumber: 0,
258
+ idleDecimals: 18,
259
+ cdoAddress: '0x1EB1b47D0d8BCD9D761f52D26FCD90bBa225344C',
260
+ idleAddress: '0xb8d0be502a8f12cc5213733285b430a43d07349d',
261
+ address: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3',
262
+ decimals: 18,
263
+ idleSymbol: 'BB_sUSDe',
264
+ tokenType: 'BB',
265
+ },
266
+ {
267
+ blockNumber: 0,
268
+ idleDecimals: 18,
269
+ cdoAddress: '0xbc48967C34d129a2ef25DD4dc693Cc7364d02eb9',
270
+ idleAddress: '0x0f09a04ad551dd941b589625bd2360fc962ff9f7',
271
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
272
+ decimals: 18,
273
+ idleSymbol: 'AA_dWETHV3',
274
+ tokenType: 'AA',
275
+ },
276
+ {
277
+ blockNumber: 0,
278
+ idleDecimals: 18,
279
+ cdoAddress: '0xbc48967C34d129a2ef25DD4dc693Cc7364d02eb9',
280
+ idleAddress: '0x1223ddeee77f8f379ea7a49e7650ff1ec1e2de8a',
281
+ address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
282
+ decimals: 18,
283
+ idleSymbol: 'BB_dWETHV3',
284
+ tokenType: 'BB',
285
+ },
286
+ {
287
+ blockNumber: 0,
288
+ idleDecimals: 18,
289
+ cdoAddress: '0xdd4D030A4337CE492B55bc5169F6A9568242C0Bc',
290
+ idleAddress: '0x450c055a00226f1eba09e8d9627034565b7c4c8a',
291
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
292
+ decimals: 6,
293
+ idleSymbol: 'AA_dUSDCV3',
294
+ tokenType: 'AA',
295
+ },
296
+ {
297
+ blockNumber: 0,
298
+ idleDecimals: 18,
299
+ cdoAddress: '0xdd4D030A4337CE492B55bc5169F6A9568242C0Bc',
300
+ idleAddress: '0x2a84a042db06222c486bcb815e961f26599d0df6',
301
+ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
302
+ decimals: 6,
303
+ idleSymbol: 'BB_dUSDCV3',
304
+ tokenType: 'BB',
305
+ },
306
+ ];
307
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/idle-dao/config.ts"],"names":[],"mappings":";;;A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QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,SAAS,EAAE,IAAI;KAChB;IACD;QACE,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,4CAA4C;QACxD,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,4CAA4C;QACrD,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,YAAY;QACxB,SAAS,EAAE,IAAI;KAChB;IACD;QACE,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,4CAA4C;QACxD,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,4CAA4C;QACrD,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,YAAY;QACxB,SAAS,EAAE,IAAI;KAChB;CACF,CAAC"}
@@ -0,0 +1,56 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { Contract } from 'web3-eth-contract';
3
+ import { Interface } from '@ethersproject/abi';
4
+ import { DeepReadonly } from 'ts-essentials';
5
+ import { Log, Logger } from '../../types';
6
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
7
+ import { IDexHelper } from '../../dex-helper/idex-helper';
8
+ import { PoolState, IdleToken } from './types';
9
+ import { IdleDao } from './idle-dao';
10
+ declare type BlocksTransfers = Record<number, {
11
+ underlyingAmount: BigNumber;
12
+ idleAmount: BigNumber;
13
+ processed: boolean;
14
+ }>;
15
+ export declare class IdleDaoEventPool extends StatefulEventSubscriber<PoolState> {
16
+ readonly parentName: string;
17
+ protected network: number;
18
+ protected dexHelper: IDexHelper;
19
+ protected logger: Logger;
20
+ protected idleToken: IdleToken;
21
+ protected IdleDao: IdleDao;
22
+ handlers: {
23
+ [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => Promise<DeepReadonly<PoolState> | null>;
24
+ };
25
+ logDecoder: (log: Log) => any;
26
+ cdoContract: Contract;
27
+ poolInterface: Interface;
28
+ addressesSubscribed: string[];
29
+ blocksTransfers: BlocksTransfers;
30
+ constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, idleToken: IdleToken, IdleDao: IdleDao);
31
+ /**
32
+ * The function is called every time any of the subscribed
33
+ * addresses release log. The function accepts the current
34
+ * state, updates the state according to the log, and returns
35
+ * the updated state.
36
+ * @param state - Current state of event subscriber
37
+ * @param log - Log released by one of the subscribed addresses
38
+ * @returns Updates state of the event subscriber after the log
39
+ */
40
+ protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): Promise<DeepReadonly<PoolState> | null>;
41
+ /**
42
+ * The function generates state using on-chain calls. This
43
+ * function is called to regenerate state if the event based
44
+ * system fails to fetch events and the local state is no
45
+ * more correct.
46
+ * @param blockNumber - Blocknumber for which the state should
47
+ * should be generated
48
+ * @returns state of the event subscriber at blocknumber
49
+ */
50
+ generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
51
+ setBlockState(blockNumber: number, state: PoolState): void;
52
+ handleCoinTransfer(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
53
+ processBlockTransfer(blockNumber: number, state: PoolState): PoolState;
54
+ handleCoinTransfer_old(event: any, state: PoolState, log: Log): Promise<DeepReadonly<PoolState> | null>;
55
+ }
56
+ export {};