To see the changes made after the first audit please refer to this CHANGELOG
Before starting to review the contracts please take a look at geode white paper and initial draft for the dynamic withdrawals implementation.
Following documentation is an initial draft prepared for testing and reviewing phase of the Geode Portal.
Contracts are comprehensively commented. To understand the contracts one by one, we will review them in this order:
-
-
ERC1155
-
gAVAX Interfaces
-
-
- StableSwap Algorithms & SwapUtils.sol
-
-
DataStoreUtils
-
GeodeUtils
-
StakeUtils
-
Portal
-
- Clone the repository:
git clone https://github.com/Geodefi/Portal-Avax.git
cd Portal-Avax
- Create
.envfile, similar to:
RESET_BASE_FEE_PER_GAS= "true"
FORK_MAINNET= "true"
SNOWTRACE_API_KEY =
ACCOUNT_PRIVATE_KEYS= "<array of private keys seperated with `space` character, at least 3>"
you can get an api key for from snowtrace here, only used on contract verification, so it is not necessary.
- Checkout to dev repository
git checkout dev
- Build the repository
npm i
npx hardhat accounts
- returns local addresses. Mostly, we don't use them :)
npx hardhat compile
- Test everything
npx hardhat test
- Test a folder
npx hardhat test ./test/Pools/*
- Test a file
npx hardhat test ./test/Pools/lpToken.js
- deploy locally:
npx hardhat deploy
- deploy with a mainnet fork
- change
FORK_MAINNETin your .env to "true"
npx hardhat deploy
- deploy with a fuji fork
- change
FORK_FUJIin your .env to "true"
npx hardhat deploy
- deploy to fuji
npx hardhat deploy --network fuji
Lists all the Planets & Operators, with curent information on fee; maintainer & CONTROLLER addresses; Withdrawal Pool, LPtoken, currentInterface addresses.
Additionally, addresses of Governance and Senate.
npx hardhat details --network fuji
Portal needs to be set as the minter address for the following scripts to work. Please set the Portal as Minter address, by simply:
npx hardhat activatePortal --network fuji
- ! please do not forget to add :
--network fujior--network localhostin the following scripts.
Creates a proposal with desired parameters.
-
requires governance role on the deployed contract
-
type: defines type such as senate, upgrade, proxyAdminUpgrade, operator, planet -
controller: refers to the proposed address as the controller of resulting ID -
name: defines id with keccak, unique for every proposal and ID. -
gives max deadline auto: 1 weeks.
npx hardhat propose --type planet --controller 0xbabababa57D8418cC282e7847cd71a7eB824A30F --name baba
- prints the id of the proposal
Deploys the new Portal contract, creates an upgrade request and then approves.
- requires both governance and Senate roles
npx hardhat clean
npx hardhat compile
npx hardhat upgradePortal --network mainnet
- new A will be effective in 14 days, which is the min amount
npx hardhat rampA --a 100 --id 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c
Approves a proposal with given id.
-
requires senate role on the deployed contract
-
id: id of the given proposal to approve (optional) -
name: name of the given id (optional) -
one of these params should be given & not both. at the same time.
npx hardhat approve --id 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c
OR
npx hardhat approve --name planetName
- NOTE : you should provide the private Key of the maintainer of given Planet ID in the
.envas 3. key of ACCOUNT_PRIVATE_KEYS
following tasks might require different tasks to be run first: such as propose, approve with desired type
-
sid: id of the given proposal senate -
pid: id of the planet to vote
npx hardhat elect --sid 5848961497861446846071668098908043216307568754054818374826047266201438740021 --pid 113154929644263497304457434162309070072515068775518083141019399877413336431517
npx hardhat maintainerSet --id 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c --m 0xbabababa57D8418cC282e7847cd71a7eB824A30F
npx hardhat controllerSet --id 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c --c 0xbabababa57D8418cC282e7847cd71a7eB824A30F
-
oid: id of the given operator -
pid: id of the planet
npx hardhat activateOperator --pid 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c --oid 91630959199093646211198814960682556727534799142799726216648273052625587106474
-
oid: id of the given operator -
pid: id of the planet
npx hardhat deactivateOperator --pid 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c --oid 91630959199093646211198814960682556727534799142799726216648273052625587106474
-
oid: id of the given operator -
pid: id of the planet that will be used -
bank: P chain address that will be responsible of creating validators and delerators while being tracked by Telescope.
npx hardhat pBankSet --oid 40531039662654797834915976548300568138790381409100383740683790942209388619086 --pid 01102186b7e3b0dda7f022d922f87d2ae9dffe939440e17d7166b89717e96f4c --bank P-fuji1ev02md0arptrz94qchu2k7sxlkahg2s3un0ahr --network fuji
-
id: id of the given maintainer -
fee: fee up to MAX_MAINTAINER_FEE, as 1e10 being 100%.
npx hardhat feeSet --id 109107927364149951677623767130832398762960713881438355650708216825266818992800 --fee 500000000
| 0 | 'gAVAX' | '0x6026a85e11BD895c934Af02647E8C7b4Ea2D9808' |
| 1 | 'AmplificationUtils' | '0xBB4C9B63586101c3b816A4437f8E5cEB9400dAA8' |
| 2 | 'SwapUtils' | '0xCa4E4229a0Aa81A4BF7aBC291f94F34B38726b51' |
| 3 | 'Swap' | '0xCD8951A040Ce2c2890d3D92Ea4278FF23488B3ac' |
| 4 | 'LPToken' | '0x71B0CD5c4Db483aE8A09Df0f83F69BAC400dBe8c' |
| 5 | 'ERC20InterfaceUpgradable' | '0x9835c0148F83994d54b3f4626015206868653D20' |
| 6 | 'DataStoreUtils' | '0xc7332D9AbEF755C42b4dF9d9db09BEEf15F8f9Fb' |
| 7 | 'GeodeUtils' | '0xB72E3Bacac35Eb5B7d04675945B028cc0A2b85B9' |
| 8 | 'StakeUtils' | '0x8Ef0bFfD16fF76FF97Fe028817f9B6283835BE8A' |
| 9 | 'Portal' | '0x4fe8C658f268842445Ae8f95D4D6D8Cfd356a8C8' |
| 9 | 'Portal Implementation' | '0xcF5162a33b05Bf45020A2f047d28C2E47E93958b' |
npx hardhat --network mainnet details
GOVERNANCE: 0x1B007c50E78ed35fDFAd395BC41C1DBD8Bb9E385
SENATE: 0x1B007c50E78ed35fDFAd395BC41C1DBD8Bb9E385
SenateExpireTimestamp:, Thu Jun 20 2024 17:02:20 GMT+0300 (GMT+03:00)
{
gAVAX: '0x6026a85e11BD895c934Af02647E8C7b4Ea2D9808',
DEFAULT_SWAP_POOL: '0xCD8951A040Ce2c2890d3D92Ea4278FF23488B3ac',
DEFAULT_LP_TOKEN: '0x71B0CD5c4Db483aE8A09Df0f83F69BAC400dBe8c',
ORACLE: '0xA30694d32533672EF0B9E2288f2b886AE5F949a2',
DEFAULT_A_: '60',
DEFAULT_FEE_: '4000000',
DEFAULT_ADMIN_FEE_: '5000000000',
FEE_DENOMINATOR_: '10000000000',
PERIOD_PRICE_INCREASE_LIMIT: '20000000',
MAX_MAINTAINER_FEE_: '1000000000'
}
| index | name | id | fee: | Maintainer&Controller: | Interface: | Withdrawal Pool: | Withdrawal Pool Token: |
|---|---|---|---|---|---|---|---|
| 0 | YieldYak | 45756385... | 5% | 0xDcEDF06Fd33E1D7b6eb4b309f779a0e9D3172e44 | ERC20: 0xF7D9281e8e363584973F946201b82ba72C965D27 | 0xa974DE60871907AAFE3A4634766aDb40dF461C16 | 0xA544F63B09369a7D116d53883897E7eD6AAEF1Fc |
Full IDs [ '45756385483164763772015628191198800763712771278583181747295544980036831301432' ]
| index | name | id | fee: | Maintainer&Controller: | pBank: |
|---|---|---|---|---|---|
| 0 | Eden | 10910792... | 5% | 0xa2d67Ff6C0a5B091A7b018de5d9377a3D465Ce64 | 45756385: P-avax1gfev5u7desmpc699x9yt683p09llf605e2z5nq |
Full IDs [ '109107927364149951677623767130832398762960713881438355650708216825266818992800' ]
Surya is a helper npm package released by ConsenSys. graph is really useful. However, same task can be handled by Solidity-Visual-Developer extension dynamically with graph(this) choice at the top of your code.

