Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x-chain gauge factory contracts w/ basic tests and deploy scripts #684

Merged
merged 75 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a43e037
adding files is state where tests work
lilPlumberBoy Aug 7, 2022
4d7990b
root gauge factory tests, child gauge factory initialize
lilPlumberBoy Aug 7, 2022
6143176
child gauge initial tests
lilPlumberBoy Aug 7, 2022
35397db
added oracles and arbitrum bridger
lilPlumberBoy Aug 8, 2022
52b8fac
fixed oracles and added test for oracle
lilPlumberBoy Aug 10, 2022
37e4cf8
updated todo comments
lilPlumberBoy Aug 10, 2022
3953509
updated Anycall translator and anycall mock contracts
lilPlumberBoy Aug 10, 2022
2c89acb
added rootgaugeFactory tests
lilPlumberBoy Aug 15, 2022
c42796d
updated mock anycall contract
lilPlumberBoy Aug 15, 2022
d85870e
updated translator / mock anycall contracts
lilPlumberBoy Aug 16, 2022
e4211c6
finalized AnycallTranslator contract
lilPlumberBoy Aug 17, 2022
04252f4
updated translator contract with all accepted function calls
lilPlumberBoy Aug 18, 2022
134d435
finalized oracle contracts
lilPlumberBoy Aug 18, 2022
7651453
finalized gauge implementations
lilPlumberBoy Aug 18, 2022
506bcc2
added Optimism bridger, cleaned up comments
lilPlumberBoy Aug 19, 2022
2779ea1
removed delegatecall from translator
lilPlumberBoy Aug 22, 2022
c5c39a8
naming changes
lilPlumberBoy Aug 22, 2022
ba6528e
Script for enabling on chain gauge voting (#691)
penandlim Aug 23, 2022
b3ee040
updated logic of RootGauge
lilPlumberBoy Aug 23, 2022
26cf50e
added logic for having a RootGauge name
lilPlumberBoy Aug 23, 2022
73761f5
fixed typing of name(), added to factory tests
lilPlumberBoy Aug 23, 2022
73e0975
updated tests to successfully deploy root gauge
lilPlumberBoy Aug 24, 2022
ec2bd62
Added to RootGauge Factory tests
lilPlumberBoy Aug 24, 2022
077091f
added deposit and rescue functios to translator
lilPlumberBoy Aug 25, 2022
db01441
added fixture to RootGauge Factory Test
lilPlumberBoy Aug 26, 2022
ecb4898
added todo comments
lilPlumberBoy Aug 26, 2022
100fab4
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Aug 29, 2022
bcbb6cd
Add deploy script and deployment data for non-flashloan swaps (#690)
penandlim Aug 29, 2022
b015eb0
Updates pool reg for FraxBP USDs pool (#686)
lilPlumberBoy Aug 29, 2022
7a1e6f4
Add separate tests for permissionless contracts (#681)
penandlim Aug 29, 2022
e617760
Fix root gauge factory test.
penandlim Aug 30, 2022
a9fb855
Fix capitalization in file names
penandlim Aug 30, 2022
65ff70d
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Aug 30, 2022
81cb5b6
Fix test imports and types
penandlim Aug 30, 2022
1cc4126
Lint x chain gauges contracts
penandlim Aug 30, 2022
4660b11
Deploy root gauge factory on hardhat
penandlim Aug 30, 2022
b3a4aca
Deploy script for fake USDC (#693)
penandlim Aug 31, 2022
8705a8b
Run prepare scripts by default on hardhat (#694)
penandlim Sep 1, 2022
d6d1bca
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 1, 2022
35a574b
Add the deployed gauge to gauge controller
penandlim Sep 1, 2022
1ea65f9
Updates hardhat and migrate from waffle to hardhat chai matchers (#696)
penandlim Sep 2, 2022
a6ef5e6
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 2, 2022
82c7294
Fix function name to include parameters for overloading
penandlim Sep 2, 2022
bd7a6a6
Adds 2 new node dependencies (#699)
penandlim Sep 3, 2022
4cb5c4a
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 3, 2022
4397cfa
Update AnyCallTranslator to be a proxy. Updates the test.
penandlim Sep 3, 2022
475fe9e
Change signatures to match up between contracts
penandlim Sep 3, 2022
a56722c
Add test for sidechain -> root chain deploy_gauge()
penandlim Sep 3, 2022
514f8f6
Fix encoding type
penandlim Sep 3, 2022
054160e
Use proxy in deploy script
penandlim Sep 3, 2022
1036f02
ChildOracle emits an event when recieving
penandlim Sep 6, 2022
1eadcbf
Cleans up hardhat config file and moves tasks into tasks folder (#698)
penandlim Sep 7, 2022
86cdb3a
Merge remote-tracking branch 'origin/master' into mike/xchain_factory…
penandlim Sep 7, 2022
030e0b3
Add deploy scripts for optimism mainnet
penandlim Sep 7, 2022
eb53ff2
Improve fork settings (#700)
penandlim Sep 7, 2022
29d5572
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 7, 2022
ab901b1
Add deploy scripts
penandlim Sep 7, 2022
b682f63
Deploy a child gauge for SaddleFRAXBPPoolLPToken
penandlim Sep 7, 2022
b586b10
Adds `patch-package` to apply fix for Arbitrum Nitro (#701)
penandlim Sep 7, 2022
ac7dbc5
Update USDS pool in pool registry (#702)
penandlim Sep 8, 2022
bebb517
Merge remote-tracking branch 'origin/master' into mike/xchain_factory…
penandlim Sep 8, 2022
4a3a7ce
Fix duplicate contract names
penandlim Sep 8, 2022
c3ee3c7
Add deploy scripts for mainnet. Only run when forking for now
penandlim Sep 8, 2022
38db655
Update RootOracle contract and test
penandlim Sep 13, 2022
a86904b
USDT pool deploy (#703)
lilPlumberBoy Sep 13, 2022
45bbac6
Update hardhat to 2.11.1 and associated dependencies (#704)
penandlim Sep 13, 2022
a885d88
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 13, 2022
9ef6075
Test for each storage variable separately
penandlim Sep 13, 2022
ad84491
Change file name cases to be in consistent style
penandlim Sep 13, 2022
c9b1d80
Update RootGaugeFactory tests
penandlim Sep 13, 2022
cd9c406
Include prefix and suffix on Gauge names
penandlim Sep 13, 2022
f41de1a
Update ChildGaugeFactory test
penandlim Sep 13, 2022
7bed302
Specify deploy tags for each test (#705)
penandlim Sep 13, 2022
525126f
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 13, 2022
f14521c
Merge branch 'master' into mike/xchain_factory_gauges
penandlim Sep 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
689 changes: 689 additions & 0 deletions contracts/tokenomics/gauges/CurveLiquidityGauge.vy

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions contracts/xchainGauges/AnycallTranslator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.6;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts-4.4.0/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-4.4.0/proxy/transparent/ProxyAdmin.sol";

import "@openzeppelin/contracts-upgradeable-4.4.0/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable-4.4.0/access/OwnableUpgradeable.sol";

interface ICallProxy {
function anyCall(
address _to,
bytes calldata _data,
address _fallback,
uint256 _toChainId,
uint256 _flags
) external payable; // nonpayable

function deposit(address _account) external payable;

function withdraw(uint256 amount) external;

function executor() external view returns (address executor);
}

interface IAnycallExecutor {
function context()
external
view
returns (
address from,
uint256 fromChainID,
uint256 nonce
);
}

// Empty contract to ensure import of TransparentUpgradeableProxy contract
contract EmptyProxy is TransparentUpgradeableProxy {
constructor(
address _logic,
address admin_,
bytes memory _data
) payable TransparentUpgradeableProxy(_logic, admin_, _data) {}
}

// Empty contract to ensure import of ProxyAdmin contract
contract EmptyProxyAdmin is ProxyAdmin {

}

// Logic contract that will be used by the proxy
contract AnyCallTranslator is OwnableUpgradeable {
using SafeERC20Upgradeable for IERC20Upgradeable;
// consts
address public anycallContract;
address public anyCallExecutor;
mapping(address => bool) public isKnownCaller;

constructor() initializer {
// logic contract
}

receive() external payable {
// fallback payable function
}

function initialize(address _owner, address _anycallContract)
public
initializer
{
_transferOwnership(_owner);
anycallContract = _anycallContract;
anyCallExecutor = ICallProxy(_anycallContract).executor();
}

function addKnownCallers(address[] calldata _callers) external onlyOwner {
for (uint256 i = 0; i < _callers.length; i++) {
isKnownCaller[_callers[i]] = true;
}
}

function removeKnownCallers(address[] calldata _callers)
external
onlyOwner
{
for (uint256 i = 0; i < _callers.length; i++) {
isKnownCaller[_callers[i]] = false;
}
}

function setAnycall(address _anycallContract) external onlyOwner {
anycallContract = _anycallContract;
anyCallExecutor = ICallProxy(_anycallContract).executor();
}

function withdraw(uint256 _amount) external onlyOwner {
ICallProxy(anycallContract).withdraw(_amount);
}

function rescue(IERC20Upgradeable token, address to) external onlyOwner {
token.safeTransfer(to, token.balanceOf(address(this)));
}

function anyCall(
address _to,
bytes calldata _data,
address _fallback,
uint256 _toChainId,
// Use 0 flag to pay fee on destination chain, 1 to pay on source
uint256 _flags
) external payable {
require(isKnownCaller[msg.sender], "Unknown caller");
ICallProxy(anycallContract).anyCall{value: msg.value}(
address(this),
abi.encode(_to, _data),
_fallback,
_toChainId,
_flags
);
}

function anyExecute(bytes calldata toAndData)
external
returns (bool, bytes memory)
{
// Check that caller is anycall executor
require(
msg.sender == anyCallExecutor,
"Caller is not anycall executor"
);
// Get address of anycallExecutor
(address _from, , ) = IAnycallExecutor(msg.sender).context();
// Check that caller is verified
require(_from == address(this), "Wrong context");

// Decode to and data
(address to, bytes memory data) = abi.decode(
toAndData,
(address, bytes)
);
(bool success, bytes memory returnData) = to.call(data);
require(success, "Proxy call failed");
return (success, returnData);
}
}
Loading