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

refactor(supplementary-contracts): update TokenUnlocking scripts #17111

Merged
merged 14 commits into from May 13, 2024
Expand Up @@ -66,7 +66,10 @@ contract TokenUnlocking is OwnableUpgradeable, ReentrancyGuardUpgradeable {
external
initializer
{
if (_taikoToken == address(0) || _recipient == address(0) || _tgeTimestamp == 0) {
if (
_owner == _recipient || _owner == address(0) || _recipient == address(0)
|| _taikoToken == address(0) || _tgeTimestamp == 0
) {
revert INVALID_PARAM();
}

Expand Down
@@ -1,18 +1,15 @@
[
{
"name": "Alice",
"recipient": "0xa48dEBc18D5e63F1FB94DD513f643e412684f8a4",
"proxy": "0x33A270541f383A4A48dB6C5f1f00A161b8F79e2a",
"vestAmount": 35000
},
{
"name": "Bob",
"recipient": "0xa48dEBc18D5e63F1FB94DD513f643e412684f8a4",
"proxy": "0x33A270541f383A4A48dB6C5f1f00A161b8F79e2a",
"vestAmount": 25000
},
{
"name": "Carol",
"recipient": "0xa48dEBc18D5e63F1FB94DD513f643e412684f8a4",
"proxy": "0x33A270541f383A4A48dB6C5f1f00A161b8F79e2a",
"vestAmount": 15000
Expand Down
34 changes: 16 additions & 18 deletions packages/supplementary-contracts/script/tokenVesting/Vest.s.sol
Expand Up @@ -6,22 +6,18 @@ import "forge-std/src/console2.sol";

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

import "../../contracts/tokenUnlocking/TokenUnlocking.sol";

contract VestTokenUnlocking is Script {
using stdJson for string;

struct VestingItem {
bytes32 name; // Conversion from json "string" to bytes32 will take place in foundry,
// cannot use string here, as json parser cannot interpret string from json, everything
// is bytes-chunks. It is more of informational to script executor anyways.
address recipient;
address proxy;
uint256 vestAmount;
}

ERC20 private tko = ERC20(vm.envAddress("TAIKO_TOKEN"));
ERC20 private tko = ERC20(0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800);

function run() external {
vm.startBroadcast();
Expand All @@ -32,23 +28,25 @@ contract VestTokenUnlocking is Script {
);

for (uint256 i; i < items.length; i++) {
address proxy = items[i].proxy;
console2.logBytes32(items[i].name);
console2.log("Grantee unlocking contract address:", proxy);
console2.log("Vest amount (TKO):", items[i].vestAmount);
if (items[i].vestAmount != 0) {
address proxy = items[i].proxy;
console2.log("Grantee unlocking contract address:", proxy);
console2.log("Vest amount (TKO):", items[i].vestAmount);

require(TokenUnlocking(proxy).owner() == msg.sender, "msg.sender not owner");
require(
TokenUnlocking(proxy).recipient() == items[i].recipient, "inconsistent recipient"
);
require(TokenUnlocking(proxy).owner() == msg.sender, "msg.sender not owner");
require(
TokenUnlocking(proxy).recipient() == items[i].recipient,
"inconsistent recipient"
);

uint128 vestAmount = uint128(items[i].vestAmount * 1e18);
require(tko.balanceOf(msg.sender) >= vestAmount, "insufficient TKO balance");
uint128 vestAmount = uint128(items[i].vestAmount * 1e18);
require(tko.balanceOf(msg.sender) >= vestAmount, "insufficient TKO balance");

tko.approve(proxy, vestAmount);
TokenUnlocking(proxy).vest(vestAmount);
tko.approve(proxy, vestAmount);
TokenUnlocking(proxy).vest(vestAmount);

console2.log("Vested!\n");
console2.log("Vested!\n");
}
}

vm.stopBroadcast();
Expand Down
Expand Up @@ -11,17 +11,14 @@ import "../../contracts/tokenUnlocking/TokenUnlocking.sol";
contract DeployTokenUnlocking is Script {
using stdJson for string;

uint256 public PRIVATE_KEY = vm.envUint("PRIVATE_KEY"); // deployer
address public OWNER = vm.envAddress("OWNER");
address public TAIKO_TOKEN = vm.envAddress("TAIKO_TOKEN");
uint256 public TGE = vm.envUint("TGE_TIMESTAMP");
address public IMPL = vm.envAddress("TOKEN_VESTING_IMPL");
address public OWNER = 0x9CBeE534B5D8a6280e01a14844Ee8aF350399C7F; // admin.taiko.eth
address public TAIKO_TOKEN = 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800; // token.taiko.eth
uint64 public TGE = 1_716_767_999; // Date and time (GMT): Sunday, May 26, 2024 11:59:59 PM
address public IMPL = 0x244108e321FE03b0E33FE63Ef62285F05d191a62;

function setUp() public { }

function run() external {
address impl = IMPL == address(0) ? address(new TokenUnlocking()) : IMPL;

string memory path = "/script/tokenUnlocking/Deploy.data.json";
address[] memory recipients = abi.decode(
vm.parseJson(vm.readFile(string.concat(vm.projectRoot(), path))), (address[])
Expand All @@ -30,12 +27,10 @@ contract DeployTokenUnlocking is Script {
for (uint256 i; i < recipients.length; i++) {
console2.log("Grantee:", recipients[i]);

vm.startBroadcast(PRIVATE_KEY);
vm.startBroadcast();
deployProxy({
impl: impl,
data: abi.encodeCall(
TokenUnlocking.init, (OWNER, TAIKO_TOKEN, recipients[i], uint64(TGE))
)
impl: IMPL,
data: abi.encodeCall(TokenUnlocking.init, (OWNER, TAIKO_TOKEN, recipients[i], TGE))
});
vm.stopBroadcast();
console2.log("Deployed!\n");
Expand Down