Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BalancerPoolBalanceChecker
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 100000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
// ====================================================================
// | ______ _______ |
// | / _____________ __ __ / ____(_____ ____ _____ ________ |
// | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ |
// | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ |
// | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ |
// | |
// ====================================================================
// =================== BalancerPoolBalanceChecker =====================
// ====================================================================
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IBalancerPool } from "./interfaces/IBalancerPool.sol";
import { IBalancerVault } from "./interfaces/IBalancerVault.sol";
/**
* @title BalancerPoolBalanceChecker
* @author Frax Finance
* @notice The BalancerPoolBalanceChecker contract is used to retrieve the balances of collateral and LP tokens of pools.
*/
contract BalancerPoolBalanceChecker {
IBalancerVault private balancerVault = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);
constructor() {}
/**
* @notice Used to get the structure of a pool.
* @dev Passing `0x0` address as the token address gets the native token balance.
* @param poolAddress Address of the pool to check the structure of
* @param tokens An array of tokens to check the balance of
* @return result An array of the balances of the tokens in the pool
* @return totalLpSupply The total supply of the LP token
*/
function poolStructure(
address poolAddress,
address[] memory tokens
) external view returns (uint256[] memory result, uint256 totalLpSupply) {
bytes32 poolId = 0x33251abecb0364df98a27a8d5d7b5ccddc774c42000000000000000000000008;
result = new uint256[](tokens.length);
for (uint256 i; i < tokens.length; ) {
(uint256 balance, , , ) = balancerVault.getPoolTokenInfo(poolId, IERC20(tokens[i]));
result[i] = balance;
unchecked {
++i;
}
}
totalLpSupply = IBalancerPool(poolAddress).getActualSupply();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IBalancerPool {
function getActualSupply() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IBalancerVault {
function getPoolTokenInfo(bytes32 poolId, IERC20 token)
external
view
returns (
uint256 cash,
uint256 managed,
uint256 lastChangeBlock,
address assetManager
);
}{
"remappings": [
"frax-std/=lib/frax-standard-solidity/src/",
"@eth-optimism/=lib/optimism/packages/",
"lib/optimism/packages/contracts-bedrock:src/=lib/optimism/packages/contracts-bedrock/src/",
"src/=src/",
"@openzeppelin-4/=node_modules/@openzeppelin-4/",
"@openzeppelin-5/=node_modules/@openzeppelin-5/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@rari-capital/=node_modules/@rari-capital/",
"clones-with-immutable-args/=lib/optimism/packages/contracts-bedrock/lib/clones-with-immutable-args/src/",
"ds-test/=lib/frax-standard-solidity/lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/frax-standard-solidity/lib/forge-std/src/",
"frax-standard-solidity/=lib/frax-standard-solidity/src/",
"kontrol-cheatcodes/=lib/optimism/packages/contracts-bedrock/lib/kontrol-cheatcodes/src/",
"lib-keccak/=lib/optimism/packages/contracts-bedrock/lib/lib-keccak/contracts/",
"openzeppelin-contracts-upgradeable/=lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/optimism/packages/contracts-bedrock/lib/openzeppelin-contracts/",
"optimism/=lib/optimism/",
"safe-contracts/=lib/optimism/packages/contracts-bedrock/lib/safe-contracts/contracts/",
"solady/=lib/optimism/packages/contracts-bedrock/lib/solady/",
"solidity-bytes-utils/=lib/frax-standard-solidity/lib/solidity-bytes-utils/",
"solmate/=lib/optimism/packages/contracts-bedrock/lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 100000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"poolStructure","outputs":[{"internalType":"uint256[]","name":"result","type":"uint256[]"},{"internalType":"uint256","name":"totalLpSupply","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6080604052600080546001600160a01b03191673ba12222222228d8ba445958a75a0704d566bf2c817905534801561003657600080fd5b506104a0806100466000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063839041d214610030575b600080fd5b61004361003e36600461029c565b61005a565b604051610051929190610394565b60405180910390f35b80516060906000907f33251abecb0364df98a27a8d5d7b5ccddc774c420000000000000000000000089067ffffffffffffffff81111561009c5761009c61026d565b6040519080825280602002602001820160405280156100c5578160200160208202803683370190505b50925060005b84518110156101be5760008054865173ffffffffffffffffffffffffffffffffffffffff9091169063b05f8e4890859089908690811061010d5761010d6103e1565b60200260200101516040518363ffffffff1660e01b815260040161015192919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b608060405180830381865afa15801561016e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101929190610410565b5050509050808583815181106101aa576101aa6103e1565b6020908102919091010152506001016100cb565b508473ffffffffffffffffffffffffffffffffffffffff1663876f303b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561020a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022e9190610451565b9150509250929050565b73ffffffffffffffffffffffffffffffffffffffff8116811461025a57600080fd5b50565b803561026881610238565b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b82356102ba81610238565b915060208381013567ffffffffffffffff808211156102d857600080fd5b818601915086601f8301126102ec57600080fd5b8135818111156102fe576102fe61026d565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f830116810181811085821117156103415761034161026d565b60405291825284820192508381018501918983111561035f57600080fd5b938501935b82851015610384576103758561025d565b84529385019392850192610364565b8096505050505050509250929050565b604080825283519082018190526000906020906060840190828701845b828110156103cd578151845292840192908401906001016103b1565b505050602093909301939093525092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000806000806080858703121561042657600080fd5b845193506020850151925060408501519150606085015161044681610238565b939692955090935050565b60006020828403121561046357600080fd5b505191905056fea264697066735822122006e769a552a5a531dc35d7e036627419c2a9acdc2050025befb86e1f2f08e25364736f6c63430008170033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063839041d214610030575b600080fd5b61004361003e36600461029c565b61005a565b604051610051929190610394565b60405180910390f35b80516060906000907f33251abecb0364df98a27a8d5d7b5ccddc774c420000000000000000000000089067ffffffffffffffff81111561009c5761009c61026d565b6040519080825280602002602001820160405280156100c5578160200160208202803683370190505b50925060005b84518110156101be5760008054865173ffffffffffffffffffffffffffffffffffffffff9091169063b05f8e4890859089908690811061010d5761010d6103e1565b60200260200101516040518363ffffffff1660e01b815260040161015192919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b608060405180830381865afa15801561016e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101929190610410565b5050509050808583815181106101aa576101aa6103e1565b6020908102919091010152506001016100cb565b508473ffffffffffffffffffffffffffffffffffffffff1663876f303b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561020a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022e9190610451565b9150509250929050565b73ffffffffffffffffffffffffffffffffffffffff8116811461025a57600080fd5b50565b803561026881610238565b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b82356102ba81610238565b915060208381013567ffffffffffffffff808211156102d857600080fd5b818601915086601f8301126102ec57600080fd5b8135818111156102fe576102fe61026d565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f830116810181811085821117156103415761034161026d565b60405291825284820192508381018501918983111561035f57600080fd5b938501935b82851015610384576103758561025d565b84529385019392850192610364565b8096505050505050509250929050565b604080825283519082018190526000906020906060840190828701845b828110156103cd578151845292840192908401906001016103b1565b505050602093909301939093525092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000806000806080858703121561042657600080fd5b845193506020850151925060408501519150606085015161044681610238565b939692955090935050565b60006020828403121561046357600080fd5b505191905056fea264697066735822122006e769a552a5a531dc35d7e036627419c2a9acdc2050025befb86e1f2f08e25364736f6c63430008170033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.