Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4b818f4
Made constructor take in governance, gave users ability to rescind vo…
Nov 4, 2021
b6b1443
Fixed a bug where deprecating a gauge messed up the total vote calcul…
Dec 5, 2021
eb314d3
Wrote GaugeProxyV3 Soft Migration test
Jan 5, 2022
7cbed0f
Completed GaugeProxyV3 tests
Jan 7, 2022
c6781af
Fixed merge conflicts
Jan 8, 2022
5be2c22
Cleaned up test code, added more comments
Jan 11, 2022
84bafb8
Split gauge proxy v3 migration into 4 phases
Jan 14, 2022
3a26d96
Minor stylistic changes
Jan 19, 2022
19b4d3e
Merge branch 'master' into gauge-proxy
Feb 2, 2022
b7c8b7d
Fix package-lock to match master
Feb 3, 2022
150928e
e Please enter the commit message for your changes. Lines starting
Feb 5, 2022
5819aa7
updating package-lock.json to match main branch
Feb 5, 2022
baea2eb
check for bayo
AbigailTCameron Feb 15, 2022
5c99ba7
break
AbigailTCameron Feb 15, 2022
cef5dc3
add github workflow ci test
fuzzylemma Feb 15, 2022
be5797a
update
AbigailTCameron Feb 16, 2022
3ab4f19
Merge branch 'gauge-proxy' of https://github.com/Snowball-Finance/pro…
AbigailTCameron Feb 16, 2022
b61be90
break
AbigailTCameron Feb 17, 2022
3ca184c
testing finished for proxyv3
AbigailTCameron Feb 18, 2022
9dc4aea
update
AbigailTCameron Feb 18, 2022
0a69dfe
gauge proxy v3
AbigailTCameron Feb 18, 2022
73e21ee
ready for review
AbigailTCameron Feb 23, 2022
144e54f
chore: remove generated types & update gitignore
bayological Feb 24, 2022
51aea33
Merge branch 'master' into gauge-proxy
bayological Feb 28, 2022
506fe2e
chore: add name, desc and version
bayological Feb 28, 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
21 changes: 21 additions & 0 deletions .github/workflows/test-gauge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Gauge Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
gauge:
runs-on: ubuntu-latest
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
WALLET_ADDR: ${{ secrets.WALLET_ADDR }}
SNOWTRACE_KEY: ${{ secrets.SNOWTRACE_KEY }}
NODE_OPTIONS: "--max_old_space_size=32184"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm i
- run: npx hardhat test test/gauge-proxy.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typings/

# Typechain generations
typechain/
typechain-types/

# TypeScript cache
*.tsbuildinfo
Expand Down
11 changes: 11 additions & 0 deletions contracts/interfaces/ierc20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
32 changes: 32 additions & 0 deletions contracts/lib/protocol-governance.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

contract ProtocolGovernance {
/// @notice governance address for the governance contract
address public governance;
address public pendingGovernance;

/**
* @notice modifier to allow for easy gov only control over a function
*/
modifier onlyGovernance() {
require(msg.sender == governance, "unauthorized sender (governance");
_;
}

/**
* @notice Allows governance to change governance (for future upgradability)
* @param _governance new governance address to set
*/
function setGovernance(address _governance) external onlyGovernance{
pendingGovernance = _governance;
}

/**
* @notice Allows pendingGovernance to accept their role as governance (protection pattern)
*/
function acceptGovernance() external {
require(msg.sender == pendingGovernance, "acceptGovernance: !pendingGov");
governance = pendingGovernance;
}
}
25 changes: 25 additions & 0 deletions contracts/lib/safe-math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,29 @@ library SafeMath {
require(b != 0, errorMessage);
return a % b;
}
}

library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}

/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}

/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
67 changes: 67 additions & 0 deletions contracts/lib/safeerc20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7; //^0.7.5;

import "./safe-math.sol";
import "../interfaces/ierc20.sol";

library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != 0x0 && codehash != accountHash);
}
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");

// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call{value:amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}

library SafeERC20 {
using SafeMath for uint256;
using Address for address;

function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}

function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");

// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");

if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Loading