-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add new chain to givEconomy guide #106
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57aed40
Add new chain to givEconomy guide
mohammadranjbarz 16da201
Update add-new-chain-to-givEconomy-guide.md
mohammadranjbarz c483396
Update add-new-chain-to-givEconomy-guide.md
mohammadranjbarz bb8ed51
Update add-new-chain-to-givEconomy-guide.md
mohammadranjbarz f1c06cb
Update add-new-chain-to-givEconomy-guide.md
mohammadranjbarz 6434ddb
Update add-new-chain-to-givEconomy-guide.md
mohammadranjbarz bd6a4cc
Update ne chain integration guide
mohammadranjbarz 6d9456e
Resolve merge conflicts
mohammadranjbarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
## Deploy GIV test token | ||
1. Open ethereum remix, and use erc20 token template | ||
|
||
``` | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; | ||
|
||
|
||
contract MyToken is ERC20, Ownable, ERC20Permit { | ||
constructor(address initialOwner) | ||
ERC20("Giveth", "GIV") | ||
Ownable(initialOwner) | ||
ERC20Permit("Giveth") | ||
{} | ||
|
||
|
||
function mint(address to, uint256 amount) public onlyOwner { | ||
_mint(to, amount); | ||
} | ||
} | ||
``` | ||
|
||
2. Deploy contract on the network | ||
3. Verify contract (Use flatten in remix and then upload it in the remix) | ||
4. Transfer ownership if it's needed https://cardona-zkevm.polygonscan.com/address/0xa77390562986f5d08f5aecf5d3fb82bd16b44548#writeContract | ||
5. Mint tokens in block explorer https://cardona-zkevm.polygonscan.com/address/0xa77390562986f5d08f5aecf5d3fb82bd16b44548#writeContract | ||
|
||
## Deploy token distro | ||
1. Install foundry on your system https://book.getfoundry.sh/getting-started/installation | ||
2. Run this command `Foundryup` | ||
3. Clone this project https://github.com/giveth/giveconomy-foundry | ||
4. `forge build` | ||
5. Edit these parameters | ||
``` | ||
address givTokenOptimismMainnet = 0x528CDc92eAB044E1E39FE43B9514bfdAB4412B98; // address of giv token deployed on previous step | ||
|
||
// initiliaze params for token distro | ||
uint256 totalTokens = 2000000000000000000000000000; | ||
uint256 startTime = 1640361600; // read from previous published smart contract | ||
// like https://cardona-zkevm.polygonscan.com/address/0xa77390562986f5d08f5aecf5d3fb82bd16b44548#readContract | ||
uint256 cliffPeriod = 0; | ||
uint256 duration = 157680000; // read from previous published smart contract | ||
uint256 initialPercentage = 1000; // read from previous published smart contract | ||
``` | ||
in below file https://github.com/Giveth/giveconomy-foundry/blob/develop/script/deployTokenDistro.s.sol | ||
|
||
6. Fill `.env` file in the project with these data | ||
``` | ||
PRIVATE_KEY=// I should start with 0x | ||
ETHERSCAN_API_KEY= // from block explorer of that specific chain | ||
VERIFIER_URL=https://api-cardona-zkevm.polygonscan.com/api // You can find it in block explorer | ||
// like https://docs.polygonscan.com/v/polygon-zkevm/getting-started/endpoint-urls | ||
|
||
``` | ||
7. Edit https://github.com/Giveth/giveconomy-foundry/blob/develop/foundry.toml and add this line(for zkevm cardona, | ||
for other chains you should change them based on the chain | ||
|
||
``` | ||
cardona = { key = "${ETHERSCAN_API_KEY}", url = "https://api-cardona-zkevm.polygonscan.com/api", chain = 2442 } | ||
``` | ||
|
||
8. Enter this command to check everything is working locally | ||
|
||
`forge script script/deployTokenDistro.s.sol --rpc-url {rpcUrl} --legacy --chain 2442 {Desired chainId}` | ||
|
||
|
||
9. Enter this command to broadcast and verify the smart contracts on blockchain | ||
|
||
`forge script script/deployTokenDistro.s.sol --rpc-url {rpcUrl} --verify --broadcast --legacy --chain 2442 {Desired chainId}` | ||
|
||
9. Verify contract with proxy admin in the block explorer | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This is example of published `tokenDistro`: https://cardona-zkevm.polygonscan.com/address/0x2df3e67be4e441cddd2d29c3d41dfd7d516f18e6 | ||
|
||
## Mint GIV test token for token distro | ||
We go to [token page in the block explorer](https://cardona-zkevm.polygonscan.com/address/0xa77390562986f5d08f5aecf5d3fb82bd16b44548#writeContract) and mint as much as token that we need for token distro address | ||
|
||
## Deploy Unipool givPower | ||
1. change some parms in below file | ||
https://github.com/Giveth/giveconomy-foundry/blob/develop/script/deployUnipoolGIVpower.s.sol | ||
|
||
``` | ||
address givTokenAddressOptimismSepolia = 0x2f2c819210191750F2E11F7CfC5664a0eB4fd5e6; | ||
// address tokenDistroOptimismMainnet = 0xE3Ac7b3e6B4065f4765d76fDC215606483BF3bD1; | ||
address tokenDistroOptimismSepolia = 0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7; | ||
ProxyAdmin unipoolGIVpowerProxyAdmin = ProxyAdmin(address(0x3b197F5cDa3516bD49e193df6F1273f3f16d414a)); | ||
``` | ||
all of these params are achieved in the previous steps | ||
|
||
2. Deploy it with foundry | ||
`forge script script/deployUnipoolGIVpower.s.sol --rpc-url {rpcUrl} --legacy --chain 2442 --verify --broadcast` | ||
|
||
3. Verify contract with proxy admin in the block explorer | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
4. We call `notifyRewardAmount` method and set some reward for the contract https://cardona-zkevm.polygonscan.com/address/0x7e9f30a74fcdf035018bc007f9930aa171863e33#writeProxyContract the `rewardDistributor` address can call it (on unipool smart contract) | ||
|
||
5. Call `transferOwnership` if it's needed | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
6. Call `setRewardDistribution` on Unipool GivPower to set the wallet address which will call the `notifyRewardAmount` | ||
|
||
7. Check the address of `DISTRIBUTOR_ROLE` in tokenDistro contract https://cardona-zkevm.polygonscan.com/address/0x2df3e67be4e441cddd2d29c3d41dfd7d516f18e6#readProxyContract | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
8. Call `grantRole` in `tokenDistro` https://cardona-zkevm.polygonscan.com/address/0x2df3e67be4e441cddd2d29c3d41dfd7d516f18e6#writeProxyContract and grant `DISTRIBUTOR_ROLE` to givPower unipool address | ||
|
||
9. Call `assign()` method in tokenDistro and assign the reward token amount to unipool givPower | ||
|
||
|
||
## Test | ||
1. Call `stake` method in unipoolGivPower contract | ||
2. See the giviverse expansion percentage in https://giveth.io/givstream | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Call the `getReward()` method in unipool givPower contract. the `result * percentage = the amount we show in harvest modal` | ||
|
||
## Add subgraph configs | ||
Should add new network in https://github.com/Giveth/giveconomy-subgraph/blob/develop/networks.yaml with needed addresses (all addresses should be in the notion file) | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Integrate with Frontend | ||
You can know how to do it with looking at below PR | ||
https://github.com/Giveth/giveth-dapps-v2/pull/4562/files | ||
(LM adress is the UnipoolGivPower address, for staging ENV you should add configs to `development.tsx` and for produciton you need to add the configs to `production.tsx` | ||
|
||
## Notify Reward Bot | ||
1. We have a wallet address that is in charge for this purpose, we have th private key of that address in the server, so we should make sure call`setRewardDistribution` on Unipool GivPower to set the wallet address of this private key as `reward distributor` | ||
2. We write a script in `giv-token-contract` to call it with crontab jobs https://github.com/Giveth/giv-token-contracts/commit/5188586beed3e0f73c7e0b9bbaf653134184a215 | ||
3. We should transfer some monet the reward distributor address for the gas fee on the new chain that we want ( if reward distributor doesnt have gas, the no`notifyRewardAmount` tx can't be executed | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. Setup the crontab on the server to execute this script periodically | ||
|
||
## Giv unlcok bot | ||
1. Copy a folder of https://github.com/Giveth/givpower-bot in the server, then change config values to the new chain and bring up the docker compose, then this app will unlcok the GIVs when it's the time | ||
2. Make sure that the wallet address of the private key that we put in the config have enough gas fee in it | ||
mohammadranjbarz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Sometimes some weird things can happen, for instance we had a problem on ZKEVM unlcok bot that Amin fixed that with this PR | ||
https://github.com/Giveth/givpower-bot/pull/8 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohammadranjbarz Please mention under which section it must be added