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

Permissionless staking contract - Staker #24

Merged
merged 66 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
95ceece
Added hardhat-docgen as a dependency
zomglings Jul 10, 2024
087db3f
Removed hardhat-docgen
zomglings Jul 10, 2024
d653fe7
Put package-lock.json in .gitignore
zomglings Jul 10, 2024
6693f84
Started working on Staker contract
zomglings Jul 11, 2024
e524fc1
Added a bunch of tests for pool creation and configuration
zomglings Jul 11, 2024
0389e83
Complete tests for pool creation and admin functionality
zomglings Jul 11, 2024
ada5d3d
Added test for creation with unknown token type
zomglings Jul 11, 2024
d092c98
Don't want to use 0 for NATIVE_TOKEN_TYPE
zomglings Jul 11, 2024
38bde03
[WIP] Starting to add actual staking/unstaking mechanic
zomglings Jul 11, 2024
bc34226
Greated "game7 staker" CLI
zomglings Jul 11, 2024
eaf792b
Completed first draft of Staker
zomglings Jul 12, 2024
5b90b14
Improved one of the initiateUnstake tests
zomglings Jul 12, 2024
6bf75e2
Added tokenURI override
zomglings Jul 12, 2024
14a8b7c
Image URI TODO
zomglings Jul 12, 2024
1508433
Upated Staker bindings
zomglings Jul 12, 2024
9c81c19
Restricted transfers of position tokens...
zomglings Jul 12, 2024
6cae0bc
Nerdsniped on managing flow labels
zomglings Jul 17, 2024
94509d6
Applied "graffiti number" to staker.md
zomglings Jul 17, 2024
7f1fcbf
More staker flows
zomglings Jul 17, 2024
01ff815
Numbered staker flows
zomglings Jul 17, 2024
bcef75e
Flows to prevent unstake without cooldown before lockup expiration...
zomglings Jul 17, 2024
aa8be04
Numbering
zomglings Jul 17, 2024
82ed300
Updated flows to cover unstaking with cooldown behavior
zomglings Jul 17, 2024
c9e4faf
Numbering of flows
zomglings Jul 17, 2024
b317724
Flow headings
zomglings Jul 17, 2024
b90aaad
Added two flows
zomglings Jul 17, 2024
69c091b
ADded two new flows
zomglings Jul 17, 2024
65d7c92
Added more tests
zomglings Jul 17, 2024
e56867c
STAKER-24 test
zomglings Jul 17, 2024
312453a
Renamed FindLabels* to ParseLabels* in graffiti
zomglings Jul 17, 2024
121ced3
Started adding unstaking tests...
zomglings Jul 17, 2024
503fc70
STAKER-27 test
zomglings Jul 17, 2024
e1ad91c
STAKER-28 test
zomglings Jul 17, 2024
20c75d3
STAKER-29, STAKER-30, STAKER-31, STAKER-32 tests
zomglings Jul 17, 2024
d447898
Tests for...
zomglings Jul 18, 2024
379f692
Tests for STAKER-{49..52}
zomglings Jul 18, 2024
045d6a9
Fixed label on test for STAKER-40
zomglings Jul 18, 2024
f801f58
More staker tests
zomglings Jul 18, 2024
c8fc976
Fixed cooldown bug
zomglings Jul 19, 2024
2a3b655
Updated unstake time checks
zomglings Jul 19, 2024
3832806
Clarifying comments
zomglings Jul 19, 2024
807cd40
Making good progress on tests
zomglings Jul 20, 2024
8a09f3b
Split the Staker test file into two files
zomglings Jul 20, 2024
57a2bba
Almost there
zomglings Jul 20, 2024
5126196
Added tests for all documented execution flows!
zomglings Jul 20, 2024
d5279d1
Added execution flows to be tested for position metadata
zomglings Jul 20, 2024
4227564
Updated Staker bindings
zomglings Jul 20, 2024
fb06567
Touched up metadata tests
zomglings Jul 20, 2024
b15561b
Slight updated to main README
zomglings Jul 20, 2024
ca99e9d
Merge branch 'main' into feature/staking
zomglings Jul 20, 2024
0f7b659
Added operational script for setup of Staker contract on Game7 testnet
zomglings Jul 21, 2024
891f6cd
Clarified transferability of pool 0 on Game7 testnet
zomglings Jul 21, 2024
63f3da0
Updated script to show staking/unstaking of native token
zomglings Jul 21, 2024
c2dbcbc
Added tests for `CurrentAmountInPool` and `CurrentPositionsInPool`.
zomglings Jul 22, 2024
37b59c2
Added more flows to test
zomglings Jul 22, 2024
25d6d5e
One more flow to test
zomglings Jul 22, 2024
33220a0
Added "game7 mock" commands
zomglings Jul 24, 2024
89aa85d
Added test for STAKER-119
zomglings Jul 24, 2024
b6c01c1
Added more tests
zomglings Jul 25, 2024
8667259
Added two more execution flows
zomglings Jul 25, 2024
d09559c
More Staker tests
zomglings Jul 25, 2024
63fb9ce
All tests
zomglings Jul 25, 2024
df88356
Fixed tests for 0 amounts
zomglings Jul 25, 2024
d674d84
README changes
zomglings Jul 30, 2024
a98dac1
Updated Makefile and regenerated bindings
zomglings Jul 30, 2024
36268ce
Some more information in readme
zomglings Jul 30, 2024
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
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ bindings/WrappedNativeToken/WrappedNativeToken.go: hardhat
mkdir -p bindings/WrappedNativeToken
seer evm generate --package WrappedNativeToken --output bindings/WrappedNativeToken/WrappedNativeToken.go --hardhat web3/artifacts/contracts/token/WrappedNativeToken.sol/WrappedNativeToken.json --cli --struct WrappedNativeToken

