Skip to content

Instantly share code, notes, and snippets.

@schystz
Created February 14, 2023 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schystz/13e19660865d00f7099250aae8f61bc1 to your computer and use it in GitHub Desktop.
Save schystz/13e19660865d00f7099250aae8f61bc1 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.7.6+commit.7338295f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.7.0;
import "@balancer-labs/v2-interfaces/contracts/pool-utils/IRateProvider.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol";
import "https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/solidity-utils/contracts/openzeppelin/ERC20.sol";
contract MockRateProvider is IRateProvider {
uint256 internal _rate;
uint256 internal _virtualSupply;
IERC20 internal _mainToken;
constructor(IERC20 mainToken) {
_rate = FixedPoint.ONE;
_virtualSupply = 1000000 * 1e18;
_mainToken = mainToken;
}
function getRate() external view override returns (uint256) {
return _rate;
}
function mockRate(uint256 newRate) external {
_rate = newRate;
}
function getVirtualSupply() external view returns (uint256) {
return _virtualSupply;
}
function mockVirtualSupply(uint256 virtualSupply) external {
_virtualSupply = virtualSupply;
}
function getMainToken() external view returns (IERC20) {
return _mainToken;
}
function mockMainToken(IERC20 mainToken) external {
_mainToken = mainToken;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment