diff --git a/scripts/constants.ts b/scripts/constants.ts index 9b289cc..5113287 100644 --- a/scripts/constants.ts +++ b/scripts/constants.ts @@ -13,4 +13,4 @@ export const BINANCE_ADDRESS = '0x564286362092D8e7936f0549571a803B203aAceD'; export const BINANCE7_ADDRESS = '0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8'; export const DAI_RICH_ADDRESS = '0xF977814e90dA44bFA03b6295A0616a897441aceC'; export const USDC_RICH_ADDRESS = '0x55FE002aefF02F77364de339a1292923A15844B8'; -export const WBTC_RICH_ADDRESS = '0xe3dd3914ab28bb552d41b8dfe607355de4c37a51'; \ No newline at end of file +export const WBTC_RICH_ADDRESS = '0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE'; \ No newline at end of file diff --git a/scripts/createAndRunPrizePoolMumbai.ts b/scripts/createAndRunPrizePoolMumbai.ts deleted file mode 100644 index 8b79650..0000000 --- a/scripts/createAndRunPrizePoolMumbai.ts +++ /dev/null @@ -1,254 +0,0 @@ -import { HardhatRuntimeEnvironment } from "hardhat/types" -import {ethers, deployments, getNamedAccounts, getChainId} from "hardhat" -import Erc20MintableAbi from "../abis/ERC20Mintable.json" - -import PoolWithMultipleWinnersBuilder from '@pooltogether/pooltogether-contracts/deployments/mumbai/PoolWithMultipleWinnersBuilder.json'; -import RNGBlockhash from '@pooltogether/pooltogether-rng-contracts/deployments/mumbai_80001/RNGBlockhash.json'; -import ControlledToken from '@pooltogether/pooltogether-contracts/abis/ControlledToken.json'; -import MultipleWinners from '@pooltogether/pooltogether-contracts/abis/MultipleWinners.json'; -import YieldSourcePrizePool from '@pooltogether/pooltogether-contracts/abis/YieldSourcePrizePool.json'; - -import { BigNumber } from 'ethers'; -import { dai } from '@studydefi/money-legos/erc20'; -import { info, success } from './helpers'; - -interface DepositAsset { - depositAssetName: string, - depositAssetAddress: string, - depositAmount: BigNumber, - depositAssetAbi: any -} - - -async function createPrizePools(){ - console.log("running create prize pool script with chainId ", await getChainId()) - - const { deployer } = await getNamedAccounts() - - console.log("deployer is ", deployer) - const signer = await ethers.provider.getSigner(deployer) - - const allDeployments = await deployments.all() - - const aaveTokenAddress = "0x341d1f30e77D3FBfbD43D17183E2acb9dF25574E" - - console.log("balance of deployer ", await ethers.provider.getBalance(deployer)) - - // minting mumbai AAVE - const aaveTokenContract = await ethers.getContractAt(Erc20MintableAbi, aaveTokenAddress, signer) - await aaveTokenContract.transfer(deployer, "50") - - - // call for each deployed yield source - console.log("running lifecycle for aAAVE") - - await poolLifecycle(signer, allDeployments.aAAVE.address, - {depositAssetName: "AAVE", - depositAssetAddress: aaveTokenAddress, - depositAssetAbi: dai.abi, - depositAmount: BigNumber.from(50) - }) - -} -createPrizePools() - - - -async function poolLifecycle(contractsOwner: any, aTokenYieldSourceAddress: string, depositArgs: DepositAsset){ - - - const {depositAssetAddress, depositAssetName, depositAmount, depositAssetAbi } = depositArgs - - const { constants, provider, getContractAt, utils } = ethers; - const { getBlock, getBlockNumber, getTransactionReceipt, send } = provider; - - const { AddressZero } = constants - const { formatEther, parseEther: toWei } = utils; - - async function increaseTime(time: number) { - await send('evm_increaseTime', [time]); - await send('evm_mine', []); - } - - - const aTokenYieldSource = (await getContractAt( - 'ATokenYieldSource', - aTokenYieldSourceAddress, - contractsOwner, - )); - - info('Deploying ATokenYieldSourcePrizePool...'); - - const poolBuilder = await getContractAt( - PoolWithMultipleWinnersBuilder.abi, - PoolWithMultipleWinnersBuilder.address, - contractsOwner, - ); - - const aaveYieldSourcePrizePoolConfig = { - yieldSource: aTokenYieldSource.address, - maxExitFeeMantissa: toWei('0.5'), - maxTimelockDuration: 1000, - }; - - const block = await getBlock(await getBlockNumber()); - - info(`Block number ${block.number}`); - - const multipleWinnersConfig = { - rngService: RNGBlockhash.address, - prizePeriodStart: block.timestamp, - prizePeriodSeconds: 60, - ticketName: 'Ticket', - ticketSymbol: 'TICK', - sponsorshipName: 'Sponsorship', - sponsorshipSymbol: 'SPON', - ticketCreditLimitMantissa: toWei('0.1'), - ticketCreditRateMantissa: toWei('0.001'), - numberOfWinners: 1, - }; - - const yieldSourceMultipleWinnersTx = await poolBuilder.createYieldSourceMultipleWinners( - aaveYieldSourcePrizePoolConfig, - multipleWinnersConfig, - 18, - ); - - console.info(yieldSourceMultipleWinnersTx) - - await new Promise(r => setTimeout(r, 120000)); // sleep so that rpc provider has it - - console.log("calling getTranasctionReceipt with ", yieldSourceMultipleWinnersTx.hash) - - const yieldSourceMultipleWinnersReceipt = await getTransactionReceipt( - yieldSourceMultipleWinnersTx.hash, - ); - - console.log("yieldSourceMultipleWinnersReceipt ", yieldSourceMultipleWinnersReceipt) - - const yieldSourcePrizePoolInitializedEvents = yieldSourceMultipleWinnersReceipt.logs.map( - (log: any) => { - try { - return poolBuilder.interface.parseLog(log); - } catch (e) { - return null; - } - }, - ); - - console.log("yieldSourcePrizePoolInitializedEvent ", yieldSourcePrizePoolInitializedEvents) - - const yieldSourcePrizePoolInitializedEvent = yieldSourcePrizePoolInitializedEvents.find((event:any) => - event && event.name === 'YieldSourcePrizePoolWithMultipleWinnersCreated'); - - console.log("yieldSourcePrizePoolInitializedEvent ", yieldSourcePrizePoolInitializedEvent) - - - console.log("yieldSourcePrizePoolInitializedEvent.args.prizePool ", yieldSourcePrizePoolInitializedEvent?.args.prizePool) - const prizePool = await getContractAt( - YieldSourcePrizePool, - yieldSourcePrizePoolInitializedEvent?.args.prizePool, - contractsOwner, - ); - - success(`Deployed ATokenYieldSourcePrizePool! ${prizePool.address}`); - - const prizeStrategy = await getContractAt( - MultipleWinners, - await prizePool.prizeStrategy(), - contractsOwner, - ); - - - const depositAssetContract = await getContractAt(depositAssetAbi, depositAssetAddress, contractsOwner); - await depositAssetContract.approve(prizePool.address, depositAmount); - - info(`Depositing ${depositAmount} ${depositAssetName} for ${contractsOwner._address}, ticket ${await prizeStrategy.ticket()}`); - - - await prizePool.depositTo( - contractsOwner._address, - depositAmount, - await prizeStrategy.ticket(), - AddressZero, - ); - - success('Deposited To!'); - - info(`Prize strategy owner: ${await prizeStrategy.owner()}`); - - - - info('Starting award...'); - await prizeStrategy.startAward(); - - await new Promise(r => setTimeout(r, 60000)); // sleep so can completeAward - - info('Completing award...'); - const awardTx = await prizeStrategy.completeAward(); - - await new Promise(r => setTimeout(r, 220000)); - const awardReceipt = await getTransactionReceipt(awardTx.hash); - - console.log("awardReceipt ", awardReceipt) - - const awardLogs = awardReceipt.logs.map((log:any) => { - try { - return prizePool.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - const completeAwardLogs = awardReceipt.logs.map((log:any) => { - try { - return prizeStrategy.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - console.log("completeAwardLogs ", completeAwardLogs) - - const awarded = awardLogs.find((event:any) => event && event.name === 'Awarded'); - // console.log("awarded event", awarded) - - if(awarded){ - success(`Awarded ${awarded?.args?.amount} ${depositAssetName}!`); - } - - - info('Withdrawing...'); - const ticketAddress = await prizeStrategy.ticket(); - const ticket = await getContractAt(ControlledToken, ticketAddress, contractsOwner); - - const withdrawalAmount = depositAmount.div(2); // withdraw half the amount deposited - - const earlyExitFee = await prizePool.callStatic.calculateEarlyExitFee(contractsOwner.address, ticket.address, withdrawalAmount); - - const withdrawTx = await prizePool.withdrawInstantlyFrom( - contractsOwner._address, - withdrawalAmount, - ticket.address, - earlyExitFee.exitFee, - ); - - - await new Promise(r => setTimeout(r, 220000)); - const withdrawReceipt = await getTransactionReceipt(withdrawTx.hash); - const withdrawLogs = withdrawReceipt.logs.map((log:any) => { - try { - return prizePool.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - const withdrawn = withdrawLogs.find((event:any) => event && event.name === 'InstantWithdrawal'); - success(`Withdrawn ${withdrawn?.args?.redeemed} ${depositAssetName}!`); - success(`Exit fee was ${withdrawn?.args?.exitFee} ${depositAssetName}`); - - await prizePool.captureAwardBalance(); - const awardBalance = await prizePool.callStatic.awardBalance(); - success(`Current awardable balance is ${awardBalance} ${depositAssetName}`); -} \ No newline at end of file diff --git a/scripts/createAndRunPrizePoolPolygon.ts b/scripts/createAndRunPrizePoolPolygon.ts deleted file mode 100644 index fca5977..0000000 --- a/scripts/createAndRunPrizePoolPolygon.ts +++ /dev/null @@ -1,255 +0,0 @@ -import { HardhatRuntimeEnvironment } from "hardhat/types" -import {ethers, deployments, getNamedAccounts, getChainId} from "hardhat" -import Erc20UpgradeableAbi from "../abis/ERC20Upgradeable.json" - -import PoolWithMultipleWinnersBuilder from '@pooltogether/pooltogether-contracts/deployments/matic/PoolWithMultipleWinnersBuilder.json'; -import RNGBlockhash from '@pooltogether/pooltogether-rng-contracts/deployments/matic_137/RNGBlockhash.json'; -import ControlledToken from '@pooltogether/pooltogether-contracts/abis/ControlledToken.json'; -import MultipleWinners from '@pooltogether/pooltogether-contracts/abis/MultipleWinners.json'; -import YieldSourcePrizePool from '@pooltogether/pooltogether-contracts/abis/YieldSourcePrizePool.json'; - -import { BigNumber } from 'ethers'; -import { dai, wbtc } from '@studydefi/money-legos/erc20'; -import { info, success } from './helpers'; - -interface DepositAsset { - depositAssetName: string, - depositAssetAddress: string, - depositAmount: BigNumber, - depositAssetAbi: any -} - - -export async function createPrizePools(){ - console.log("running create prize pool script with chainId ", await getChainId()) - - const { deployer } = await getNamedAccounts() - - console.log("deployer is ", deployer) - const signer = await ethers.provider.getSigner(deployer) - - const allDeployments = await deployments.all() - - const aaveTokenAddress = "0x341d1f30e77D3FBfbD43D17183E2acb9dF25574E" - - console.log("balance of deployer ", await ethers.provider.getBalance(deployer)) - - // minting mumbai AAVE - const aaveTokenContract = await ethers.getContractAt(Erc20UpgradeableAbi, aaveTokenAddress, signer) - // const mintResult = await aaveTokenContract.transfer(deployer, "100") - - // console.log(mintResult) - - - // call for each deployed yield source - console.log("running lifecycle for aAAVE") - - await poolLifecycle(signer, allDeployments.aAAVE.address, - {depositAssetName: "AAVE", - depositAssetAddress: aaveTokenAddress, - depositAssetAbi: dai.abi, - depositAmount: BigNumber.from(50) - }) - -} -createPrizePools() - - - -async function poolLifecycle(contractsOwner: any, aTokenYieldSourceAddress: string, depositArgs: DepositAsset){ - - - const {depositAssetAddress, depositAssetName, depositAmount, depositAssetAbi } = depositArgs - - const { constants, provider, getContractAt, utils } = ethers; - const { getBlock, getBlockNumber, getTransactionReceipt, send } = provider; - - const { AddressZero } = constants - const { parseEther: toWei } = utils; - - async function increaseTime(time: number) { - await send('evm_increaseTime', [time]); - await send('evm_mine', []); - } - - - const aTokenYieldSource = (await getContractAt( - 'ATokenYieldSource', - aTokenYieldSourceAddress, - contractsOwner, - )); - - info('Deploying ATokenYieldSourcePrizePool...'); - - const poolBuilder = await getContractAt( - PoolWithMultipleWinnersBuilder.abi, - PoolWithMultipleWinnersBuilder.address, - contractsOwner, - ); - - const aaveYieldSourcePrizePoolConfig = { - yieldSource: aTokenYieldSource.address, - maxExitFeeMantissa: toWei('0.5'), - maxTimelockDuration: 1000, - }; - - const block = await getBlock(await getBlockNumber()); - - info(`Block number ${block.number}`); - - const multipleWinnersConfig = { - rngService: RNGBlockhash.address, - prizePeriodStart: block.timestamp, - prizePeriodSeconds: 60, - ticketName: 'Ticket', - ticketSymbol: 'TICK', - sponsorshipName: 'Sponsorship', - sponsorshipSymbol: 'SPON', - ticketCreditLimitMantissa: toWei('0.1'), - ticketCreditRateMantissa: toWei('0.001'), - numberOfWinners: 1, - }; - - const yieldSourceMultipleWinnersTx = await poolBuilder.createYieldSourceMultipleWinners( - aaveYieldSourcePrizePoolConfig, - multipleWinnersConfig, - 18, - ); - - console.info(yieldSourceMultipleWinnersTx) - - await new Promise(r => setTimeout(r, 120000)); // sleep so that rpc provider has it - - console.log("calling getTranasctionReceipt with ", yieldSourceMultipleWinnersTx.hash) - - const yieldSourceMultipleWinnersReceipt = await getTransactionReceipt( - yieldSourceMultipleWinnersTx.hash, - ); - - console.log("yieldSourceMultipleWinnersReceipt ", yieldSourceMultipleWinnersReceipt) - - const yieldSourcePrizePoolInitializedEvents = yieldSourceMultipleWinnersReceipt.logs.map( - (log: any) => { - try { - return poolBuilder.interface.parseLog(log); - } catch (e) { - return null; - } - }, - ); - - console.log("yieldSourcePrizePoolInitializedEvent ", yieldSourcePrizePoolInitializedEvents) - - const yieldSourcePrizePoolInitializedEvent = yieldSourcePrizePoolInitializedEvents.find((event:any) => - event && event.name === 'YieldSourcePrizePoolWithMultipleWinnersCreated'); - - console.log("yieldSourcePrizePoolInitializedEvent ", yieldSourcePrizePoolInitializedEvent) - - - console.log("yieldSourcePrizePoolInitializedEvent.args.prizePool ", yieldSourcePrizePoolInitializedEvent?.args.prizePool) - const prizePool = await getContractAt( - YieldSourcePrizePool, - yieldSourcePrizePoolInitializedEvent?.args.prizePool, - contractsOwner, - ); - - success(`Deployed ATokenYieldSourcePrizePool! ${prizePool.address}`); - - const prizeStrategy = await getContractAt( - MultipleWinners, - await prizePool.prizeStrategy(), - contractsOwner, - ); - - - const depositAssetContract = await getContractAt(depositAssetAbi, depositAssetAddress, contractsOwner); - await depositAssetContract.approve(prizePool.address, depositAmount); - - info(`Depositing ${depositAmount} ${depositAssetName} for ${contractsOwner._address}, ticket ${await prizeStrategy.ticket()}`); - - - await prizePool.depositTo( - contractsOwner._address, - depositAmount, - await prizeStrategy.ticket(), - AddressZero, - ); - - success('Deposit Successful!'); - - info(`Prize strategy owner: ${await prizeStrategy.owner()}`); - - - - info('Starting award...'); - await prizeStrategy.startAward(); - - await new Promise(r => setTimeout(r, 60000)); // sleep so can completeAward - - info('Completing award...'); - const awardTx = await prizeStrategy.completeAward(); - - await new Promise(r => setTimeout(r, 220000)); - const awardReceipt = await getTransactionReceipt(awardTx.hash); - - console.log("awardReceipt ", awardReceipt) - - const awardLogs = awardReceipt.logs.map((log:any) => { - try { - return prizePool.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - const completeAwardLogs = awardReceipt.logs.map((log:any) => { - try { - return prizeStrategy.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - console.log("completeAwardLogs ", completeAwardLogs) - - const awarded = awardLogs.find((event:any) => event && event.name === 'Awarded'); - // console.log("awarded event", awarded) - - if(awarded){ - success(`Awarded ${awarded?.args?.amount} ${depositAssetName}!`); - } - - info('Withdrawing...'); - const ticketAddress = await prizeStrategy.ticket(); - const ticket = await getContractAt(ControlledToken, ticketAddress, contractsOwner); - - const withdrawalAmount = depositAmount.div(2); // withdraw half the amount deposited - - const earlyExitFee = await prizePool.callStatic.calculateEarlyExitFee(contractsOwner.address, ticket.address, withdrawalAmount); - - const withdrawTx = await prizePool.withdrawInstantlyFrom( - contractsOwner._address, - withdrawalAmount, - ticket.address, - earlyExitFee.exitFee, - ); - - - await new Promise(r => setTimeout(r, 220000)); - const withdrawReceipt = await getTransactionReceipt(withdrawTx.hash); - const withdrawLogs = withdrawReceipt.logs.map((log:any) => { - try { - return prizePool.interface.parseLog(log); - } catch (e) { - return null; - } - }); - - const withdrawn = withdrawLogs.find((event:any) => event && event.name === 'InstantWithdrawal'); - success(`Withdrawn ${withdrawn?.args?.redeemed} ${depositAssetName}!`); - success(`Exit fee was ${withdrawn?.args?.exitFee} ${depositAssetName}`); - - await prizePool.captureAwardBalance(); - const awardBalance = await prizePool.callStatic.awardBalance(); - success(`Current awardable balance is ${awardBalance} ${depositAssetName}`); -} \ No newline at end of file diff --git a/scripts/fork/createPoolPrize.ts b/scripts/createPoolPrize.ts similarity index 70% rename from scripts/fork/createPoolPrize.ts rename to scripts/createPoolPrize.ts index ce717bb..2107986 100644 --- a/scripts/fork/createPoolPrize.ts +++ b/scripts/createPoolPrize.ts @@ -3,49 +3,45 @@ import RNGBlockhash from '@pooltogether/pooltogether-rng-contracts/deployments/m import ControlledToken from '@pooltogether/pooltogether-contracts/abis/ControlledToken.json'; import MultipleWinners from '@pooltogether/pooltogether-contracts/abis/MultipleWinners.json'; import YieldSourcePrizePool from '@pooltogether/pooltogether-contracts/abis/YieldSourcePrizePool.json'; +import hre from "hardhat"; +import { wbtc } from '@studydefi/money-legos/erc20'; -import { dai, usdc } from '@studydefi/money-legos/erc20'; - -import { task } from 'hardhat/config'; import { BADGER_WBTC_VAULT_ADDRESS_MAINNET, - WBTC_ADDRESS, WBTC_RICH_ADDRESS, -} from '../constants'; +} from './constants'; + +import { info, success } from './helpers'; -import { info, success } from '../helpers'; -export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').setAction( - async (taskArguments, hre) => { - const { ethers, deployments } = hre; +async function poolCycle() { + const { ethers } = hre; const { constants, provider, getContractAt, getContractFactory, getSigners, utils } = ethers; - const [contractsOwner] = await getSigners(); const { AddressZero } = constants; const { getBlock, getBlockNumber, getTransactionReceipt, send } = provider; - const { deploy } = deployments; async function increaseTime(time: number) { await send('evm_increaseTime', [time]); await send('evm_mine', []); } - info('Deploying BadgerWBTCVaultYieldSource...'); - - const badgerWbtcVaultYieldSourceResult = await deploy('WBTCVaultYieldSource', { - from: await contractsOwner.getAddress(), - }); + const accountToImpersonate = WBTC_RICH_ADDRESS; + await hre.network.provider.request({ + method: "hardhat_impersonateAccount", + params: [accountToImpersonate] + }) + let contractsOwner = await ethers.provider.getSigner(accountToImpersonate) + info('Deploying BadgerWBTCVaultYieldSource...'); - //const BadgerWBTCVaultYieldSourceFactory = await getContractFactory('WBTCVaultYieldSource'); + const BadgerWBTCVaultYieldSourceFactory = await getContractFactory('WBTCVaultYieldSource'); - const BadgerWBTCVaultYieldSource = await getContractAt( - 'WBTCVaultYieldSource', badgerWbtcVaultYieldSourceResult.address); - //(await BadgerWBTCVaultYieldSourceFactory.deploy()); + const BadgerWBTCVaultYieldSource = (await BadgerWBTCVaultYieldSourceFactory.deploy()); await BadgerWBTCVaultYieldSource.initialize( BADGER_WBTC_VAULT_ADDRESS_MAINNET, - WBTC_ADDRESS + wbtc.address ); info('Deploying WbtcYieldSourcePrizePool...'); @@ -68,10 +64,10 @@ export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').set rngService: RNGBlockhash.address, prizePeriodStart: block.timestamp, prizePeriodSeconds: 60, - ticketName: 'badger-wbtc', - ticketSymbol: 'BAD', - sponsorshipName: 'badger', - sponsorshipSymbol: 'erg', + ticketName: 'Ticket', + ticketSymbol: 'TICK', + sponsorshipName: 'Sponsorship', + sponsorshipSymbol: 'SPON', ticketCreditLimitMantissa: ethers.utils.parseEther('0.1'), ticketCreditRateMantissa: ethers.utils.parseEther('0.001'), numberOfWinners: 1, @@ -83,14 +79,12 @@ export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').set 8, ); - console.log("Tx ", yieldSourceMultipleWinnersTx); + await new Promise(r => setTimeout(r, 120000)); const yieldSourceMultipleWinnersReceipt = await getTransactionReceipt( yieldSourceMultipleWinnersTx.hash, ); - console.log("Receipt ", yieldSourceMultipleWinnersReceipt); - const yieldSourcePrizePoolInitializedEvent = yieldSourceMultipleWinnersReceipt.logs.map( (log) => { try { @@ -111,35 +105,39 @@ export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').set success(`Deployed BadgeWBTCYieldSourcePrizePool! ${prizePool.address}`); - /*const prizeStrategy = await getContractAt( + console.log("WBTC address: ", wbtc.address); + console.log("Badger Vault address: ", BADGER_WBTC_VAULT_ADDRESS_MAINNET); + console.log("Yield Source Addres: ", BadgerWBTCVaultYieldSource.address); + + const prizeStrategy = await getContractAt( MultipleWinners, await prizePool.prizeStrategy(), contractsOwner, ); - await prizeStrategy.addExternalErc20Award(dai.address); + await prizeStrategy.addExternalErc20Award(wbtc.address); - const usdcAmount = ethers.utils.parseUnits('1000', 6); - const usdcContract = await getContractAt(usdc.abi, usdc.address, contractsOwner); - await usdcContract.approve(prizePool.address, usdcAmount); + const wbtcAmount = ethers.utils.parseUnits('10', 8); + const wbtcContract = await getContractAt(wbtc.abi, wbtc.address, contractsOwner); + await wbtcContract.approve(prizePool.address, wbtcAmount); - info(`Depositing ${ethers.utils.formatUnits(usdcAmount, 6)} USDC...`); + info(`Depositing ${ethers.utils.formatUnits(wbtcAmount, 8)} WBTC...`); await prizePool.depositTo( - contractsOwner.address, - usdcAmount, + contractsOwner._address, + wbtcAmount, await prizeStrategy.ticket(), AddressZero, ); - success('Deposited USDC!'); + success('Deposited WBTC!'); info(`Prize strategy owner: ${await prizeStrategy.owner()}`); await increaseTime(30); // simulating returns in the vault during the prizePeriod - const usdcProfits = ethers.utils.parseUnits('10000', 6); - info(`yVault generated ${ethers.utils.formatUnits(usdcProfits, 6)} USDC`); - await usdcContract.transfer(USDC_VAULT_ADDRESS_MAINNET, usdcProfits); + const wbtcProfits = ethers.utils.parseUnits('100', 8); + info(`Vault generated ${ethers.utils.formatUnits(wbtcProfits, 8)} WBTC`); + await wbtcContract.transfer(BADGER_WBTC_VAULT_ADDRESS_MAINNET, wbtcProfits); await increaseTime(30); @@ -161,16 +159,16 @@ export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').set const awarded = awardLogs.find((event) => event && event.name === 'Awarded'); - success(`Awarded ${ethers.utils.formatUnits(awarded?.args?.amount, 6)} USDC!`); + success(`Awarded ${ethers.utils.formatUnits(awarded?.args?.amount, 8)} WBTC!`); info('Withdrawing...'); const ticketAddress = await prizeStrategy.ticket(); const ticket = await getContractAt(ControlledToken, ticketAddress, contractsOwner); const withdrawalAmount = ethers.utils.parseUnits('100', 6); - const earlyExitFee = await prizePool.callStatic.calculateEarlyExitFee(contractsOwner.address, ticket.address, withdrawalAmount); + const earlyExitFee = await prizePool.callStatic.calculateEarlyExitFee(contractsOwner._address, ticket.address, withdrawalAmount); const withdrawTx = await prizePool.withdrawInstantlyFrom( - contractsOwner.address, + contractsOwner._address, withdrawalAmount, ticket.address, earlyExitFee.exitFee, @@ -186,11 +184,17 @@ export default task('fork:create-wbtc-pool-prize', 'Create WBTC Prize Pool').set }); const withdrawn = withdrawLogs.find((event) => event && event.name === 'InstantWithdrawal'); - success(`Withdrawn ${ethers.utils.formatUnits(withdrawn?.args?.redeemed, 6)} USDC!`); - success(`Exit fee was ${ethers.utils.formatUnits(withdrawn?.args?.exitFee, 6)} USDC`); + success(`Withdrawn ${ethers.utils.formatUnits(withdrawn?.args?.redeemed, 6)} WBTC!`); + success(`Exit fee was ${ethers.utils.formatUnits(withdrawn?.args?.exitFee, 6)} WBTC`); await prizePool.captureAwardBalance(); const awardBalance = await prizePool.callStatic.awardBalance(); - success(`Current awardable balance is ${ethers.utils.formatUnits(awardBalance, 6)} USDC`);*/ - }, -); + success(`Current awardable balance is ${ethers.utils.formatUnits(awardBalance, 8)} WBTC`) + } + +poolCycle() +.then(() => process.exit(0)) +.catch(error => { + console.error(error); + process.exit(1); +}); diff --git a/scripts/fork/distributeEtherFromBinance.ts b/scripts/fork/distributeEtherFromBinance.ts deleted file mode 100644 index ed49f33..0000000 --- a/scripts/fork/distributeEtherFromBinance.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { wbtc } from '@studydefi/money-legos/erc20'; - -import { task } from 'hardhat/config'; - -import { WBTC_RICH_ADDRESS } from '../constants'; -import { info, success } from '../helpers'; - -export default task( - 'fork:distribute-ether-from-binance', - 'Distribute Ether from Binance', -).setAction(async (taskArguments, hre) => { - info('Gathering funds from Binance...'); - - const { getNamedAccounts, ethers } = hre; - const { provider, getContractAt } = ethers; - const { deployer } = await getNamedAccounts(); - - const wbtc_rich = provider.getUncheckedSigner(WBTC_RICH_ADDRESS); - - const wbtcContract = await getContractAt(wbtc.abi, wbtc.address, wbtc_rich); - - const recipients: { [key: string]: string } = { - ['Deployer']: deployer, - }; - - const keys = Object.keys(recipients); - - for (var i = 0; i < keys.length; i++) { - const name = keys[i]; - const address = recipients[name]; - - info(`Sending 200 WBTC to ${name}...`); - await wbtcContract.transfer(address, ethers.utils.parseUnits('200', 8)); - - info(`Sending 100 Ether to ${name}...`); - await wbtc_rich.sendTransaction({ to: address, value: ethers.utils.parseEther('100') }); - } - - success('Done!'); -}); diff --git a/scripts/fork/impersonateAccounts.ts b/scripts/fork/impersonateAccounts.ts deleted file mode 100644 index 914df98..0000000 --- a/scripts/fork/impersonateAccounts.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { task } from 'hardhat/config'; - -import { BINANCE_ADDRESS, BINANCE7_ADDRESS, DAI_RICH_ADDRESS } from '../../Constant'; -import { WBTC_RICH_ADDRESS } from '../constants'; -import { info, success } from '../helpers'; - -export default task('fork:impersonate-accounts', 'Impersonate accounts').setAction( - async (taskArguments, hre) => { - info('Impersonate accounts...'); - - await hre.network.provider.request({ - method: 'hardhat_impersonateAccount', - params: ['0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6'], - }); - - await hre.network.provider.request({ - method: 'hardhat_impersonateAccount', - params: [WBTC_RICH_ADDRESS], - }); - - await hre.network.provider.request({ - method: 'hardhat_impersonateAccount', - params: [BINANCE7_ADDRESS], - }); - - await hre.network.provider.request({ - method: 'hardhat_impersonateAccount', - params: [DAI_RICH_ADDRESS], - }); - - success('Done!'); - }, -); diff --git a/scripts/fork/index.ts b/scripts/fork/index.ts deleted file mode 100644 index c36667f..0000000 --- a/scripts/fork/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * as impersonateAccountsTask from './impersonateAccounts'; -export * as distributeEtherFromBinanceTask from './distributeEtherFromBinance'; -export * as createPoolPrizeTask from './createPoolPrize'; diff --git a/scripts/generateDeployment.ts b/scripts/generateDeployment.ts deleted file mode 100644 index 6c6bac0..0000000 --- a/scripts/generateDeployment.ts +++ /dev/null @@ -1,43 +0,0 @@ -interface ProxyDeployment { - address?: string - abi?: any - transactionHash?: string - receipt?: any - args?: any - bytecode?: string - } - -import { Contract } from "ethers"; -import { writeFileSync } from "fs"; -import {ethers, getNamedAccounts} from "hardhat" - - async function createDeployment(){ - - const hash = "0x04e348a719e5e68b858ef78a9140af1e9440a4d48febc5c40a879cfd184757b5" - const receipt = await ethers.provider.getTransactionReceipt(hash); - - console.log("receipt is ", receipt) - - const {genericProxyFactory} = await getNamedAccounts() - let proxyFactoryContract : Contract = await ethers.getContractAt("GenericProxyFactory", genericProxyFactory) - - - const createdEvent = proxyFactoryContract.interface.parseLog(receipt.logs[0]); - - - - - let jsonObj: ProxyDeployment = { - address: createdEvent.args.created, - transactionHash: receipt.transactionHash, - receipt: receipt, - args: ``, - bytecode: `${await ethers.provider.getCode(createdEvent.args.created)}` - } - - writeFileSync(`./deployments/mainnet/aGUSD.json`, JSON.stringify(jsonObj), {encoding:'utf8',flag:'w'}) - - console.log("finished") - } - - createDeployment() \ No newline at end of file diff --git a/scripts/helpers.ts b/scripts/helpers.ts index 36a90d0..2719baf 100644 --- a/scripts/helpers.ts +++ b/scripts/helpers.ts @@ -1,4 +1,4 @@ -import chalk from 'chalk'; +const chalk = require('chalk'); export const info = (message: string) => console.log(chalk.dim(message)); export const success = (message: string) => console.log(chalk.green(message)); diff --git a/test/ATokenYieldSource.test.ts b/test/ATokenYieldSource.test.ts deleted file mode 100644 index 4280810..0000000 --- a/test/ATokenYieldSource.test.ts +++ /dev/null @@ -1,446 +0,0 @@ -import debug from 'debug'; - -import { Signer } from '@ethersproject/abstract-signer'; -import { BigNumber } from '@ethersproject/bignumber'; -import { JsonRpcProvider } from '@ethersproject/providers'; -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; - -import { expect } from 'chai'; -import { ethers, waffle } from 'hardhat'; - -import { - ATokenInterface as AToken, - ATokenYieldSourceHarness, - IERC20Upgradeable as ERC20, - ILendingPool as LendingPool, - ILendingPoolAddressesProvider as LendingPoolAddressesProvider, - ILendingPoolAddressesProviderRegistry as LendingPoolAddressesProviderRegistry, -} from '../types'; - -import ATokenInterface from '../abis/ATokenInterface.json'; -import ILendingPool from '../abis/ILendingPool.json'; -import ILendingPoolAddressesProvider from '../abis/ILendingPoolAddressesProvider.json'; -import ILendingPoolAddressesProviderRegistry from '../abis/ILendingPoolAddressesProviderRegistry.json'; -import SafeERC20WrapperUpgradeable from '../abis/SafeERC20WrapperUpgradeable.json'; - -const toWei = ethers.utils.parseEther; - -describe('ATokenYieldSource', () => { - let contractsOwner: Signer; - let yieldSourceOwner: SignerWithAddress; - let wallet2: SignerWithAddress; - let provider: JsonRpcProvider; - - let aToken: AToken; - let lendingPool: LendingPool; - let lendingPoolAddressesProvider: LendingPoolAddressesProvider; - let lendingPoolAddressesProviderRegistry: LendingPoolAddressesProviderRegistry; - - let aTokenYieldSource: ATokenYieldSourceHarness; - - let erc20Token: ERC20; - let underlyingToken: ERC20; - - // Numerical error tests for shares decreasing - - beforeEach(async () => { - const { deployMockContract } = waffle; - - [contractsOwner, yieldSourceOwner, wallet2] = await ethers.getSigners(); - provider = waffle.provider; - - debug('mocking tokens...'); - erc20Token = ((await deployMockContract( - contractsOwner, - SafeERC20WrapperUpgradeable, - )) as unknown) as ERC20; - - underlyingToken = ((await deployMockContract( - contractsOwner, - SafeERC20WrapperUpgradeable, - )) as unknown) as ERC20; - - aToken = ((await deployMockContract(contractsOwner, ATokenInterface)) as unknown) as AToken; - await aToken.mock.UNDERLYING_ASSET_ADDRESS.returns(underlyingToken.address); - - debug('mocking contracts...'); - lendingPool = ((await deployMockContract( - contractsOwner, - ILendingPool, - )) as unknown) as LendingPool; - - lendingPoolAddressesProvider = ((await deployMockContract( - contractsOwner, - ILendingPoolAddressesProvider, - )) as unknown) as LendingPoolAddressesProvider; - - lendingPoolAddressesProviderRegistry = ((await deployMockContract( - contractsOwner, - ILendingPoolAddressesProviderRegistry, - )) as unknown) as LendingPoolAddressesProviderRegistry; - - await lendingPoolAddressesProvider.mock.getLendingPool.returns(lendingPool.address); - await lendingPoolAddressesProviderRegistry.mock.getAddressesProvidersList.returns([ - lendingPoolAddressesProvider.address, - '0x67FB118A780fD740C8936511947cC4bE7bb7730c', - ]); - - debug('deploying ATokenYieldSource instance...'); - - const ATokenYieldSource = await ethers.getContractFactory( - 'ATokenYieldSourceHarness', - ); - const hardhatATokenYieldSourceHarness = await ATokenYieldSource.deploy() - - aTokenYieldSource = (await ethers.getContractAt( - 'ATokenYieldSourceHarness', - hardhatATokenYieldSourceHarness.address, - contractsOwner, - )) as ATokenYieldSourceHarness; - - const initializeTx = await aTokenYieldSource.initialize( - aToken.address, - lendingPoolAddressesProviderRegistry.address, - 18, - "Test", - "TEST", - yieldSourceOwner.address - ); - }); - - describe('create()', () => { - it('should create ATokenYieldSource', async () => { - expect(await aTokenYieldSource.aToken()).to.equal(aToken.address); - expect(await aTokenYieldSource.lendingPoolAddressesProviderRegistry()).to.equal( - lendingPoolAddressesProviderRegistry.address, - ); - expect(await aTokenYieldSource.owner()).to.equal(yieldSourceOwner.address); - }); - }); - - describe('depositToken()', () => { - it('should return the underlying token', async () => { - expect(await aTokenYieldSource.depositToken()).to.equal(underlyingToken.address); - }); - }); - - describe('balanceOfToken()', () => { - it('should return user balance', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('1000')); - - expect(await aTokenYieldSource.callStatic.balanceOfToken(wallet2.address)).to.equal( - toWei('500'), - ); - }); - }); - - describe('_tokenToShares()', () => { - it('should return shares amount', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('1000')); - - expect(await aTokenYieldSource.tokenToShares(toWei('10'))).to.equal(toWei('2')); - }); - - it('should return 0 if tokens param is 0', async () => { - expect(await aTokenYieldSource.tokenToShares("0")).to.equal("0"); - }); - - it('should return tokens if totalSupply is 0', async () => { - expect(await aTokenYieldSource.tokenToShares(toWei('100'))).to.equal(toWei('100')); - }); - - it('should return shares even if aToken total supply has a lot of decimals', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('1')); - await aToken.mock.balanceOf - .withArgs(aTokenYieldSource.address) - .returns(toWei('0.000000000000000005')); - - expect(await aTokenYieldSource.tokenToShares(toWei('0.000000000000000005'))).to.equal(toWei('1')); - }); - - it('should return shares even if aToken total supply increases', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('100')); - - expect(await aTokenYieldSource.tokenToShares(toWei('1'))).to.equal(toWei('2')); - - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(ethers.utils.parseUnits('100', 36)); - expect(await aTokenYieldSource.tokenToShares(toWei('1'))).to.equal(2); - }); - - it('should fail to return shares if aToken total supply increases too much', async () => { // failing here - - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('100')); - - expect(await aTokenYieldSource.tokenToShares(toWei('1'))).to.equal(toWei('2')); - - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(ethers.utils.parseUnits('100', 37)); - await expect(aTokenYieldSource.supplyTokenTo(toWei('1'), wallet2.address)).to.be.revertedWith('ATokenYieldSource/shares-equal-zero'); - - }); - }); - - describe('_sharesToToken()', () => { - it('should return tokens amount', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('1000')); - - expect(await aTokenYieldSource.sharesToToken(toWei('2'))).to.equal(toWei('10')); - }); - - it('should return shares if totalSupply is 0', async () => { - expect(await aTokenYieldSource.sharesToToken(toWei('100'))).to.equal(toWei('100')); - }); - - it('should return tokens even if totalSupply has a lot of decimals', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('0.000000000000000005')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('100')); - - expect(await aTokenYieldSource.sharesToToken(toWei('0.000000000000000005'))).to.equal(toWei('100')); - }); - - it('should return tokens even if aToken total supply increases', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('100')); - - expect(await aTokenYieldSource.sharesToToken(toWei('2'))).to.equal(toWei('1')); - - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(ethers.utils.parseUnits('100', 36)); - expect(await aTokenYieldSource.sharesToToken(2)).to.equal(toWei('1')); - }); - }); - - const supplyTokenTo = async (user: SignerWithAddress, userAmount: BigNumber) => { - const lendingPoolAddress = await lendingPoolAddressesProvider.getLendingPool(); - const tokenAddress = await aTokenYieldSource.tokenAddress(); - const userAddress = user.address; - - await underlyingToken.mock.balanceOf.withArgs(yieldSourceOwner.address).returns(toWei('200')); - await aToken.mock.balanceOf.withArgs(aTokenYieldSource.address).returns(toWei('300')); - await underlyingToken.mock.transferFrom - .withArgs(userAddress, aTokenYieldSource.address, userAmount) - .returns(true); - await underlyingToken.mock.allowance - .withArgs(aTokenYieldSource.address, lendingPoolAddress) - .returns(toWei('0')); - await underlyingToken.mock.approve.withArgs(lendingPoolAddress, userAmount).returns(true); - await lendingPool.mock.deposit - .withArgs(tokenAddress, userAmount, aTokenYieldSource.address, 188) - .returns(); - await aTokenYieldSource.connect(user).supplyTokenTo(userAmount, userAddress); - }; - - describe('supplyTokenTo()', () => { - let amount: BigNumber; - let lendingPoolAddress: any; - let tokenAddress: any; - - beforeEach(async () => { - amount = toWei('100'); - lendingPoolAddress = await lendingPoolAddressesProvider.getLendingPool(); - tokenAddress = await aTokenYieldSource.tokenAddress(); - }); - - it('should supply assets if totalSupply is 0', async () => { - await supplyTokenTo(yieldSourceOwner, amount); - expect(await aTokenYieldSource.totalSupply()).to.equal(amount); - }); - - it('should supply assets if totalSupply is not 0', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, toWei('100')); - await aTokenYieldSource.mint(wallet2.address, toWei('100')); - await supplyTokenTo(yieldSourceOwner, amount); - }); - - it('should revert on error', async () => { - await underlyingToken.mock.approve.withArgs(lendingPoolAddress, amount).returns(true); - await lendingPool.mock.deposit - .withArgs(tokenAddress, amount, aTokenYieldSource.address, 188) - .reverts(); - - await expect( - aTokenYieldSource.supplyTokenTo(amount, aTokenYieldSource.address), - ).to.be.revertedWith(''); - }); - }); - - describe('redeemToken()', () => { - let yieldSourceOwnerBalance: BigNumber; - let redeemAmount: BigNumber; - - beforeEach(() => { - yieldSourceOwnerBalance = toWei('300'); - redeemAmount = toWei('100'); - }); - - it('should redeem assets', async () => { - await aTokenYieldSource.mint(yieldSourceOwner.address, yieldSourceOwnerBalance); - await aToken.mock.balanceOf - .withArgs(aTokenYieldSource.address) - .returns(yieldSourceOwnerBalance); - await lendingPool.mock.withdraw - .withArgs(underlyingToken.address, redeemAmount, aTokenYieldSource.address) - .returns(redeemAmount); - - const balanceAfter = await aToken.balanceOf(aTokenYieldSource.address); - const balanceDiff = yieldSourceOwnerBalance.sub(balanceAfter); - - await underlyingToken.mock.transfer - .withArgs(yieldSourceOwner.address, balanceDiff) - .returns(true); - - await aTokenYieldSource.connect(yieldSourceOwner).redeemToken(redeemAmount); - - expect(await aTokenYieldSource.callStatic.balanceOf(yieldSourceOwner.address)).to.equal( - yieldSourceOwnerBalance.sub(redeemAmount), - ); - }); - - it('should not be able to redeem assets if balance is 0', async () => { - await expect( - aTokenYieldSource.connect(yieldSourceOwner).redeemToken(redeemAmount), - ).to.be.revertedWith('ERC20: burn amount exceeds balance'); - }); - - it('should fail to redeem if amount superior to balance', async () => { - const yieldSourceOwnerLowBalance = toWei('10'); - - await aTokenYieldSource.mint(yieldSourceOwner.address, yieldSourceOwnerLowBalance); - await aToken.mock.balanceOf - .withArgs(aTokenYieldSource.address) - .returns(yieldSourceOwnerLowBalance); - await lendingPool.mock.withdraw - .withArgs(underlyingToken.address, redeemAmount, aTokenYieldSource.address) - .returns(redeemAmount); - - await expect( - aTokenYieldSource.connect(yieldSourceOwner).redeemToken(redeemAmount), - ).to.be.revertedWith('ERC20: burn amount exceeds balance'); - }); - }); - - describe('transferERC20()', () => { - it('should transferERC20 if yieldSourceOwner', async () => { - const transferAmount = toWei('10'); - - await erc20Token.mock.transfer.withArgs(wallet2.address, transferAmount).returns(true); - - await aTokenYieldSource - .connect(yieldSourceOwner) - .transferERC20(erc20Token.address, wallet2.address, transferAmount); - }); - - it('should transferERC20 if assetManager', async () => { - const transferAmount = toWei('10'); - - await erc20Token.mock.transfer - .withArgs(yieldSourceOwner.address, transferAmount) - .returns(true); - - await aTokenYieldSource.connect(yieldSourceOwner).setAssetManager(wallet2.address); - - await aTokenYieldSource - .connect(wallet2) - .transferERC20(erc20Token.address, yieldSourceOwner.address, transferAmount); - }); - - it('should not allow to transfer aToken', async () => { - await expect( - aTokenYieldSource - .connect(yieldSourceOwner) - .transferERC20(aToken.address, wallet2.address, toWei('10')), - ).to.be.revertedWith('ATokenYieldSource/aToken-transfer-not-allowed'); - }); - - it('should fail to transferERC20 if not yieldSourceOwner or assetManager', async () => { - await expect( - aTokenYieldSource - .connect(wallet2) - .transferERC20(erc20Token.address, yieldSourceOwner.address, toWei('10')), - ).to.be.revertedWith('OwnerOrAssetManager: caller is not owner or asset manager'); - }); - }); - - describe('sponsor()', () => { - let amount: BigNumber; - let lendingPoolAddress: any; - let tokenAddress: any; - - beforeEach(async () => { - amount = toWei('500'); - lendingPoolAddress = await lendingPoolAddressesProvider.getLendingPool(); - tokenAddress = await aTokenYieldSource.tokenAddress(); - }); - - it('should sponsor Yield Source', async () => { - const wallet2Amount = toWei('100'); - await aTokenYieldSource.mint(wallet2.address, wallet2Amount); - - await underlyingToken.mock.transferFrom - .withArgs(yieldSourceOwner.address, aTokenYieldSource.address, amount) - .returns(true); - await underlyingToken.mock.allowance - .withArgs(aTokenYieldSource.address, lendingPoolAddress) - .returns(toWei('0')); - await underlyingToken.mock.approve.withArgs(lendingPoolAddress, amount).returns(true); - await lendingPool.mock.deposit - .withArgs(tokenAddress, amount, aTokenYieldSource.address, 188) - .returns(); - - await aTokenYieldSource.connect(yieldSourceOwner).sponsor(amount); - await aToken.mock.balanceOf - .withArgs(aTokenYieldSource.address) - .returns(amount.add(wallet2Amount)); - expect(await aTokenYieldSource.callStatic.balanceOfToken(wallet2.address)).to.equal( - amount.add(wallet2Amount), - ); - }); - - it('should revert on error', async () => { - await underlyingToken.mock.transferFrom - .withArgs(yieldSourceOwner.address, aTokenYieldSource.address, amount) - .returns(true); - await underlyingToken.mock.allowance - .withArgs(aTokenYieldSource.address, lendingPoolAddress) - .returns(toWei('0')); - await underlyingToken.mock.approve.withArgs(lendingPoolAddress, amount).returns(true); - await lendingPool.mock.deposit - .withArgs(tokenAddress, amount, aTokenYieldSource.address, 188) - .reverts(); - - await expect(aTokenYieldSource.connect(yieldSourceOwner).sponsor(amount)).to.be.revertedWith( - '', - ); - }); - }); - - describe('_lendingPoolProvider()', () => { - it('should return Aave LendingPoolAddressesProvider address', async () => { - const lendingPoolAddressesProviderList = await lendingPoolAddressesProviderRegistry.getAddressesProvidersList(); - - expect(await aTokenYieldSource.connect(yieldSourceOwner).lendingPoolProvider()).to.equal( - lendingPoolAddressesProviderList[0], - ); - }); - }); - - describe('_lendingPool()', () => { - it('should return Aave LendingPool address', async () => { - expect(await aTokenYieldSource.connect(yieldSourceOwner).lendingPool()).to.equal( - lendingPool.address, - ); - }); - }); -}); -function toHex(arg0: number) { - throw new Error('Function not implemented.'); -}