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

Audit suggestions v1 #33

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4a05bd5
New deployment script test
asmodat Mar 27, 2022
2b4a8d3
cant store address in memory
asmodat Mar 27, 2022
0a31cf6
deployer refactor
asmodat Mar 27, 2022
ca85ad8
specify correct address and output to envs
asmodat Mar 27, 2022
9853499
update compilers
asmodat Mar 27, 2022
ff45a24
explicit debug log & do not load all at once
asmodat Mar 27, 2022
c98a0c3
add missing new lines to envs
asmodat Mar 27, 2022
546fa17
deplay contract verification so that chain ha time to catch up
asmodat Mar 27, 2022
e2b6628
sync
asmodat Mar 27, 2022
4e6cbfd
Merge branch 'LIP_5' of https://github.com/KiraCore/liquidity-program…
asmodat Mar 27, 2022
b424a8c
added final suggestions, ready for testing
asmodat Mar 27, 2022
d706399
typo
asmodat Mar 27, 2022
a561678
Merge branch 'master' of https://github.com/KiraCore/liquidity-progra…
asmodat Mar 27, 2022
173067a
mull & add compiler err & missing line terminators
asmodat Mar 27, 2022
be0e80f
set correct subdirectory
asmodat Mar 27, 2022
cb36fca
removed unnecessary nonReentrant
asmodat Mar 27, 2022
ca9e8df
missing incheritance
asmodat Mar 27, 2022
6496c2f
math operators fix
asmodat Mar 27, 2022
305bad3
update frontend variables
asmodat Mar 27, 2022
fe34018
prettyfiy refactor
asmodat Mar 27, 2022
8173bf6
Merge pull request #32 from KiraCore/bugfix/LIP_5-audit-v2
asmodat Mar 27, 2022
862374d
ABI & Contracts update
asmodat Mar 27, 2022
b8ad711
Add kovan LIP_5 addresses
asmodat Mar 28, 2022
49b3a06
Add explicit errors to console
asmodat Mar 28, 2022
12d624b
final refactor, ready for review
asmodat Mar 28, 2022
35e2560
Final audit comments
asmodat Mar 28, 2022
39cc3dc
LIK-02
asmodat Apr 10, 2022
68c40f5
Syntax fix, safe transfer does NOT return bool
asmodat Apr 10, 2022
56dd26e
Update testnet addresses
asmodat Apr 10, 2022
b0852c7
Merge pull request #34 from KiraCore/bugfix/LIP_5-audit-v3
asmodat Apr 10, 2022
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
Prev Previous commit
Next Next commit
ABI & Contracts update
asmodat committed Mar 27, 2022
commit 862374d2ba0d71e52ed9b59169086c14adabb1c3
6 changes: 3 additions & 3 deletions LIP_5.1/.env.example
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@ REACT_APP_INFURA_PROJECT_ID=9f39881c4d9b48f8b9b865ea9a5add18
REACT_APP_INFURA_NETWORK=ropsten
REACT_APP_ETHEREUM_CHAIN_ID=3
REACT_APP_KIRA_TOKEN_ADDRESS=0x2CDA738623354c93eB974F3C90175F249d611CA4
REACT_APP_NFT_STAKING_ADDRESS=0xacEA0dC3008731945F77bc1182045197672068b1
REACT_APP_NFT_FARM_ADDRESS=0x29DFF8C2A22154bCf442C39f6B1BB5E6EDce7d5F
REACT_APP_NFT_MINTING_ADDRESS=0x2Bc49Ae2f5a3194dd68eC202c2Af43E3786A61F3
REACT_APP_NFT_STAKING_ADDRESS=0xe89841b13b7e23e560D5f1FdD8591BDE466d68c4
REACT_APP_NFT_FARM_ADDRESS=0xa97e2425DE402e55CC230bCa330E02A7Ae0051c4
REACT_APP_NFT_MINTING_ADDRESS=0xad81b3ab9439b71b3F0BD1EA2bBbF5e9D086d0C1
8 changes: 5 additions & 3 deletions LIP_5.1/README.md
Original file line number Diff line number Diff line change
@@ -70,7 +70,9 @@ cd $HOME/liquidity-program/LIP_5.1 && \
echo "REACT_APP_ETHEREUM_CHAIN_ID=3" >> ./.env && \
echo "REACT_APP_INFURA_NETWORK=ropsten" >> ./.env && \
echo "REACT_APP_KIRA_TOKEN_ADDRESS=0x2CDA738623354c93eB974F3C90175F249d611CA4" >> ./.env && \
echo "REACT_APP_NFT_STAKING_ADDRESS=0xacEA0dC3008731945F77bc1182045197672068b1" >> ./.env && \
echo "REACT_APP_NFT_FARM_ADDRESS=0x29DFF8C2A22154bCf442C39f6B1BB5E6EDce7d5F" >> ./.env && \
echo "REACT_APP_NFT_MINTING_ADDRESS=0x2Bc49Ae2f5a3194dd68eC202c2Af43E3786A61F3" >> ./.env
echo "REACT_APP_NFT_STAKING_ADDRESS=0xe89841b13b7e23e560D5f1FdD8591BDE466d68c4" >> ./.env && \
echo "REACT_APP_NFT_FARM_ADDRESS=0xa97e2425DE402e55CC230bCa330E02A7Ae0051c4" >> ./.env && \
echo "REACT_APP_NFT_MINTING_ADDRESS=0xad81b3ab9439b71b3F0BD1EA2bBbF5e9D086d0C1" >> ./.env

