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

chore(protocol): check in data for the first token grant exercise #17707

Merged
merged 13 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/protocol/deployments/mainnet-contract-logs-L1.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@

### token_unlock

- impl: `0x035AFfC82612de31E9Db2259B9482D0Dd53B7819.`
- impl: `0x035AFfC82612de31E9Db2259B9482D0Dd53B7819`
- logs:
- deployed @commit`bca493f` @tx`0x0a4a63715257b766ca06e7e87ee25088d557c460e50120208b31666c83fc68bc`

Expand Down
1 change: 1 addition & 0 deletions packages/protocol/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fs_permissions = [
{ access = "read", path = "./out" },
{ access = "read-write", path = "./deployments" },
{ access = "read", path = "./test" },
{ access = "read", path = "./script/" },
{ access = "read", path = "./genesis" },
]

Expand Down
58 changes: 31 additions & 27 deletions packages/protocol/script/tokenunlock/Vest.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,53 @@ contract VestTokenUnlock is Script {
using stdJson for string;

struct VestingItem {
address recipient;
address proxy;
address recipient;
uint256 vestAmount;
}

// On L2 it shall be: 0xA9d23408b9bA935c230493c40C73824Df71A0975
ERC20 private tko = ERC20(0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800);

function run() external {
vm.startBroadcast();

string memory path = "/script/tokenunlock/Vest.data.json";
VestingItem[] memory items = abi.decode(
vm.parseJson(vm.readFile(string.concat(vm.projectRoot(), path))), (VestingItem[])
);

uint256 total;
for (uint256 i; i < items.length; i++) {
if (items[i].vestAmount != 0) {
// This is needed due to some memory read operation! It seems forge/foundry
// parseJson works in a way that we need to read into local variables from struct,
// as it acts like a stack-like buffer read.
address proxy = items[i].proxy;
address recipient = items[i].recipient;
uint128 vestAmount = uint128(items[i].vestAmount);
console2.log("proxy. :", proxy);
console2.log("grantee:", recipient);
console2.log("vested :", vestAmount);

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

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

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

console2.log("Vested!\n");
}
address proxy = items[i].proxy;
address recipient = items[i].recipient;
uint256 vestAmount = uint256(items[i].vestAmount);

console2.log("proxy:", proxy);
console2.log("recipient:", recipient);
console2.log("vestAmount:", vestAmount);
console2.log("");

TokenUnlock target = TokenUnlock(proxy);

require(target.recipient() == recipient, "recipient mismatch");
require(target.owner() == 0x9CBeE534B5D8a6280e01a14844Ee8aF350399C7F, "owner mismatch");

total += SafeCastUpgradeable.toUint128(items[i].vestAmount * 1e18);
}

console2.log("total:", total / 1e18);
require(tko.balanceOf(msg.sender) >= total, "insufficient TKO balance");

vm.startBroadcast();
for (uint256 i; i < items.length; i++) {
// This is needed due to some memory read operation! It seems forge/foundry
// parseJson works in a way that we need to read into local variables from struct,
// as it acts like a stack-like buffer read.
address proxy = items[i].recipient;
uint128 vestAmount = uint128(items[i].vestAmount * 1e18);

tko.approve(proxy, vestAmount);
TokenUnlock(proxy).vest(vestAmount);
}
vm.stopBroadcast();
}
}
Loading