Skip to content

Commit

Permalink
feat: Deprecated pools lens for mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
DeFIBrain88 committed May 8, 2024
1 parent 8025e2f commit 9be10f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
21 changes: 6 additions & 15 deletions contracts/powerindex-mining/DeprecatedPoolsLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ https://powerpool.finance/

pragma solidity 0.8.11;

import "hardhat/console.sol";

interface IUniswapV2Router {
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external view returns (uint256 amountB);
}

interface IVestedLpMining {
function pools(uint256 index) external view returns (Pool calldata);
function users(uint256 poolId, address userAddress) external view returns (miningUserDataStruct calldata);
Expand Down Expand Up @@ -137,6 +130,7 @@ struct LiquidityTokens {
address tokenAddress;
uint256 balance;
uint8 decimals;
string symbol;
uint256 tokenAmountForOneLpSingle;
uint256 tokenAmountForOneLpMulti;
}
Expand All @@ -161,23 +155,15 @@ struct RemoveLiquidityData {

contract DeprecatedPoolsLens {
IVestedLpMining public mining;
IUniswapV2Router public uniRouter;

address public stableAddress;
address immutable public wethAddress;
address immutable public cvpAddress;
mapping(uint8 => uint8) public earnPidMap;

constructor(
IVestedLpMining _mining,
IUniswapV2Router _router,
address _wethAddress,
address _stableAddress,
address _cvpAddress
) {
mining = _mining;
uniRouter = _router;
wethAddress = _wethAddress;
cvpAddress = _cvpAddress;

earnPidMap[0] = 13;
Expand Down Expand Up @@ -400,6 +386,11 @@ contract DeprecatedPoolsLens {
token.tokenAddress = ILpToken(pool.lpToken).getFinalTokens()[i];
token.balance = ERC20(ILpToken(pool.lpToken).getFinalTokens()[i]).balanceOf(_user);
token.decimals = ERC20(ILpToken(pool.lpToken).getFinalTokens()[i]).decimals();
if (ILpToken(pool.lpToken).getFinalTokens()[i] == 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2) {
token.symbol = 'MKR';
} else {
token.symbol = ILpToken(ILpToken(pool.lpToken).getFinalTokens()[i]).symbol();
}
token.tokenAmountForOneLpSingle = getSingleTokenOut(_pid, token.tokenAddress);
token.tokenAmountForOneLpMulti = getMultiTokensOut(_pid, token.tokenAddress, token.decimals);
}
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const config = {
mainnet: {
url: 'https://rough-compatible-hill.quiknode.pro/b7052dc47d31d455c2a770377f7db70735924fba/',
accounts: getAccounts('mainnet'),
gasPrice: 9 * 10 ** 9,
gasPrice: 5 * 10 ** 9,
gasMultiplier: 1.2,
timeout: 2000000,
},
Expand Down
3 changes: 0 additions & 3 deletions tasks/deployDeprecatedPoolsLens.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ task('deploy-deprecated-pools-lens', 'Deploy deprecated pools lens').setAction(a
const sendOptions = { from: deployer };
const poolsLens = await PoolsLens.new(
'0xF09232320eBEAC33fae61b24bB8D7CA192E58507',
'0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
'0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1',
sendOptions,
);
Expand Down
7 changes: 2 additions & 5 deletions test/DeprecatedPoolsLens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ describe.only('DeprecatedPoolsLens', async () => {
it('chore test pass', async () => {
this.poolsLens = await PoolsLens.new(
'0xF09232320eBEAC33fae61b24bB8D7CA192E58507',
'0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
'0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1',
);
// const result = await this.poolsLens.getPoolData(ethers.constants.AddressZero);
// const result = await this.poolsLens.getFarmingDetail('0x8b19f6F51501dA80FCEFb578427907f223005F7A', 6);
// const result = await this.poolsLens.getEarnList('0x8b19f6F51501dA80FCEFb578427907f223005F7A');

const result = await this.poolsLens.RemoveLiquidityInfo('0x8b19f6F51501dA80FCEFb578427907f223005F7A', 6); // balancer
// const result = await this.poolsLens.removeLiquidityInfo('0x8b19f6F51501dA80FCEFb578427907f223005F7A', 6); // balancer

// const result = await this.poolsLens.getSecondaryLiquidityRemoveInfo('0x8b19f6F51501dA80FCEFb578427907f223005F7A', 7); // balancer
// const result = await this.poolsLens.getSecondaryLiquidityRemoveInfo('0x8b19f6F51501dA80FCEFb578427907f223005F7A', 11); // sushi
Expand Down
5 changes: 1 addition & 4 deletions verify-args.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = [
'0xF09232320eBEAC33fae61b24bB8D7CA192E58507',
'0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
'0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1'
'0x38e4adB44ef08F22F5B5b76A8f0c2d0dCbE7DcA1',
]

0 comments on commit 9be10f4

Please sign in to comment.