This commit is contained in:
Alexey 2020-10-08 12:06:43 +03:00
parent 98f4d06e14
commit 91dcea570c
4 changed files with 46 additions and 8 deletions

View File

@ -6,5 +6,32 @@ pragma experimental ABIEncoderV2;
import "./GovernanceAggregator.sol";
import "./PriceAggregator.sol";
import "./SwapAggregator.sol";
import "./MinerAggregator.sol";
contract Aggregator is GovernanceAggregator, PriceAggregator, SwapAggregator {}
contract Aggregator is GovernanceAggregator, PriceAggregator, SwapAggregator, MinerAggregator {
function miningData(
Miner miner,
address[] calldata instances,
RewardSwap swap
)
external
view
returns (
uint256[] memory _rates,
uint256 balance,
uint256 poolWeight
)
{
_rates = minerRates(miner, instances);
(balance, poolWeight) = swapState(swap);
}
function marketData(
address[] calldata fromTokens,
uint256[] calldata oneUnitAmounts,
RewardSwap swap
) external view returns (uint256[] memory prices, uint256 balance) {
prices = getPricesInETH(fromTokens, oneUnitAmounts);
balance = swap.tornVirtualBalance();
}
}

View File

@ -23,7 +23,7 @@ contract GovernanceAggregator {
Governance governance,
uint256 from,
uint256 to
) external view returns (Proposal[] memory proposals) {
) public view returns (Proposal[] memory proposals) {
uint256 proposalCount = governance.proposalCount();
to = to == 0 ? proposalCount : to;
proposals = new Proposal[](proposalCount);
@ -56,11 +56,7 @@ contract GovernanceAggregator {
}
}
function getGovernanceBalances(Governance governance, address[] calldata accs)
external
view
returns (uint256[] memory amounts)
{
function getGovernanceBalances(Governance governance, address[] calldata accs) public view returns (uint256[] memory amounts) {
amounts = new uint256[](accs.length);
for (uint256 i = 0; i < accs.length; i++) {
amounts[i] = governance.balances(accs[i]);

View File

@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import "tornado-anonymity-mining/contracts/Miner.sol";
contract MinerAggregator {
function minerRates(Miner miner, address[] calldata instances) public view returns (uint256[] memory _rates) {
_rates = new uint256[](instances.length);
for (uint256 i = 0; i < _rates.length; i++) {
_rates[i] = miner.rates(instances[i]);
}
}
}

View File

@ -6,7 +6,7 @@ pragma experimental ABIEncoderV2;
import "tornado-anonymity-mining/contracts/RewardSwap.sol";
contract SwapAggregator {
function swapState(RewardSwap swap) external view returns (uint256 balance, uint256 poolWeight) {
function swapState(RewardSwap swap) public view returns (uint256 balance, uint256 poolWeight) {
balance = swap.tornVirtualBalance();
poolWeight = swap.poolWeight();
}