Skip to content

Commit

Permalink
Fixes and tests for L2 token
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed Apr 1, 2022
1 parent 5c0d486 commit f91c67d
Show file tree
Hide file tree
Showing 12 changed files with 593 additions and 376 deletions.
159 changes: 80 additions & 79 deletions arbitrum-graph.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,89 +30,90 @@ contracts:
- fn: "setContractProxy"
id: "0xd362cac9cb75c10d67bcc0b7eeb0b1ef48bb5420b556c092d4fd7f758816fcf0" # keccak256('GraphTokenGateway')
contractAddress: "${{L2GraphTokenGateway.address}}"
ServiceRegistry:
proxy: true
init:
controller: "${{Controller.address}}"
EpochManager:
proxy: true
init:
controller: "${{Controller.address}}"
lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
# ServiceRegistry:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# EpochManager:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# lengthInBlocks: 1108 # 4 hours (in 13 second blocks)
L2GraphToken:
proxy: true
init:
owner: *governor
initialSupply: "0"
Curation:
proxy: true
init:
controller: "${{Controller.address}}"
bondingCurve: "${{BancorFormula.address}}"
curationTokenMaster: "${{GraphCurationToken.address}}"
reserveRatio: 500000 # 50% (parts per million)
curationTaxPercentage: 10000 # 1% (parts per million)
minimumCurationDeposit: "1000000000000000000" # 1 GRT
DisputeManager:
proxy: true
init:
controller: "${{Controller.address}}"
arbitrator: *arbitrator
minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
fishermanRewardPercentage: 500000 # 50% (parts per million)
idxSlashingPercentage: 25000 # 2.5% (parts per million)
qrySlashingPercentage: 5000 # 0.5% (parts per million)
GNS:
proxy: true
init:
controller: "${{Controller.address}}"
bondingCurve: "${{BancorFormula.address}}"
subgraphNFT: "${{SubgraphNFT.address}}"
calls:
- fn: "approveAll"
SubgraphNFT:
init:
governor: "${{Env.deployer}}"
calls:
- fn: "setTokenDescriptor"
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
- fn: "setMinter"
minter: "${{GNS.address}}"
Staking:
proxy: true
init:
controller: "${{Controller.address}}"
minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
thawingPeriod: 6646 # 10 days (in blocks)
protocolPercentage: 10000 # 1% (parts per million)
curationPercentage: 100000 # 10% (parts per million)
channelDisputeEpochs: 2 # (in epochs)
maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
calls:
- fn: "setDelegationTaxPercentage"
delegationTaxPercentage: 5000 # 0.5% (parts per million)
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
RewardsManager:
proxy: true
init:
controller: "${{Controller.address}}"
issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
AllocationExchange:
init:
graphToken: "${{L2GraphToken.address}}"
staking: "${{Staking.address}}"
governor: *governor
authority: *authority
calls:
- fn: "approveAll"
# Curation:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# bondingCurve: "${{BancorFormula.address}}"
# curationTokenMaster: "${{GraphCurationToken.address}}"
# reserveRatio: 500000 # 50% (parts per million)
# curationTaxPercentage: 10000 # 1% (parts per million)
# minimumCurationDeposit: "1000000000000000000" # 1 GRT
# DisputeManager:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# arbitrator: *arbitrator
# minimumDeposit: "10000000000000000000000" # 10,000 GRT (in wei)
# fishermanRewardPercentage: 500000 # 50% (parts per million)
# idxSlashingPercentage: 25000 # 2.5% (parts per million)
# qrySlashingPercentage: 5000 # 0.5% (parts per million)
# GNS:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# bondingCurve: "${{BancorFormula.address}}"
# subgraphNFT: "${{SubgraphNFT.address}}"
# calls:
# - fn: "approveAll"
# SubgraphNFT:
# init:
# governor: "${{Env.deployer}}"
# calls:
# - fn: "setTokenDescriptor"
# tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
# - fn: "setMinter"
# minter: "${{GNS.address}}"
# Staking:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# minimumIndexerStake: "100000000000000000000000" # 100,000 GRT (in wei)
# thawingPeriod: 6646 # 10 days (in blocks)
# protocolPercentage: 10000 # 1% (parts per million)
# curationPercentage: 100000 # 10% (parts per million)
# channelDisputeEpochs: 2 # (in epochs)
# maxAllocationEpochs: 6 # Based on epoch length this is 28 days (in epochs)
# delegationUnbondingPeriod: 6 # Based on epoch length this is 28 days (in epochs)
# delegationRatio: 16 # 16x (delegated stake to indexer stake multiplier)
# rebateAlphaNumerator: 77 # rebateAlphaNumerator / rebateAlphaDenominator
# rebateAlphaDenominator: 100 # rebateAlphaNumerator / rebateAlphaDenominator
# calls:
# - fn: "setDelegationTaxPercentage"
# delegationTaxPercentage: 5000 # 0.5% (parts per million)
# - fn: "setSlasher"
# slasher: "${{DisputeManager.address}}"
# allowed: true
# - fn: "setAssetHolder"
# assetHolder: "${{AllocationExchange.address}}"
# allowed: true
# RewardsManager:
# proxy: true
# init:
# controller: "${{Controller.address}}"
# issuanceRate: "1000000012184945188" # 3% annual rate (per block increase of total supply, blocks in a year = 365*60*60*24/13)
# AllocationExchange:
# init:
# graphToken: "${{L2GraphToken.address}}"
# staking: "${{Staking.address}}"
# governor: *governor
# authority: *authority
# calls:
# - fn: "approveAll"
L2GraphTokenGateway:
proxy: true
init:
Expand Down
8 changes: 8 additions & 0 deletions contracts/l2/gateway/L2GraphTokenGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger {
);
_;
}
/**
* @dev Initialize this contract.
*/
function initialize(address _controller) external onlyImpl {
Managed._initialize(_controller);
__ReentrancyGuard_init();
_paused = true;
}

