V3Tool.sol 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //SPDX-License-Identifier: Unlicense
  2. pragma solidity ^0.7.6;
  3. pragma abicoder v2;
  4. import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
  5. import '@uniswap/v3-periphery/contracts/NonfungiblePositionManager.sol';
  6. import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol';
  7. contract V3Tool {
  8. NonfungiblePositionManager private positionManager;
  9. IUniswapV3Factory private factory;
  10. constructor(address payable _positionManager, address payable _factory) {
  11. positionManager = NonfungiblePositionManager(_positionManager);
  12. factory = IUniswapV3Factory(_factory);
  13. }
  14. struct PositionInfo {
  15. address lp;
  16. address token0;
  17. string symbol0;
  18. uint24 decimals0;
  19. uint256 r0;
  20. address token1;
  21. string symbol1;
  22. uint24 decimals1;
  23. uint256 r1;
  24. uint24 feei;
  25. }
  26. function getMoreInfo(address token0, address token1, uint24 fee) public view returns (
  27. address lp,
  28. string memory symbol0,
  29. uint24 decimals0,
  30. uint256 r0,
  31. string memory symbol1,
  32. uint24 decimals1,
  33. uint256 r1
  34. ) {
  35. ERC20 token0Obj = ERC20(token0);
  36. ERC20 token1Obj = ERC20(token1);
  37. address lp = factory.getPool(token0, token1, fee);
  38. return (lp, token0Obj.symbol(), token0Obj.decimals(), token0Obj.balanceOf(lp),
  39. token1Obj.symbol(), token1Obj.decimals(), token1Obj.balanceOf(lp));
  40. }
  41. }