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

Feature/airdrop and bot scripts #26

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
338db9f
Governance option, treasury fee 30% by default
Feb 28, 2022
f6d089c
correction
Feb 28, 2022
2658e82
TreasuryFee correction
Feb 28, 2022
e6b10ec
Gorvance On off, TreasuryFee setup
Feb 28, 2022
6a0f948
Merge branch 'feature/monorepo' into Governance-On-Off
HxSimo Mar 1, 2022
118a9f4
Merge
Mar 7, 2022
e73a75f
Merge finish
Mar 7, 2022
8b7c5f4
Console log correction
Mar 7, 2022
ce3fa41
add console log for new gorvernance options
Mar 7, 2022
7bd511a
example env
Mar 8, 2022
e098f3c
Merge pull request #3 from wagmiog/Governance-On-Off
HxSimo Mar 8, 2022
fc3263e
attach Multisig
Mar 10, 2022
8bdb706
Merge pull request #4 from wagmiog/Governance-On-Off
HxSimo Mar 10, 2022
525257f
Merge branch 'pangolindex:main' into feature/monorepo
iam-robi Mar 21, 2022
f98b628
Airdrop scripts
Mar 29, 2022
4e4ce1c
RewardBotV2
Mar 29, 2022
3e2745f
:art: structure airdrop script in single folder
Mar 29, 2022
58c7075
Merge pull request #8 from wagmiog/feature/airdrop-scripts-refine
HxSimo Mar 29, 2022
f5f6696
:art: align with main branch
Mar 30, 2022
f3b31a8
Auto Addresses length
Mar 31, 2022
fc53163
Auto Addresses length
Mar 31, 2022
5610ca2
New csv format
Apr 5, 2022
b4578dc
New csv format
Apr 5, 2022
1928d84
Airdrop patch
Apr 8, 2022
b52900e
Merge pull request #11 from wagmiog/Airdrop
iam-robi Apr 11, 2022
c9610d5
csv new fomat
Apr 13, 2022
fcaa4d6
Security for whitelisting
Apr 14, 2022
296ff87
SDK MAJ & rewardBot link with the SDK
Apr 15, 2022
2be2dbd
rewardBot link with the SDK
Apr 15, 2022
b376dbd
New csv format
Apr 19, 2022
e2a552a
patch rewardBot
Apr 29, 2022
65650cd
Merge pull request #12 from wagmiog/Airdrop
iam-robi Apr 29, 2022
0db7f65
Merge branch 'main' into feature/airdrop-and-bot-scripts
HxSimo Jun 7, 2022
6878c94
Correction for merge
OrgSimo Jun 8, 2022
10edcd8
Merge branch 'pangolindex:main' into feature/airdrop-and-bot-scripts
HxSimo Jun 8, 2022
fed66f5
Update for merge
OrgSimo Jun 8, 2022
2342acd
Duplicates update
OrgSimo Jun 8, 2022
954812d
Duplicates update
OrgSimo Jun 8, 2022
da0a100
csv smell
OrgSimo Jun 8, 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
2 changes: 1 addition & 1 deletion addresses/wagmi_fuji_subnet.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");
const { CHAINS } = require("@pangolindex/sdk");
const { ALL_CHAINS } = require("@pangolindex/sdk");
require('dotenv').config();

