-
Notifications
You must be signed in to change notification settings - Fork 0
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
hdev-703-xav-airdrop #3
base: develop
Are you sure you want to change the base?
Changes from 3 commits
5a3d8f6
6e83df7
cf9ed92
6b7455b
7cc6d89
7b8b09f
7ad38ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
require('dotenv').config() | ||
|
||
// import { ethers } from 'hardhat' | ||
import { formatEther, formatUnits, parseEther } from 'ethers/lib/utils' | ||
import { ExportToCsv } from 'export-to-csv' | ||
import { internalRnbwHolders } from '../constants/abi/rnbw' | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types' | ||
import * as fs from 'fs' | ||
|
||
interface AirdropList { | ||
address: string | ||
balance: string | ||
} | ||
|
||
export const generateAirdroplist = async (hre: HardhatRuntimeEnvironment) => { | ||
// 0 - Setup | ||
const options = { | ||
fieldSeparator: ',', | ||
quoteStrings: '"', | ||
decimalSeparator: '.', | ||
showLabels: true, | ||
showTitle: true, | ||
title: `Airdrop List`, | ||
useTextFile: false, | ||
useBom: true, | ||
useKeysAsHeaders: true | ||
} | ||
|
||
const csvExporter = new ExportToCsv(options) | ||
const airdropList: AirdropList[] = [] | ||
const addresses: string[] = [] | ||
const snapshotBlockNumber = 15281097 | ||
|
||
// 1 - get rnbwContract contract instance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question - is this code forked? If not, I guess we need to probably create a unit test here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const rnbwContract = await hre.ethers.getContractAt( | ||
'HaloHalo', | ||
'0x47BE779De87de6580d0548cde80710a93c502405' | ||
) | ||
|
||
// 2 - query all Transfer events from deployment to snapshot block | ||
const rnbwContractEventFilter = await rnbwContract.filters.Transfer() | ||
|
||
const rnbwContractEvents = await rnbwContract.queryFilter( | ||
rnbwContractEventFilter, | ||
12570796, // deployment block | ||
snapshotBlockNumber | ||
) | ||
|
||
// 3 - store Events[] to an array to prevent loss | ||
const rnbwContractEventsArray = rnbwContractEvents | ||
|
||
// 4 - store all unique addresses from transfer events in an array | ||
for (let key in rnbwContractEventsArray) { | ||
const log = rnbwContractEventsArray[key] | ||
if (addresses.indexOf(log.args?.to) < 0 | ||
&& log.args?.to != '0x0000000000000000000000000000000000000000' | ||
&& internalRnbwHolders.indexOf(log.args?.to) < 0) { | ||
addresses.push(log.args?.to) | ||
} | ||
if (addresses.indexOf(log.args?.from) < 0 | ||
&& log.args?.from != '0x0000000000000000000000000000000000000000' | ||
&& internalRnbwHolders.indexOf(log.args?.from) < 0) { | ||
addresses.push(log.args?.from) | ||
} | ||
} | ||
|
||
// 5 - get the RNBW balance of addresses at snapshot block | ||
for (let key in addresses) { | ||
const bal = await rnbwContract.balanceOf(addresses[key], { blockTag: snapshotBlockNumber }) | ||
if (bal > 0) { | ||
airdropList.push({ | ||
address: addresses[key], | ||
balance: formatEther(bal) | ||
}) | ||
console.log(addresses[key], formatEther(bal)) | ||
} | ||
} | ||
|
||
// 5 - output csv | ||
const protocolStatsCSV = csvExporter.generateCsv(airdropList, true) | ||
fs.writeFileSync(`v1Protocol${name}.csv`, protocolStatsCSV) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const internalRnbwHolders = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tracyarciaga the comments say xRNBW but the filenames and variables say rnbw. which one are we getting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ctverceles I fixed the naming conventions |
||
'0x4fbc1dffd80f197cf99faeda8f7bcae0ebea4d81', // xRNBW Primary Bridge | ||
'0xa3a7b6f88361f48403514059f1f16c8e78d60eec', // xRNBW Arbitrum Bridge (external contract) | ||
'0xd10e226f85dfb53aa2f9f3d297e521e1ee4f1bf7', // xRNBW Multichain Bridge (external contract) | ||
'0x9cff4a10b6fb163a4df369aafed9d95838222ca6', // AMM Rewards 1.1 | ||
'0x1af00782f74ddc4c7fcefe8752113084febcda45', // AMM Rewards 1.0 | ||
'0x5fcd66bce7fdccbaa7aeeb39537820bd953ef7e2', // AMM Rewards 0 | ||
'0xd1a8ab10725779246d9d48e422f7fc3313d133f2', // Uniswap V2: xRNBW | ||
'0x7eaE370E6a76407C3955A2f0BBCA853C38e6454E', // contract ops multisig | ||
] |
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.
@tracyarciaga how did we get this btw? is this aug 5 8am UTC?
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.
@ctverceles Yes it's Aug-05-2022 08:00:12 AM +UTC here
https://etherscan.io/block/15281097
The block before that is Aug-05-2022 07:59:59 AM +UTC