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

hdev-703-xav-airdrop #3

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ Example:
```
yarn hardhat v1statistics --curveaddress 0x64DCbDeb83e39f152B7Faf83E5E5673faCA0D42A --name XSGD --decimal 6 --network mainnet
```

### Using XAV Airdrop
```
yarn hardhat xav-airdrop --network mainnet
```
5 changes: 5 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '@nomiclabs/hardhat-etherscan'
import 'hardhat-typechain'
import { fetchV0Stats } from './scripts/protocol-statistics/fetch-v0-stats'
import { fetchV1Stats } from './scripts/protocol-statistics/fetch-v1-stats'
import { generateAirdroplist } from './scripts/airdrop-xav/generate-airdroplist'

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
Expand All @@ -31,6 +32,10 @@ task('v0statistics', 'fetch v0 statistics', async (args, hre) => {
await fetchV0Stats(hre)
})

task('xav-airdrop', 'generate airdrop addresses', async (args, hre) => {
await generateAirdroplist(hre)
})

const config: HardhatUserConfig = {
solidity: '0.6.12',
networks: {
Expand Down
82 changes: 82 additions & 0 deletions scripts/airdrop-xav/generate-airdroplist.ts
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
Copy link
Contributor

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?

Copy link
Contributor Author

@tracyarciaga tracyarciaga Aug 16, 2022

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


// 1 - get rnbwContract contract instance

Choose a reason for hiding this comment

The 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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2022-08-16 at 11 43 56 AM

I'm having issues in using the command yarn hardhat xav-airdrop --network mainnet :(

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)
}
10 changes: 10 additions & 0 deletions scripts/constants/abi/rnbw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const internalRnbwHolders = [
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctverceles I fixed the naming conventions
For the sheet it should be this one -> https://docs.google.com/spreadsheets/d/11G_UJ2_Wjf8BB0uY5wRFPKWHyFjUFzdiG_X9v9WbIlw/edit#gid=1457496626

'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
]