bindings: bindings/ERC20/ERC20.go bindings/TokenFaucet/TokenFaucet.go bindings/WrappedNativeToken/WrappedNativeToken.go
bindings/Staker/Staker.go: hardhat
mkdir -p bindings/Staker
seer evm generate --package Staker --output bindings/Staker/Staker.go --hardhat web3/artifacts/contracts/staking/Staker.sol/Staker.json --cli --struct Staker

bindings: bindings/ERC20/ERC20.go bindings/TokenFaucet/TokenFaucet.go bindings/WrappedNativeToken/WrappedNativeToken.go bindings/Staker/Staker.go

test:
npx hardhat test
zomglings marked this conversation as resolved.
Show resolved Hide resolved

clean:
rm -rf bindings/ERC20/* bin/* bindings/TokenFaucet/* bindings/WrappedNativeToken/*
rm -rf bindings/ERC20/* bin/* bindings/TokenFaucet/* bindings/WrappedNativeToken/* bindings/Staker/*

hardhat:
cd web3 && npm install && npx hardhat compile
Expand Down
6,630 changes: 6,630 additions & 0 deletions bindings/Staker/Staker.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion cmd/game7/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/G7DAO/protocol/bindings/ArbitrumL2CustomGateway"
"github.com/G7DAO/protocol/bindings/ArbitrumUpgradeExecutor"
"github.com/G7DAO/protocol/bindings/ERC20Inbox"
"github.com/G7DAO/protocol/bindings/Staker"
"github.com/G7DAO/protocol/bindings/TokenFaucet"
"github.com/G7DAO/protocol/bridge"

Expand Down Expand Up @@ -66,7 +67,10 @@ func CreateRootCommand() *cobra.Command {
wrappedNativeTokenCmd := WrappedNativeToken.CreateWrappedNativeTokenCommand()
wrappedNativeTokenCmd.Use = "wrapped-native-token"

rootCmd.AddCommand(completionCmd, versionCmd, tokenCmd, arbitrumL1OrbitCustomGatewayCmd, arbitrumL2CustomGatewayCmd, arbitrumUpgradeExecutorCmd, arbitrumL1OrbitGatewayRouterCmd, arbSysCmd, erc20InboxCmd, bridgeCmd, faucetCmd, accountsCmd, wrappedNativeTokenCmd)
stakerCmd := Staker.CreateStakerCommand()
stakerCmd.Use = "staker"

rootCmd.AddCommand(completionCmd, versionCmd, tokenCmd, arbitrumL1OrbitCustomGatewayCmd, arbitrumL2CustomGatewayCmd, arbitrumUpgradeExecutorCmd, arbitrumL1OrbitGatewayRouterCmd, arbSysCmd, erc20InboxCmd, bridgeCmd, faucetCmd, accountsCmd, wrappedNativeTokenCmd, stakerCmd)

// By default, cobra Command objects write to stderr. We have to forcibly set them to output to
// stdout.
Expand Down
4 changes: 3 additions & 1 deletion web3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ coverage.json
.vscode
out
cache_forge
forge-artifacts
forge-artifacts

package-lock.json
39 changes: 39 additions & 0 deletions web3/contracts/mock/tokens.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MockERC20 is ERC20 {
constructor() ERC20("Mock ERC20", "MOCK20") {}

function mint(address account, uint256 amount) external {
_mint(account, amount);
}

function burn(address account, uint256 amount) external {
_burn(account, amount);
}
}

contract MockERC721 is ERC721 {
constructor() ERC721("Mock ERC721", "MOCK721") {}

function mint(address account, uint256 tokenId) external {
_mint(account, tokenId);
}

function burn(uint256 tokenId) external {
_burn(tokenId);
}
}

contract MockERC1155 is ERC1155 {
constructor() ERC1155("https://example.com/mock/erc1155.json") {}

function mint(address account, uint256 tokenId, uint256 amount) external {
_mint(account, tokenId, amount, "");
}

function burn(address account, uint256 tokenId, uint256 amount) external {
_burn(account, tokenId, amount);
}
}
Loading
Loading