From 2d2216359d3a44d1406eac6df423fd47f2a2c195 Mon Sep 17 00:00:00 2001 From: Tarp Date: Sat, 15 Mar 2025 13:36:41 -0700 Subject: [PATCH] feat: pool data --- contracts/api/ExchangeHelper.sol | 24 +++++++++ .../deployments/monadTestnet/deployment.json | 49 ++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/contracts/api/ExchangeHelper.sol b/contracts/api/ExchangeHelper.sol index cce09ea..ddf7396 100644 --- a/contracts/api/ExchangeHelper.sol +++ b/contracts/api/ExchangeHelper.sol @@ -48,6 +48,30 @@ contract ExchangeHelper is Initializable { } } + struct PoolData { + address pair; + uint256 fee7; + uint256 tvl; + uint256 volume24; + } + function getPoolData(uint256 from, uint256 to) external view returns (PoolData[] memory pairFees) { + uint256 pairsLength = pairFactory.allPairsLength(); + pairFees= new PoolData[](pairsLength); + for (uint i; i < pairsLength; i++) { + // TODO: ONLY WHITELISTED PAIRS + // voter.isWhitelisted() + Pair pair = Pair(pairFactory.allPairs(i)); + (uint256 pairFee) = getFeesInUSDForPair(pair); + (,,,,uint256 volume) = getVolumeLockedPerTimeForPair(pair, from, to); + (,,uint256 tvl) = getTVLInUSDForPair(pair ); + pairFees[i] = PoolData({ + pair: address(pair), + fee7: pairFee, + tvl: tvl, + volume24:volume + }); + } + } /** * * @param pair Address of pair diff --git a/scripts/deployments/monadTestnet/deployment.json b/scripts/deployments/monadTestnet/deployment.json index b76632a..024a01d 100644 --- a/scripts/deployments/monadTestnet/deployment.json +++ b/scripts/deployments/monadTestnet/deployment.json @@ -9810,7 +9810,7 @@ ] }, "ExchangeHelper": { - "contractAddress": "0x7D7e0040890d06663AcbaDB11Fd5A4aAEc21B825", + "contractAddress": "0x0159f1cfE00e287f84d9d4D974Da2FEF1D6099Ac", "abi": [ { "inputs": [], @@ -9912,6 +9912,52 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "from", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "to", + "type": "uint256" + } + ], + "name": "getPoolData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "pair", + "type": "address" + }, + { + "internalType": "uint256", + "name": "fee7", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tvl", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume24", + "type": "uint256" + } + ], + "internalType": "struct ExchangeHelper.PoolData[]", + "name": "pairFees", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "getTVLInUSDForAllPairs", @@ -10136,3 +10182,4 @@ ] } } +