-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
102 additions
and
76 deletions.
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
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
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
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
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 |
---|---|---|
@@ -1,34 +1,33 @@ | ||
// import { ethers } from 'hardhat'; | ||
const { ethers } = require("hardhat") | ||
const { ethers } = require('hardhat'); | ||
import fs from 'fs'; | ||
|
||
// npx hardhat run script/06_deploy_deposit.ts --network testnet | ||
async function main() { | ||
if (!process.env.LST_GAUGE) { | ||
console.log(`Please provide LST_GAUGE address`); | ||
return; | ||
} | ||
if (!process.env.LST_POOL1) { | ||
console.log(`Please provide LST_Token address`); | ||
return; | ||
} | ||
if (!process.env.LST_GAUGE) { | ||
console.log(`Please provide LST_GAUGE address`); | ||
return; | ||
} | ||
if (!process.env.LST_POOL1) { | ||
console.log(`Please provide LST_Token address`); | ||
return; | ||
} | ||
|
||
const [deployer] = await ethers.getSigners(); | ||
console.log('Deployer address:', deployer.address); | ||
const [deployer] = await ethers.getSigners(); | ||
console.log('Deployer address:', deployer.address); | ||
|
||
const lst_token = await ethers.getContractAt('TestToken', process.env.LST_POOL1) | ||
const tx = await lst_token.approve(process.env.LST_GAUGE, ethers.parseEther('1000')); | ||
await tx.wait(); | ||
const gauge = await ethers.getContractAt('IRewardGauge', process.env.LST_GAUGE, deployer); | ||
const tx2 = await gauge.deposit(ethers.parseEther('1')); | ||
await tx2.wait(); | ||
|
||
const balance = await gauge.balanceOf(deployer); | ||
console.log("balance of deposit: ", balance); | ||
const lst_token = await ethers.getContractAt('TestToken', process.env.LST_POOL1); | ||
const tx = await lst_token.approve(process.env.LST_GAUGE, ethers.parseEther('1000')); | ||
await tx.wait(); | ||
const gauge = await ethers.getContractAt('IRewardGauge', process.env.LST_GAUGE, deployer); | ||
const tx2 = await gauge.deposit(ethers.parseEther('1')); | ||
await tx2.wait(); | ||
|
||
const balance = await gauge.balanceOf(deployer); | ||
console.log('balance of deposit: ', balance); | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
process.exitCode = 1; | ||
console.error(err); | ||
process.exitCode = 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 |
---|---|---|
@@ -1,29 +1,33 @@ | ||
const { ethers } = require("hardhat") | ||
const { ethers } = require('hardhat'); | ||
|
||
// npx hardhat run script/07_calculate_boost.ts --network testnet | ||
async function main() { | ||
if (!process.env.LST_GAUGE) { | ||
console.log(`Please provide LST_GAUGE address`); | ||
return; | ||
} | ||
if (!process.env.LST_GAUGE) { | ||
console.log(`Please provide LST_GAUGE address`); | ||
return; | ||
} | ||
|
||
const [deployer] = await ethers.getSigners(); | ||
console.log('Deployer address:', deployer.address); | ||
const [deployer] = await ethers.getSigners(); | ||
console.log('Deployer address:', deployer.address); | ||
|
||
const gauge = await ethers.getContractAt('IRewardGauge', process.env.LST_GAUGE, deployer); | ||
const totalSupply = await gauge.totalSupply(); | ||
const totalShare = await gauge.totalShare(); | ||
const gauge = await ethers.getContractAt('IRewardGauge', process.env.LST_GAUGE, deployer); | ||
const totalSupply = await gauge.totalSupply(); | ||
const totalShare = await gauge.totalShare(); | ||
|
||
const userWillDepositLp = BigInt(10000); | ||
const userWillVoteShare = BigInt(100) ; | ||
var boost = Number(1.5) * Number((totalSupply+userWillDepositLp) *userWillVoteShare)/Number(totalShare+userWillVoteShare)/Number(userWillDepositLp) + Number(1) | ||
if (boost > Number(2.5)){ | ||
boost = Number(2.5) | ||
} | ||
console.log("boost for user: ", boost); | ||
const userWillDepositLp = BigInt(10000); | ||
const userWillVoteShare = BigInt(100); | ||
var boost = | ||
(Number(1.5) * Number((totalSupply + userWillDepositLp) * userWillVoteShare)) / | ||
Number(totalShare + userWillVoteShare) / | ||
Number(userWillDepositLp) + | ||
Number(1); | ||
if (boost > Number(2.5)) { | ||
boost = Number(2.5); | ||
} | ||
console.log('boost for user: ', boost); | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
process.exitCode = 1; | ||
console.error(err); | ||
process.exitCode = 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 |
---|---|---|
|
@@ -15,4 +15,4 @@ async function main() { | |
main().catch(err => { | ||
console.error(err); | ||
process.exitCode = 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 |
---|---|---|
@@ -1,59 +1,64 @@ | ||
import { expect } from 'chai'; | ||
import { ethers } from 'hardhat'; | ||
import { time, mine, mineUpTo } from "@nomicfoundation/hardhat-toolbox/network-helpers"; | ||
import { time, mine, mineUpTo } from '@nomicfoundation/hardhat-toolbox/network-helpers'; | ||
|
||
describe('BatchClaimVault tests', function () { | ||
it('claim', async function () { | ||
const [owner, projectRecipient, fakeRecipient] = await ethers.getSigners(); | ||
|
||
const vault = await ethers.deployContract('BatchClaimVault'); | ||
await vault.connect(owner).initialize(ethers.parseEther('0.1')); | ||
|
||
expect(await vault.batchSize()).to.equal(17280); | ||
await expect(vault.connect(fakeRecipient).changeBatchSize(10)) | ||
.to.revertedWith('Ownable: caller is not the owner'); | ||
await expect(vault.connect(fakeRecipient).changeRewardPerBlock(10)) | ||
.to.revertedWith('Ownable: caller is not the owner'); | ||
await expect(vault.connect(fakeRecipient).changeRecipient(1, fakeRecipient.address)) | ||
.to.revertedWith('invalid admin'); | ||
await expect(vault.connect(fakeRecipient).changeBatchSize(10)).to.revertedWith('Ownable: caller is not the owner'); | ||
await expect(vault.connect(fakeRecipient).changeRewardPerBlock(10)).to.revertedWith( | ||
'Ownable: caller is not the owner', | ||
); | ||
await expect(vault.connect(fakeRecipient).changeRecipient(1, fakeRecipient.address)).to.revertedWith( | ||
'invalid admin', | ||
); | ||
|
||
await vault.connect(owner).changeBatchSize(10); | ||
|
||
const projectId = 1; | ||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('invalid project'); | ||
const startBlock = (await time.latestBlock() + 2); | ||
const startBlock = (await time.latestBlock()) + 2; | ||
await vault.connect(owner).addProject(projectId, projectRecipient.address, startBlock); | ||
|
||
await expect(vault.connect(owner).claim(projectId)).to.rejectedWith('claim too short'); | ||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('claim too short'); | ||
|
||
await mine(10); | ||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('insufficient fund'); | ||
|
||
await vault.donate({value: ethers.parseEther("1")}); | ||
await vault.donate({ value: ethers.parseEther('1') }); | ||
let claimBeforeBalance = await ethers.provider.getBalance(projectRecipient.address); | ||
let tx = await vault.connect(projectRecipient).claim(projectId); | ||
let claimAfterBalance = await ethers.provider.getBalance(projectRecipient.address); | ||
let receipt = await ethers.provider.getTransactionReceipt(tx.hash); | ||
expect(claimBeforeBalance).to.equals(claimAfterBalance - ethers.parseEther("1") + receipt!.gasUsed * receipt!.gasPrice); | ||
expect(claimBeforeBalance).to.equals( | ||
claimAfterBalance - ethers.parseEther('1') + receipt!.gasUsed * receipt!.gasPrice, | ||
); | ||
|
||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('claim too short'); | ||
|
||
const lastClaimedBlock = await vault.lastClaimedBlock(projectId); | ||
await mineUpTo(lastClaimedBlock + BigInt(10)); | ||
|
||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('insufficient fund'); | ||
await vault.donate({value: ethers.parseEther("1")}); | ||
await vault.donate({ value: ethers.parseEther('1') }); | ||
claimBeforeBalance = await ethers.provider.getBalance(projectRecipient.address); | ||
tx = await vault.connect(projectRecipient).claim(projectId); | ||
claimAfterBalance = await ethers.provider.getBalance(projectRecipient.address); | ||
receipt = await ethers.provider.getTransactionReceipt(tx.hash); | ||
expect(claimBeforeBalance).to.equals(claimAfterBalance - ethers.parseEther("1") + receipt!.gasUsed * receipt!.gasPrice); | ||
expect(claimBeforeBalance).to.equals( | ||
claimAfterBalance - ethers.parseEther('1') + receipt!.gasUsed * receipt!.gasPrice, | ||
); | ||
|
||
await vault.removeProject(projectId); | ||
await expect(vault.connect(projectRecipient).claim(projectId)).to.rejectedWith('invalid project'); | ||
|
||
expect(await vault.lastClaimedBlock(projectId)).to.equals(0); | ||
expect(await vault.projectRecipient(projectId)).to.equals('0x0000000000000000000000000000000000000000'); | ||
}) | ||
}) | ||
}); | ||
}); |
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