# NOTE: Remember to keep contract metadata up to date!
```
514 changes: 239 additions & 275 deletions LIP_5.1/src/lib/farm.ts
Original file line number Diff line number Diff line change
@@ -2,311 +2,275 @@ import { BigNumber, Contract, ethers } from 'ethers';

const abi = [
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "_tokenAddr",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
"inputs":[
{
"internalType":"contract IERC20",
"name":"token",
"type":"address"
}
],
"stateMutability":"nonpayable",
"type":"constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
"anonymous":false,
"inputs":[
{
"indexed":true,
"internalType":"address",
"name":"previousOwner",
"type":"address"
},
{
"indexed":true,
"internalType":"address",
"name":"newOwner",
"type":"address"
}
],
"name":"OwnershipTransferred",
"type":"event"
},
{
"inputs": [
{
"internalType": "address",
"name": "address_",
"type": "address"
}
],
"name": "addAuthorizedAddress",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"uint256",
"name":"amount",
"type":"uint256"
}
],
"name":"deposit",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [],
"name": "authorizedAddresses",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"sender",
"type":"address"
}
],
"name":"farmed",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"sender",
"type":"address"
}
],
"name":"farmedStart",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "farmed",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[

],
"name":"limit",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "farmedStart",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[

],
"name":"owner",
"outputs":[
{
"internalType":"address",
"name":"",
"type":"address"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
},
{
"internalType": "uint256",
"name": "stones",
"type": "uint256"
}
],
"name": "giveAway",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"buyer",
"type":"address"
},
{
"internalType":"uint256",
"name":"amount",
"type":"uint256"
}
],
"name":"payment",
"outputs":[
{
"internalType":"bool",
"name":"",
"type":"bool"
}
],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [],
"name": "limit",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[

],
"name":"renounceOwnership",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"staker",
"type":"address"
}
],
"name":"rewardedStones",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "buyer",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "payment",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"contract IERC20",
"name":"minter",
"type":"address"
}
],
"name":"setMinterAddress",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "address_",
"type": "address"
}
],
"name": "removeAuthorizedAddress",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"contract IERC20",
"name":"token",
"type":"address"
}
],
"name":"setTokenAddress",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"",
"type":"address"
}
],
"name":"stakers",
"outputs":[
{
"internalType":"uint256",
"name":"amount",
"type":"uint256"
},
{
"internalType":"uint256",
"name":"stones",
"type":"uint256"
},
{
"internalType":"uint256",
"name":"timestamp",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "staker",
"type": "address"
}
],
"name": "rewardedStones",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
"inputs":[

],
"name":"total",
"outputs":[
{
"internalType":"uint256",
"name":"",
"type":"uint256"
}
],
"stateMutability":"view",
"type":"function"
},
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "token_",
"type": "address"
}
],
"name": "setTokenAddress",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"address",
"name":"newOwner",
"type":"address"
}
],
"name":"transferOwnership",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "stakers",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "stones",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "total",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"inputs":[
{
"internalType":"uint256",
"name":"amount",
"type":"uint256"
}
],
"name":"withdraw",
"outputs":[

],
"stateMutability":"nonpayable",
"type":"function"
}
];

1,383 changes: 736 additions & 647 deletions LIP_5.1/src/lib/nftstake.ts

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions LIP_5/README.md
Original file line number Diff line number Diff line change
@@ -39,11 +39,11 @@ echo "KIRA_TOKEN_ADDRESS=0x2CDA738623354c93eB974F3C90175F249d611CA4" >> ./.env &
```sh
# Requires `KIRA_TOKEN_ADDRESS` set in env variables
npx hardhat run scripts/1_deploy_KexFarm.js --network kovan
# KexFarm on ROPSTEN: 0x29DFF8C2A22154bCf442C39f6B1BB5E6EDce7d5F
# KexFarm on ROPSTEN: 0xa97e2425DE402e55CC230bCa330E02A7Ae0051c4
# KexFarm on MAINNET: TBD

