-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pranay Valson <pranay.valson@gmail.com>
- Loading branch information
Showing
18 changed files
with
1,633 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const hre = require('hardhat'); | ||
const { ethers } = require('hardhat'); | ||
require('dotenv').config(); | ||
const { oneToken } = require('../test/helpers'); | ||
|
||
async function depositRewards() { | ||
const [owner] = await ethers.getSigners(); | ||
|
||
console.log('Depositing rewards with the account:', owner.address); | ||
console.log('Account balance:', (await owner.getBalance()).toString()); | ||
|
||
// Get addresses from environment variables | ||
const NFT_CONTROLLER_ADDRESS = process.env.BASE_SEPOLIA_NFT_CONTROLLER; | ||
const CXT_ADDRESS = process.env.BASE_SEPOLIA_CXT_FAUCET; | ||
|
||
// Ensure the required environment variables are set | ||
if (!NFT_CONTROLLER_ADDRESS || !CXT_ADDRESS) { | ||
throw new Error('Required environment variables are not set'); | ||
} | ||
|
||
console.log('NFT Controller Address:', NFT_CONTROLLER_ADDRESS); | ||
console.log('CXT Address:', CXT_ADDRESS); | ||
|
||
// Get the NFT Controller contract instance | ||
const EwmNftController = await hre.ethers.getContractFactory('EwmNftController'); | ||
const nftController = await EwmNftController.attach(NFT_CONTROLLER_ADDRESS); | ||
|
||
// Get the CXT token contract instance | ||
const CXT = await hre.ethers.getContractFactory('CovalentXTokenFaucet'); | ||
const cxtToken = await CXT.attach(CXT_ADDRESS); | ||
|
||
// Amount of tokens to deposit (e.g., 10 MIO based on 25% APY for CXT 10K LCs) | ||
const depositAmount = oneToken.mul(10000000); | ||
|
||
console.log('Approving CXT transfer...'); | ||
await cxtToken.connect(owner).approve(NFT_CONTROLLER_ADDRESS, depositAmount); | ||
|
||
console.log('Depositing reward tokens...'); | ||
await nftController.connect(owner).depositRewardTokens(depositAmount); | ||
|
||
console.log('Reward tokens deposited successfully'); | ||
|
||
// Get the contract metadata | ||
const metadata = await nftController.getMetadata(); | ||
console.log('Contract Metadata:', metadata); | ||
|
||
// Check if rewardPool exists and is a BigNumber | ||
if (metadata._rewardPool && ethers.BigNumber.isBigNumber(metadata._rewardPool)) { | ||
console.log('New reward balance:', ethers.utils.formatUnits(metadata._rewardPool, 18), 'CXT'); | ||
} else { | ||
console.log('Reward pool balance:', metadata._rewardPool); | ||
} | ||
} | ||
|
||
async function main() { | ||
try { | ||
await hre.run('compile'); | ||
await depositRewards(); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
const hre = require('hardhat'); | ||
const { ethers } = require('hardhat'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
require('dotenv').config(); | ||
|
||
async function distributeCxtTokens() { | ||
const [owner] = await ethers.getSigners(); | ||
|
||
console.log('Distributing CXT tokens with the account:', owner.address); | ||
console.log('Account balance:', (await owner.getBalance()).toString()); | ||
|
||
const CXT_FAUCET_ADDRESS = process.env.BASE_SEPOLIA_CXT_FAUCET; | ||
|
||
if (!CXT_FAUCET_ADDRESS) { | ||
throw new Error('Required environment variables are not set'); | ||
} | ||
|
||
// Read whitelist addresses from JSON file | ||
const whitelistFile = path.join(__dirname, 'data', 'tokenHolderWhitelistBaseSepolia.json'); | ||
|
||
let whitelistAddresses; | ||
try { | ||
const fileContent = fs.readFileSync(whitelistFile, 'utf8'); | ||
const fileData = JSON.parse(fileContent); | ||
whitelistAddresses = fileData.addresses; | ||
} catch (error) { | ||
console.error('Error reading whitelist file:', error); | ||
process.exit(1); | ||
} | ||
|
||
// Specify which indices to distribute to and their NFT counts | ||
const distributionConfig = { | ||
0: 366, // First address gets 67 NFTs | ||
// 1: 67, // Second address gets 67 NFTs | ||
// 2: 100, // Third address gets 100 NFTs | ||
// 3: 200, // Fourth address gets 100 NFTs | ||
}; | ||
|
||
const NFT_PRICE = ethers.utils.parseUnits('5000', 18); // 5000 CXT per NFT | ||
|
||
// Create distribution data only for specified indices | ||
const whitelistData = Object.entries(distributionConfig).map(([index, nftCount]) => ({ | ||
address: whitelistAddresses[index], | ||
nftCount, | ||
index: parseInt(index), | ||
})); | ||
|
||
console.log('\n=== Distribution Configuration ==='); | ||
console.log('CXT Faucet Address:', CXT_FAUCET_ADDRESS); | ||
console.log('NFT Price:', ethers.utils.formatUnits(NFT_PRICE, 18), 'CXT'); | ||
|
||
console.log('\n=== Distribution Details ==='); | ||
whitelistData.forEach(({ address, nftCount, index }) => { | ||
console.log(`Index ${index}: ${address} will receive tokens for ${nftCount} NFTs`); | ||
console.log(`Amount: ${ethers.utils.formatUnits(NFT_PRICE.mul(nftCount), 18)} CXT\n`); | ||
}); | ||
|
||
const CxtFaucet = await hre.ethers.getContractFactory('CovalentXTokenFaucet'); | ||
const cxtFaucet = await CxtFaucet.attach(CXT_FAUCET_ADDRESS); | ||
|
||
console.log('\n=== Starting Distribution ==='); | ||
for (const { address, nftCount, index } of whitelistData) { | ||
const distributionAmount = NFT_PRICE.mul(nftCount); | ||
|
||
try { | ||
const tx = await cxtFaucet.connect(owner).faucet(address, distributionAmount); | ||
const receipt = await tx.wait(); | ||
console.log( | ||
`✅ Index ${index}: Transferred ${ethers.utils.formatUnits(distributionAmount, 18)} CXT to ${address}`, | ||
); | ||
console.log(` Transaction hash: ${receipt.transactionHash}\n`); | ||
} catch (error) { | ||
console.error(`❌ Error transferring tokens to index ${index} (${address}):`, error.message); | ||
} | ||
} | ||
|
||
console.log('\n=== Distribution Summary ==='); | ||
const balance = await cxtFaucet.balanceOf(owner.address); | ||
console.log('Remaining CXT balance of owner:', ethers.utils.formatUnits(balance, 18)); | ||
|
||
// Calculate total distributed | ||
const totalDistributed = whitelistData.reduce( | ||
(acc, { nftCount }) => acc.add(NFT_PRICE.mul(nftCount)), | ||
ethers.BigNumber.from(0), | ||
); | ||
console.log('Total CXT distributed:', ethers.utils.formatUnits(totalDistributed, 18)); | ||
} | ||
|
||
async function main() { | ||
try { | ||
await hre.run('compile'); | ||
await distributeCxtTokens(); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const hre = require('hardhat'); | ||
const { ethers } = require('hardhat'); | ||
require('dotenv').config(); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
async function adminBatchClaimNfts() { | ||
const [, claimAdmin] = await ethers.getSigners(); | ||
|
||
console.log('Performing admin batch claim with the account:', claimAdmin.address); | ||
console.log('Account balance:', (await claimAdmin.getBalance()).toString()); | ||
|
||
const NFT_CLAIM_ADDRESS = process.env.BASE_SEPOLIA_NFT_CLAIM; | ||
const NFT_CONTROLLER_ADDRESS = process.env.BASE_SEPOLIA_NFT_CONTROLLER; | ||
|
||
if (!NFT_CLAIM_ADDRESS || !NFT_CONTROLLER_ADDRESS) { | ||
throw new Error('Required environment variables are not set'); | ||
} | ||
|
||
console.log('NFT Claim Address:', NFT_CLAIM_ADDRESS); | ||
console.log('NFT Controller Address:', NFT_CONTROLLER_ADDRESS); | ||
|
||
// Read whitelist addresses from JSON file | ||
const whitelistFile = path.join( | ||
__dirname, | ||
'..', | ||
'scripts', | ||
'data', | ||
'tokenHolderWhitelistBaseSepolia.json', | ||
); | ||
let whitelistAddresses; | ||
try { | ||
const fileContent = fs.readFileSync(whitelistFile, 'utf8'); | ||
const fileData = JSON.parse(fileContent); | ||
whitelistAddresses = fileData.addresses; | ||
} catch (error) { | ||
console.error('Error reading whitelist file:', error); | ||
process.exit(1); | ||
} | ||
|
||
// Get the NFT Claim contract instance | ||
const EwmNftClaim = await hre.ethers.getContractFactory('EwmNftClaim'); | ||
const claimContract = await EwmNftClaim.attach(NFT_CLAIM_ADDRESS); | ||
|
||
// Get the NFT Controller contract instance | ||
const EwmNftController = await hre.ethers.getContractFactory('EwmNftController'); | ||
const controllerContract = await EwmNftController.attach(NFT_CONTROLLER_ADDRESS); | ||
|
||
console.log('Checking unclaimed NFT counts for each address...'); | ||
const unclaimedCounts = await Promise.all( | ||
whitelistAddresses.map(async (address) => { | ||
const count = await claimContract.unClaimedNftCount(address); | ||
console.log(`Address: ${address}, Unclaimed NFT count: ${count.toString()}`); | ||
return { address, unclaimedCount: count.toNumber() }; | ||
}), | ||
); | ||
|
||
// Filter out addresses with 0 unclaimed NFTs | ||
const addressesToClaim = unclaimedCounts | ||
.filter(({ unclaimedCount }) => unclaimedCount > 0) | ||
.map(({ address }) => address); | ||
|
||
if (addressesToClaim.length === 0) { | ||
console.log('No addresses with unclaimed NFTs found.'); | ||
return; | ||
} | ||
|
||
console.log('Addresses to claim:', addressesToClaim); | ||
console.log('Unclaimed counts:', unclaimedCounts); | ||
|
||
// Perform admin batch claim | ||
try { | ||
const tx = await claimContract.connect(claimAdmin).adminBatchClaimAll(addressesToClaim); | ||
await tx.wait(); | ||
console.log('Admin batch claim successful'); | ||
} catch (error) { | ||
console.error('Error performing admin batch claim:', error.message); | ||
return; | ||
} | ||
|
||
// Check NFT balances after claim | ||
for (const address of addressesToClaim) { | ||
const balance = await controllerContract.balanceOf(address); | ||
console.log(`NFT balance for ${address}: ${balance.toString()}`); | ||
} | ||
} | ||
|
||
async function main() { | ||
try { | ||
await hre.run('compile'); | ||
await adminBatchClaimNfts(); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.