From 34c27cac72f9f9a61ff1001add9c3d089fd37030 Mon Sep 17 00:00:00 2001 From: jaderiverstokes Date: Tue, 26 Nov 2024 15:43:04 -0800 Subject: [PATCH] cleanup --- contracts/scripts/VotingEscrowDepositor.s.sol | 29 ----- contracts/src/governance/IVotingEscrow.sol | 12 -- .../src/governance/SmartWalletChecker.sol | 63 ----------- contracts/src/governance/VotingEscrow.vy | 5 +- .../src/governance/VotingEscrowDepositor.sol | 65 ----------- .../src/test/VotingEscrowDepositor.t.sol | 105 ------------------ ui/components/nance/DePrize.tsx | 1 - ui/components/subscription/TeamPreview.tsx | 36 ------ 8 files changed, 2 insertions(+), 314 deletions(-) delete mode 100644 contracts/scripts/VotingEscrowDepositor.s.sol delete mode 100644 contracts/src/governance/SmartWalletChecker.sol delete mode 100644 contracts/src/governance/VotingEscrowDepositor.sol delete mode 100644 contracts/src/test/VotingEscrowDepositor.t.sol delete mode 100644 ui/components/subscription/TeamPreview.tsx diff --git a/contracts/scripts/VotingEscrowDepositor.s.sol b/contracts/scripts/VotingEscrowDepositor.s.sol deleted file mode 100644 index b11b2561a..000000000 --- a/contracts/scripts/VotingEscrowDepositor.s.sol +++ /dev/null @@ -1,29 +0,0 @@ -pragma solidity ^0.8.0; - -import "forge-std/Script.sol"; -import "../src/governance/VotingEscrowDepositor.sol"; - -contract MyScript is Script { - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - uint256 networkChainId = block.chainid; - address MOONEY; - address VMOONEY; - // arbitrum - if (networkChainId == 42161) { - MOONEY = 0x1Fa56414549BdccBB09916f61f0A5827f779a85c; - VMOONEY = 0xB255c74F8576f18357cE6184DA033c6d93C71899; - } else if (networkChainId == 11155111) { - MOONEY = 0x85A3C597F43B0cCE657793Cf31b05DF6969FbD2C; - VMOONEY = 0xA4F6A4B135b9AF7909442A7a3bF7797b61e609b1; - } else { - revert("Unsupported network"); - } - - - VotingEscrowDepositor sender = new VotingEscrowDepositor(MOONEY, VMOONEY); - - vm.stopBroadcast(); - } -} diff --git a/contracts/src/governance/IVotingEscrow.sol b/contracts/src/governance/IVotingEscrow.sol index 46e1c7956..d5877f211 100644 --- a/contracts/src/governance/IVotingEscrow.sol +++ b/contracts/src/governance/IVotingEscrow.sol @@ -10,16 +10,4 @@ interface IVotingEscrow { function locked(address) external view returns (LockedBalance memory); function balanceOf(address) external view returns (uint256); - function deploy_for(address _addr, uint256 _value) external; - function commit_smart_wallet_checker(address) external; - function apply_smart_wallet_checker() external; - - function admin() external view returns (address); - function create_lock(uint256 _value, uint256 _unlock_time) external; - function totalSupply() external view returns (uint256); - function checkpoint() external; - function user_point_history(address, uint256) external view returns (uint256, uint256); - function user_point_history__ts(address, uint256) external view returns (uint256); - function get_last_user_slope(address) external view returns (int128); - } diff --git a/contracts/src/governance/SmartWalletChecker.sol b/contracts/src/governance/SmartWalletChecker.sol deleted file mode 100644 index 752ec7a50..000000000 --- a/contracts/src/governance/SmartWalletChecker.sol +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -//import "@openzeppelin/contracts-4.2.0/access/Ownable.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; - -contract SmartWalletChecker is Ownable { - bool public isWhitelistEnabled; - mapping(address => bool) public wallets; - address public checker; - address public future_checker; - - event ApproveWallet(address); - event RevokeWallet(address); - event WhitelistEnabled(bool); - - constructor(bool _isWhitelistEnabled) public Ownable() { - // Set state variables - setIsWhitelistEnabled(_isWhitelistEnabled); - } - - function commitSetChecker(address _checker) external onlyOwner { - future_checker = _checker; - } - - function applySetChecker() external onlyOwner { - checker = future_checker; - } - - function approveWallet(address _wallet) external onlyOwner { - wallets[_wallet] = true; - - emit ApproveWallet(_wallet); - } - - function revokeWallet(address _wallet) external onlyOwner { - wallets[_wallet] = false; - - emit RevokeWallet(_wallet); - } - - function setIsWhitelistEnabled(bool _isWhitelistEnabled) public onlyOwner { - isWhitelistEnabled = _isWhitelistEnabled; - - emit WhitelistEnabled(_isWhitelistEnabled); - } - - function check(address _wallet) external view returns (bool) { - if (!isWhitelistEnabled) { - return true; - } - - bool _check = wallets[_wallet]; - if (_check) { - return _check; - } else { - if (checker != address(0)) { - return SmartWalletChecker(checker).check(_wallet); - } - } - return false; - } -} diff --git a/contracts/src/governance/VotingEscrow.vy b/contracts/src/governance/VotingEscrow.vy index 66fd976fd..bd09ec9b2 100644 --- a/contracts/src/governance/VotingEscrow.vy +++ b/contracts/src/governance/VotingEscrow.vy @@ -1,4 +1,4 @@ -# @version 0.3.1 +# @version 0.3.0 """ @title Voting Escrow @author Curve Finance @@ -94,7 +94,6 @@ epoch: public(uint256) point_history: public(Point[100000000000000000000000000000]) # epoch -> unsigned point user_point_history: public(HashMap[address, Point[1000000000]]) # user -> Point[user_epoch] user_point_epoch: public(HashMap[address, uint256]) - slope_changes: public(HashMap[uint256, int128]) # time -> signed slope change # Aragon's view methods for compatibility @@ -669,4 +668,4 @@ def changeController(_newController: address): @dev Dummy method required for Aragon compatibility """ assert msg.sender == self.controller - self.controller = _newController + self.controller = _newController \ No newline at end of file diff --git a/contracts/src/governance/VotingEscrowDepositor.sol b/contracts/src/governance/VotingEscrowDepositor.sol deleted file mode 100644 index 049308482..000000000 --- a/contracts/src/governance/VotingEscrowDepositor.sol +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts/access/Ownable.sol"; - -interface IERC20Interface { - function transfer(address recipient, uint256 amount) external returns (bool); - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); - function balanceOf(address account) external view returns (uint256); -} - -interface IVotingEscrowInterface { - function deposit_for(address _addr, uint256 _value) external; -} - -contract VotingEscrowDepositor is Ownable{ - IERC20Interface public token; - IVotingEscrowInterface public escrowToken; - // map from address to amount availabe to withdraw - mapping(address => uint256) public availableToWithdraw; - address[] public withdrawAddresses; - - constructor(address _tokenAddress, address _escrowTokenAddress){ - token = IERC20Interface(_tokenAddress); - escrowToken = IVotingEscrowInterface(_escrowTokenAddress); - } - - function increaseWithdrawAmounts(address[] memory addresses, uint256[] memory amounts) external onlyOwner{ - require(addresses.length == amounts.length, "Arrays must be of equal length"); - uint256 totalAmount = 0; - for (uint256 i = 0; i < addresses.length; i++) { - if (availableToWithdraw[addresses[i]] == 0) { - withdrawAddresses.push(addresses[i]); - } - availableToWithdraw[addresses[i]] += amounts[i]; - totalAmount += amounts[i]; - } - require(token.transferFrom(msg.sender, address(this), totalAmount), "Token transfer failed"); - } - - function clearWithdrawAmounts() external onlyOwner { - for (uint256 i = 0; i < withdrawAddresses.length; i++) { - availableToWithdraw[withdrawAddresses[i]] = 0; - } - delete withdrawAddresses; - } - - function withdraw() external { - uint256 amount = availableToWithdraw[msg.sender]; - require(amount > 0, "No amount available to withdraw"); - availableToWithdraw[msg.sender] = 0; - require(token.transfer(msg.sender, amount), "Token transfer failed"); - escrowToken.deposit_for(msg.sender, amount); - } - - function returnTokens() external onlyOwner { - uint256 balance = token.balanceOf(address(this)); - require(token.transfer(msg.sender, balance), "Token transfer failed"); - } - - function sendVotingEscrowTokens(address _addr, uint256 _value) external onlyOwner { - require(token.transfer(_addr, _value), "Token transfer failed"); - escrowToken.deposit_for(_addr, _value); - } -} diff --git a/contracts/src/test/VotingEscrowDepositor.t.sol b/contracts/src/test/VotingEscrowDepositor.t.sol deleted file mode 100644 index 8f5934d1a..000000000 --- a/contracts/src/test/VotingEscrowDepositor.t.sol +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "forge-std/Test.sol"; -import "../governance/VotingEscrowDepositor.sol"; -import "../governance/SmartWalletChecker.sol"; -import "../governance/IVotingEscrow.sol"; -import "../tokens/MyToken.sol"; - -//Using deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -//Deploying MOONEY.. -//Deployed MOONEY to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 -//Minted 0.0000000001 tokens to deployer address -//Deploying vMOONEY.. -//Deployed vMOONEY to: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 -//Deployment manifest saved to ./deployments/local.json - -contract VotingEscrowDepositorTest is Test { - VotingEscrowDepositor public depositor; - MyToken public token; - IVotingEscrow public escrowToken; - SmartWalletChecker public checker; - - //0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 - address public user = address(0x123); - //uint256 public initialBalance = 1000; - uint256 public initialBalance = 126144000 * 2; - uint256 depositAmount = 126144000; - - address public MOONEY = 0x5FbDB2315678afecb367f032d93F642f64180aa3; - - address public vMOONEY = 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512; - - - function setUp() public { - token = MyToken(MOONEY); - - escrowToken = IVotingEscrow(vMOONEY); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - depositor = new VotingEscrowDepositor(address(MOONEY), address(vMOONEY)); - checker = new SmartWalletChecker(true); - checker.approveWallet(address(depositor)); - // TODO we really shouldn't need this? - checker.approveWallet(address(user)); - //escrowToken.admin(); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - escrowToken.commit_smart_wallet_checker(address(checker)); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - escrowToken.apply_smart_wallet_checker(); - //token.transfer(address(depositor), initialBalance); - address[] memory addresses = new address[](1); - addresses[0] = address(user); - uint256[] memory amounts = new uint256[](1); - amounts[0] = depositAmount; - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - token.approve(address(depositor), depositAmount); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - depositor.increaseWithdrawAmounts(addresses, amounts); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - token.transfer(address(user), initialBalance); - vm.prank(user); - token.approve(address(escrowToken), initialBalance); - vm.prank(user); - escrowToken.create_lock(initialBalance, block.timestamp + 4*60 * 60 * 24 * 365); - // Mint tokens for the depositor contract to transfer - //token.mint(address(depositor), initialBalance); - vm.prank(user); - token.approve(address(escrowToken), depositAmount); - vm.prank(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - depositor.sendVotingEscrowTokens(address(user), depositAmount); - } - - function testTransferAndDepositFor() public { - //uint256 depositAmount = 500; - - - // Verify initial balances and deposits - //assertEq(token.balanceOf(address(depositor)), initialBalance); - //assertEq(token.balanceOf(user), 0); - //assertEq(escrowToken.balanceOf(user), initialBalance); - escrowToken.checkpoint(); - - //assertEq(escrowToken.admin(), address(0)); - - // Call transfer_and_deposit_for - vm.prank(user); - //depositor.transfer_and_deposit_for(user, depositAmount); - //depositor.withdraw(); - - // Verify token transfer - //assertEq(token.balanceOf(address(depositor)), initialBalance - depositAmount); - //assertEq(token.balanceOf(user), 0); - ////assertEq(escrowToken.totalSupply(), initialBalance + depositAmount); - //escrowToken.user_point_history(user, 0); - //escrowToken.user_point_history(user, 1); - //escrowToken.user_point_history(user, 2); - //escrowToken.get_last_user_slope(user); - //escrowToken.user_point_history__ts(user, 0); - //escrowToken.user_point_history__ts(user, 1); - //escrowToken.user_point_history__ts(user, 2); - - //// Verify escrow deposit - assertEq(escrowToken.balanceOf(user), depositAmount + initialBalance); - } -} diff --git a/ui/components/nance/DePrize.tsx b/ui/components/nance/DePrize.tsx index 077fe0d20..e12f1345c 100644 --- a/ui/components/nance/DePrize.tsx +++ b/ui/components/nance/DePrize.tsx @@ -39,7 +39,6 @@ import ContentLayout from '@/components/layout/ContentLayout' import Head from '@/components/layout/Head' import { NoticeFooter } from '@/components/layout/NoticeFooter' import { JoinDePrizeModal } from '@/components/nance/JoinDePrizeModal' -import { TeamPreview } from '@/components/subscription/TeamPreview' import StandardButton from '../layout/StandardButton' import { useVotingPowers } from '@/lib/snapshot' import useTokenBalances from '@/lib/tokens/hooks/useTokenBalances' diff --git a/ui/components/subscription/TeamPreview.tsx b/ui/components/subscription/TeamPreview.tsx deleted file mode 100644 index 2ab8902f2..000000000 --- a/ui/components/subscription/TeamPreview.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { NFT, ThirdwebNftMedia } from '@thirdweb-dev/react' -import { useEffect, useState } from 'react' - -type TeamPreviewProps = { - teamId: any - teamContract?: any -} - -export function TeamPreview({ teamId, teamContract }: TeamPreviewProps) { - const [teamNFT, setTeamNFT] = useState() - - useEffect(() => { - async function getTeamNFT() { - const nft = await teamContract.erc721.get(teamId) - setTeamNFT(nft) - } - - if (teamContract?.erc721?.get && teamId) { - getTeamNFT() - } - }, [teamId, teamContract]) - - return ( -
- {teamNFT && ( -
- -
- )} -
- ) -}