# Save NFT_FARM_ADDRESS as env variable
echo "NFT_FARM_ADDRESS=0x29DFF8C2A22154bCf442C39f6B1BB5E6EDce7d5F" >> ./.env
echo "NFT_FARM_ADDRESS=0xa97e2425DE402e55CC230bCa330E02A7Ae0051c4" >> ./.env

# verify NFT farming contract
. ./.env && npx hardhat verify --network kovan $NFT_FARM_ADDRESS $KIRA_TOKEN_ADDRESS
@@ -55,11 +55,11 @@ echo "NFT_FARM_ADDRESS=0x29DFF8C2A22154bCf442C39f6B1BB5E6EDce7d5F" >> ./.env
# Requires `NFT_FARM_ADDRESS` set in env variables
# The setFarm address funciton is trigerred automatically
npx hardhat run scripts/2_deploy_KiraNFT.js --network kovan
# KiraNFT on ROPSTEN: 0x2Bc49Ae2f5a3194dd68eC202c2Af43E3786A61F3
# KiraNFT on ROPSTEN: 0xad81b3ab9439b71b3F0BD1EA2bBbF5e9D086d0C1
# KiraNFT on MAINNET: TBD

# Save NFT_MINTING_ADDRESS as env variable
echo "NFT_MINTING_ADDRESS=0x2Bc49Ae2f5a3194dd68eC202c2Af43E3786A61F3" >> ./.env
echo "NFT_MINTING_ADDRESS=0xad81b3ab9439b71b3F0BD1EA2bBbF5e9D086d0C1" >> ./.env

# Verify NFT minting contract
. ./.env && npx hardhat verify --network kovan $NFT_MINTING_ADDRESS
@@ -72,11 +72,11 @@ echo "NFT_MINTING_ADDRESS=0x2Bc49Ae2f5a3194dd68eC202c2Af43E3786A61F3" >> ./.env

```sh
npx hardhat run scripts/3_deploy_NFTStaking.js --network kovan
# NFTStaking on ROPSTEN: 0xacEA0dC3008731945F77bc1182045197672068b1
# NFTStaking on ROPSTEN: 0xe89841b13b7e23e560D5f1FdD8591BDE466d68c4
# NFTStaking on MAINNET: TBD

# Save NFT_STAKING_ADDRESS as env variable
echo "NFT_STAKING_ADDRESS=0x0C5B4c3E377Af1A7a93Dd3ecd89A7D4645350A9a" >> ./.env
echo "NFT_STAKING_ADDRESS=0xe89841b13b7e23e560D5f1FdD8591BDE466d68c4" >> ./.env

# verify NFT staking contract
. ./.env && npx hardhat verify --network kovan $NFT_STAKING_ADDRESS $KIRA_TOKEN_ADDRESS $NFT_MINTING_ADDRESS