// Create hardhat networks from @pangolindex/sdk
let networksFromSdk = {};
for (const chain of CHAINS) {
for(const chain of ALL_CHAINS) {
networksFromSdk[chain.id] = {
url: chain.rpc_uri,
chainId: chain.chain_id,
accounts: [process.env.PRIVATE_KEY],
accounts: [process.env.PRIVATE_KEY]
};
}
networksFromSdk["hardhat"] = {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
"dependencies": {
"@gnosis.pm/safe-core-sdk": "^1.3.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@pangolindex/sdk": "^1.4.0",
"@pangolindex/sdk": "2.0.11",
"chance": "^1.1.8",
"dotenv": "^14.2.0"
"csvtojson": "^2.0.10",
"dotenv": "^14.2.0",
"web3": "^1.7.3"
}
}
73 changes: 73 additions & 0 deletions scripts/Airdrop/AddWhitelistAddresses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const { ethers } = require('hardhat');
const { BigNumber } = require('ethers');
const fs = require('fs');
const csv = require('csvtojson');
const { ADDRESSES } = require(`../../addresses/${network.name}.js`);
const { attach, check_whitelister, check_arrays_equal_length} = require('./modules/utils');

async function main() {

const [deployer] = await ethers.getSigners();
console.log("Using script with the account:", deployer.address);

let txCount = await ethers.provider.getTransactionCount(deployer.address);

async function confirmTransactionCount() {
let newTxCount;
while (true) {
try {
newTxCount = await ethers.provider.getTransactionCount(
deployer.address
);
if (newTxCount != txCount + 1) {
continue;
}
txCount++;
} catch (err) {
console.log(err);
process.exit(0);
}
break;
}
}

const initBalance = await deployer.getBalance();
console.log("Account balance:", initBalance.toString());

const Airdrop = await attach("Airdrop", ADDRESSES[9 - (13 - ADDRESSES.length) ].address);

await check_whitelister(Airdrop, deployer);

let csvFile = await csv().fromFile(`scripts/Airdrop/lists/${network.name}.csv`)
let airdropAddresses = [], airdropAmounts = [];
let amount;
for(const csvInfo of csvFile) {
amount = BigNumber.from(csvInfo.allocated_amount);
airdropAddresses.push(csvInfo.address);
airdropAmounts.push(amount);
if (airdropAddresses.length == 250) {
await check_arrays_equal_length(airdropAddresses, airdropAmounts);
await Airdrop.whitelistAddresses(airdropAddresses, airdropAmounts);
await confirmTransactionCount();
console.log("Whitelist has been added");
airdropAddresses = [];
airdropAmounts = [];
}
}
if (airdropAddresses.length > 0) {
await check_arrays_equal_length(airdropAddresses, airdropAmounts);
await Airdrop.whitelistAddresses(airdropAddresses, airdropAmounts);
await confirmTransactionCount();
console.log("Whitelist has been added");
}

const endBalance = await deployer.getBalance();
console.log("Deploy cost: ", initBalance.sub(endBalance).toString())
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
37 changes: 37 additions & 0 deletions scripts/Airdrop/AirdropInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { ethers } = require('hardhat');
const { BigNumber } = require('ethers');
const fs = require('fs');
const { ADDRESSES } = require(`../../addresses/${network.name}.js`);
const { attach } = require('./modules/utils');

async function main() {

const [deployer] = await ethers.getSigners();

const Airdrop = await attach("Airdrop", ADDRESSES[9 - (13 - ADDRESSES.length) ].address);

let info;

console.log("address : " + await Airdrop.address);
info = await Airdrop.owner();
console.log("owner : " + info);
info = await Airdrop.whitelister();
console.log("whitelister : " + info);
info = await Airdrop.remainderDestination();
console.log("remainderDestination : " + info);
info = await Airdrop.totalAllocated();
console.log("totalAllocated : " + info);
info = await Airdrop.withdrawAmount(deployer.address);
console.log("Your withdrawAmount : " + info);
info = await Airdrop.airdropSupply();
console.log("airdropSupply : " + info);
info = await Airdrop.claimingAllowed();
console.log("claimingAllowed : " + info);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
37 changes: 37 additions & 0 deletions scripts/Airdrop/AllowClaiming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { ethers } = require('hardhat');
const { BigNumber } = require('ethers');
const fs = require('fs');
const { ADDRESSES } = require(`../../addresses/${network.name}.js`);
const { attach, multisigWallet } = require('./modules/utils');

async function main() {

const [deployer] = await ethers.getSigners();
console.log("Using script with the account:", deployer.address);
const initBalance = await deployer.getBalance();
console.log("Account balance:", initBalance.toString());

const Airdrop = await attach("Airdrop", ADDRESSES[9 - (13 - ADDRESSES.length) ].address);
const multisig = await attach("MultiSigWalletWithDailyLimit", ADDRESSES[2 - (13 - ADDRESSES.length) ].address);

if (!(await multisig.isOwner(deployer.address))) {
console.error("You are not an owner of Multisig");
process.exit(1);
}

if (await Airdrop.owner() != multisig.address) {
console.error("Multisig is not the owner of Airdrop");
process.exit(1);
}
await multisigWallet(multisig, [Airdrop.address, 0, "0xde733397"])

const endBalance = await deployer.getBalance();
console.log("Deploy cost: ", initBalance.sub(endBalance).toString())
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
37 changes: 37 additions & 0 deletions scripts/Airdrop/EndAirdrop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { ethers } = require('hardhat');
const { BigNumber } = require('ethers');
const fs = require('fs');
const { ADDRESSES } = require(`../../addresses/${network.name}.js`);
const { attach, multisigWallet } = require('./modules/utils')

async function main() {

const [deployer] = await ethers.getSigners();
console.log("Using script with the account:", deployer.address);
const initBalance = await deployer.getBalance();
console.log("Account balance:", initBalance.toString());

const Airdrop = await attach("Airdrop", ADDRESSES[9 - (13 - ADDRESSES.length) ].address);
const multisig = await attach("MultiSigWalletWithDailyLimit", ADDRESSES[2 - (13 - ADDRESSES.length) ].address);

if (!(await multisig.isOwner(deployer.address))) {
console.error("You are not an owner of Multisig");
process.exit(1);
}

if (await Airdrop.owner() != multisig.address) {
console.error("Multisig is not the owner of Airdrop");
process.exit(1);
}
await multisigWallet(multisig, [Airdrop.address, 0, "0x6556c391"]);

const endBalance = await deployer.getBalance();
console.log("Deploy cost: ", initBalance.sub(endBalance).toString())
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
38 changes: 38 additions & 0 deletions scripts/Airdrop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Airdrop Scripts

Once `yarn deploy` is ran, deployed contracts will be stored in
`addresses/` directory as a file with the network’s name. For example,
`yarn deploy --network avalanche_fuji` will create a file named
`addresses/avalanche_fuji.js`.

After the deployment, you can use airdrop scripts.

If it's only test it's better to be the only 1 multisig owner, or only have 1 required on the multisig. (it's necessary for Airdrop/Airdrop.js).

Airdrop/SetWhitelister.js, change the whitelister by you.

Airdrop/AddWhitelistAddresses.js, for this script you need to be the whitelister, it's add all addresses and amounts of csv network file, for example if you want whitelist on avalanche_fuji, it's will use `avalanche_fuji.csv`, to prepare your csv file you have `example.csv`.

After that's you need use Airdrop/AllowClaiming.js to allow the claim.

If you want to use Airdrop/SetWhitelister.js then Airdrop/AddWhitelistAddresses.js then Airdrop/AllowClaiming.js, you can directly use Airdrop/Airdrop.js.

And for end the airdrop you can use Airdrop/EndAirdrop.js.

To get some info on the Airdrop contract you have Airdrop/AirdropInfo.js.

You must also add your private key to the `.env` file.

To execute a script use: `npx hardhat --network avalanche_fuji run yourScriptPath`

## Test on fuji

1. make sure you are single owner of multisig in constants avalanche fuji.js
2. deploy contracts ``yarn deploy --network avalanche_fuji``
3. check airdrop info `npx hardhat --network avalanche_fuji run scripts/Airdrop/AirdropInfo.js`
4. fill list data in scripts/Airdrop/lists/avalanche_fuji.csv
5. set up airdrop your address to whitelister `npx hardhat --network avalanche_fuji run scripts/Airdrop/SetWhitelister.js`
6. Add all addresses with the csv file `npx hardhat --network avalanche_fuji run scripts/Airdrop/AddWhitelistAddresses.js`
7. Start airdrop `npx hardhat --network avalanche_fuji run scripts/Airdrop/AllowClaiming.js`
5. check new airdrop info `npx hardhat --network avalanche_fuji run scripts/Airdrop/AirdropInfo.js`
5. end airdrop `npx hardhat --network avalanche_fuji run scripts/Airdrop/EndAirdrop.js`
39 changes: 39 additions & 0 deletions scripts/Airdrop/SetWhitelister.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { ethers } = require('hardhat');
const { BigNumber } = require('ethers');
const fs = require('fs');
const { ADDRESSES } = require(`../../addresses/${network.name}.js`);
const { attach, multisigWallet} = require('./modules/utils')

async function main() {

const [deployer] = await ethers.getSigners();
console.log("Using script with the account:", deployer.address);
const initBalance = await deployer.getBalance();
console.log("Account balance:", initBalance.toString());

const Airdrop = await attach("Airdrop", ADDRESSES[9 - (13 - ADDRESSES.length) ].address);
const multisig = await attach("MultiSigWalletWithDailyLimit", ADDRESSES[2 - (13 - ADDRESSES.length)].address);

if (!(await multisig.isOwner(deployer.address))) {
console.error("You are not an owner of Multisig");
process.exit(1);
}

if (await Airdrop.owner() != multisig.address) {
console.error("Multisig is not the owner of Airdrop");
console.log(await Airdrop.owner())
process.exit(1);
}

await multisigWallet(multisig, [Airdrop.address, 0, "0xf98f5b92000000000000000000000000" + deployer.address.substr(2)]);

const endBalance = await deployer.getBalance();
console.log("Deploy cost: ", initBalance.sub(endBalance).toString())
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
Loading