function setL2Router(address _l2Router) external onlyGovernor {
l2Router = _l2Router;
Expand Down
26 changes: 9 additions & 17 deletions contracts/l2/token/L2GraphToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Upgradeable,
* @dev Graph Token Contract initializer.
* @param _initialSupply Initial supply of GRT
*/
function _initialize(uint256 _initialSupply) internal {
function _initialize(address owner, uint256 _initialSupply) internal {
__ERC20_init("Graph Token", "GRT");
Governed._initialize(msg.sender);
Governed._initialize(owner);

// The Governor has the initial supply of tokens
_mint(msg.sender, _initialSupply);
_mint(owner, _initialSupply);

// The Governor is the default minter
_addMinter(msg.sender);
_addMinter(owner);

// EIP-712 domain separator
DOMAIN_SEPARATOR = keccak256(
Expand Down Expand Up @@ -207,7 +207,7 @@ contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Upgradeable,
contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
using SafeMath for uint256;
address public gateway;
address public l1GRT;
address public override l1Address;

event BridgeMinted(address indexed account, uint256 amount);
event BridgeBurned(address indexed account, uint256 amount);
Expand All @@ -222,8 +222,8 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
* @dev L2 Graph Token Contract Constructor.
* @param _initialSupply Initial supply of GRT
*/
function initialize(uint256 _initialSupply) external onlyImpl {
GraphTokenUpgradeable._initialize(_initialSupply);
function initialize(address owner, uint256 _initialSupply) external onlyImpl {
GraphTokenUpgradeable._initialize(owner, _initialSupply);
}

function setGateway(address gw) external onlyGovernor {
Expand All @@ -232,8 +232,8 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
}

function setL1Address(address addr) external onlyGovernor {
l1GRT = addr;
emit L1AddressSet(l1GRT);
l1Address = addr;
emit L1AddressSet(addr);
}

/**
Expand All @@ -255,12 +255,4 @@ contract L2GraphToken is GraphTokenUpgradeable, IArbToken {
burnFrom(account, amount);
emit BridgeBurned(account, amount);
}

/**
* @dev Get the address of the L1 counterpart of this token
* @return address of layer 1 token
*/
function l1Address() external override view returns (address) {
return l1GRT;
}
}
2 changes: 2 additions & 0 deletions test/epochs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getAccounts,
toBN,
Account,
initNetwork,
} from './lib/testHelpers'

describe('EpochManager', () => {
Expand All @@ -23,6 +24,7 @@ describe('EpochManager', () => {
const epochLength: BigNumber = toBN('3')

before(async function () {
initNetwork()
;[me, governor] = await getAccounts()
})

Expand Down
Loading

0 comments on commit f91c67d

Please sign in to comment.