mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Clean up code a bit
This commit is contained in:
parent
3207bdd3b0
commit
a8ad815814
|
@ -19,9 +19,9 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
|
|||
|
||||
/**
|
||||
* @dev Deposit into Prize Pool
|
||||
* @notice Deposit a token into a prize pool
|
||||
* @notice Deposit assets into the Prize Pool in exchange for tokens
|
||||
* @param prizePool PrizePool address to deposit to
|
||||
* @param to Address to whom the controlled tokens should be minted
|
||||
* @param to The address receiving the newly minted tokens
|
||||
* @param amount The amount of the underlying asset the user wishes to deposit. The Prize Pool contract should have been pre-approved by the caller to transfer the underlying ERC20 tokens.
|
||||
* @param controlledToken The address of the token that they wish to mint. For our default Prize Strategy this will either be the Ticket address or the Sponsorship address. Those addresses can be looked up on the Prize Strategy.
|
||||
* @param referrer The address that should receive referral awards, if any.
|
||||
|
@ -57,12 +57,12 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
|
|||
|
||||
/**
|
||||
* @dev Withdraw from Prize Pool
|
||||
* @notice Withdraw a token from a prize pool
|
||||
* @notice Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit.
|
||||
* @param prizePool PrizePool address to deposit to
|
||||
* @param from The address to withdraw from. This means you can withdraw on another user's behalf if you have an allowance for the controlled token.
|
||||
* @param amount THe amount to withdraw
|
||||
* @param controlledToken The controlled token to withdraw from.
|
||||
* @param maximumExitFee The maximum early exit fee the caller is willing to pay. This prevents the Prize Strategy from changing the fee on the fly.
|
||||
* @param from The address to redeem tokens from.. This means you can withdraw on another user's behalf if you have an allowance for the controlled token.
|
||||
* @param amount The amount of tokens to redeem for assets.
|
||||
* @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship)
|
||||
* @param maximumExitFee The maximum early exit fee the caller is willing to pay. This prevents the Prize Strategy from changing the fee on the fly. This should be pre-calculated by the calculateExitFee() fxn.
|
||||
* @param getId Get token amount at this ID from `InstaMemory` Contract.
|
||||
* @param setId Set token amount at this ID in `InstaMemory` Contract.
|
||||
*/
|
||||
|
@ -169,8 +169,8 @@ abstract contract PoolTogetherResolver is Events, DSMath, Basic {
|
|||
|
||||
/**
|
||||
* @dev Withdraw from shares from Pod
|
||||
* @dev The function should first withdraw from the 'float'; i.e. the funds that have not yet been deposited.
|
||||
* @notice Withdraws a users share of the prize pool.
|
||||
* @dev The function should first withdraw from the 'float'; i.e. the funds that have not yet been deposited.
|
||||
* @param pod Pod address
|
||||
* @param shareAmount The number of Pod shares to burn.
|
||||
* @param maxFee Max fee amount for withdrawl if amount isn't available in float.
|
||||
|
|
|
@ -17,22 +17,22 @@ const connectV2CompoundArtifacts = require("../../artifacts/contracts/mainnet/co
|
|||
const connectV2PoolTogetherArtifacts = require("../../artifacts/contracts/mainnet/connectors/pooltogether/main.sol/ConnectV2PoolTogether.json")
|
||||
const connectV2UniswapArtifacts = require("../../artifacts/contracts/mainnet/connectors/uniswap/main.sol/ConnectV2UniswapV2.json")
|
||||
|
||||
const token = tokens.dai.address // DAI Token
|
||||
const DAI_TOKEN_ADDR = tokens.dai.address // DAI Token
|
||||
|
||||
// PoolTogether Address: https://docs.pooltogether.com/resources/networks/ethereum
|
||||
const prizePool = "0xEBfb47A7ad0FD6e57323C8A42B2E5A6a4F68fc1a" // DAI Prize Pool
|
||||
const controlledToken = "0x334cBb5858417Aee161B53Ee0D5349cCF54514CF" // PT DAI Ticket
|
||||
const daiPoolFaucet = "0xF362ce295F2A4eaE4348fFC8cDBCe8d729ccb8Eb" // DAI POOL Faucet
|
||||
const poolTokenAddress = "0x0cEC1A9154Ff802e7934Fc916Ed7Ca50bDE6844e"
|
||||
const tokenFaucetProxyFactory = "0xE4E9cDB3E139D7E8a41172C20b6Ed17b6750f117" // TokenFaucetProxyFactory for claimAll
|
||||
const daiPod = "0x2f994e2E4F3395649eeE8A89092e63Ca526dA829" // DAI Pod
|
||||
const uniswapPoolETHLPPrizePool = "0x3AF7072D29Adde20FC7e173a7CB9e45307d2FB0A" // Uniswap Pool/ETH LP PrizePool
|
||||
const uniswapPoolETHLPFaucet = "0x9A29401EF1856b669f55Ae5b24505b3B6fAEb370" // Uniswap Pool/ETH LP Faucet
|
||||
const uniswapPOOLETHLPToken = "0x85cb0bab616fe88a89a35080516a8928f38b518b"
|
||||
const ptUniswapPOOLETHLPTicket = "0xeb8928ee92efb06c44d072a24c2bcb993b61e543"
|
||||
const poolPoolPrizePool = "0x396b4489da692788e327e2e4b2b0459a5ef26791"
|
||||
const ptPoolTicket = "0x27d22a7648e955e510a40bdb058333e9190d12d4"
|
||||
const WETHAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
const DAI_PRIZE_POOL_ADDR = "0xEBfb47A7ad0FD6e57323C8A42B2E5A6a4F68fc1a" // DAI Prize Pool
|
||||
const PT_DAI_TICKET_ADDR = "0x334cBb5858417Aee161B53Ee0D5349cCF54514CF" // PT DAI Ticket
|
||||
const DAI_POOL_FAUCET_ADDR = "0xF362ce295F2A4eaE4348fFC8cDBCe8d729ccb8Eb" // DAI POOL Faucet
|
||||
const POOL_TOKEN_ADDRESS = "0x0cEC1A9154Ff802e7934Fc916Ed7Ca50bDE6844e" // POOL Tocken
|
||||
const TOKEN_FAUCET_PROXY_FACTORY_ADDR = "0xE4E9cDB3E139D7E8a41172C20b6Ed17b6750f117" // TokenFaucetProxyFactory for claimAll
|
||||
const DAI_POD_ADDR = "0x2f994e2E4F3395649eeE8A89092e63Ca526dA829" // DAI Pod
|
||||
const UNISWAP_POOLETHLP_PRIZE_POOL_ADDR = "0x3AF7072D29Adde20FC7e173a7CB9e45307d2FB0A" // Uniswap Pool/ETH LP PrizePool
|
||||
const UNISWAP_POOLETHLP_FAUCET_ADDR = "0x9A29401EF1856b669f55Ae5b24505b3B6fAEb370" // Uniswap Pool/ETH LP Faucet
|
||||
const UNISWAP_POOLETHLP_TOKEN_ADDR = "0x85cb0bab616fe88a89a35080516a8928f38b518b" // Uniswap Pool/ETH Token
|
||||
const PT_UNISWAP_POOLETHLP_TICKET_ADDR = "0xeb8928ee92efb06c44d072a24c2bcb993b61e543" // Pool Together Uniswap Pool/ETH LP Ticket
|
||||
const POOL_PRIZE_POOL_ADDR = "0x396b4489da692788e327e2e4b2b0459a5ef26791" // POOL Prize Pool
|
||||
const PT_POOL_TICKET_ADDR = "0x27d22a7648e955e510a40bdb058333e9190d12d4" // Pool Together POOL Ticket
|
||||
const WETH_ADDR = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" // WETH
|
||||
|
||||
describe("PoolTogether", function () {
|
||||
const connectorName = "COMPOUND-TEST-A"
|
||||
|
@ -91,7 +91,7 @@ describe("PoolTogether", function () {
|
|||
expect(!!dsaWallet0.address).to.be.true;
|
||||
});
|
||||
|
||||
it("Deposit ETH into DSA wallet", async function () {
|
||||
it("Deposit 10 ETH into DSA wallet", async function () {
|
||||
await wallet0.sendTransaction({
|
||||
to: dsaWallet0.address,
|
||||
value: ethers.utils.parseEther("10")
|
||||
|
@ -102,7 +102,7 @@ describe("PoolTogether", function () {
|
|||
|
||||
describe("Main - DAI Prize Pool Test", function () {
|
||||
|
||||
it("Should deposit ETH in Compound", async function () {
|
||||
it("Should deposit 1 ETH in Compound", async function () {
|
||||
const amount = ethers.utils.parseEther("1") // 1 ETH
|
||||
const spells = [
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ describe("PoolTogether", function () {
|
|||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9"));
|
||||
});
|
||||
|
||||
it("Should borrow DAI from Compound and deposit DAI into DAI Prize Pool", async function () {
|
||||
it("Should borrow 100 DAI from Compound and deposit DAI into DAI Prize Pool", async function () {
|
||||
const amount = ethers.utils.parseEther("100") // 100 DAI
|
||||
const setId = "83478237"
|
||||
const spells = [
|
||||
|
@ -129,38 +129,30 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositTo",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, constants.address_zero, setId, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, setId, 0]
|
||||
}
|
||||
]
|
||||
// Before Spell
|
||||
// DAI balance 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before spell:");
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI balance is 0`).to.be.eq(ethers.utils.parseEther("0"));
|
||||
|
||||
// PT DAI Ticket balance is 0
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, controlledToken)
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, PT_DAI_TICKET_ADDR)
|
||||
const balance = await cToken.balanceOf(dsaWallet0.address)
|
||||
const tokenName = await cToken.name()
|
||||
console.log("\tBalance before: ", balance.toString(), tokenName)
|
||||
expect(balance,`PoolTogether DAI Ticket balance is 0`).to.be.eq(0);
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address)
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to equal 0
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell:");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.eq(ethers.utils.parseEther("0"));
|
||||
expect(daiBalance, `Expect DAI balance to still equal 0 since it was deposited into Prize Pool`).to.be.eq(0);
|
||||
|
||||
// Expect PT DAI Ticket to equal 100
|
||||
const balanceAfter = await cToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", balanceAfter.toString(), tokenName)
|
||||
expect(balanceAfter.toString()).to.be.eq(ethers.utils.parseEther("100"));
|
||||
expect(balanceAfter, `PoolTogether DAI Ticket balance equals 100`).to.be.eq(ethers.utils.parseEther("100"));
|
||||
|
||||
// ETH used for transaction
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9"));
|
||||
});
|
||||
|
||||
|
@ -170,33 +162,27 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawInstantlyFrom",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, amount, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "claim",
|
||||
args: [daiPoolFaucet, dsaWallet0.address, 0]
|
||||
args: [DAI_POOL_FAUCET_ADDR, dsaWallet0.address, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI balance equals 0`).to.be.eq(ethers.utils.parseEther("0"));
|
||||
|
||||
// PT Dai Ticket is 100
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, controlledToken)
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, PT_DAI_TICKET_ADDR)
|
||||
const balance = await cToken.balanceOf(dsaWallet0.address)
|
||||
const tokenName = await cToken.name()
|
||||
console.log("\tBalance before: ", balance.toString(), tokenName)
|
||||
expect(balance, `PoolTogether Dai Ticket is 100`).to.be.eq(ethers.utils.parseEther("100"));
|
||||
|
||||
// PoolToken is 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token equals 0`).to.be.eq(ethers.utils.parseEther("0"));
|
||||
|
||||
// Increase time by 11 days so we get back all DAI without early withdrawal fee
|
||||
await ethers.provider.send("evm_increaseTime", [11*24*60*60]);
|
||||
|
@ -206,21 +192,16 @@ describe("PoolTogether", function () {
|
|||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be equal to 100, because of no early withdrawal fee
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.eq(ethers.utils.parseEther("100"));
|
||||
expect(daiBalance,
|
||||
`DAI balance to be equal to 100, because of no early withdrawal fee`
|
||||
).to.be.eq(ethers.utils.parseEther("100"));
|
||||
|
||||
// Expect PT Dai Ticket to equal 0
|
||||
const balanceAfter = await cToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", balanceAfter.toString(), tokenName)
|
||||
expect(balanceAfter.toNumber()).to.be.eq(0);
|
||||
expect(balanceAfter, `PoolTogether Dai Ticket to equal 0`).to.be.eq(0);
|
||||
|
||||
// Expect Pool Token Balance to be greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `POOL Token Balance to be greater than 0`).to.be.gt(ethers.utils.parseEther("0"));
|
||||
});
|
||||
|
||||
it("Should deposit and withdraw all PrizePool, get back less than 100 DAI", async function() {
|
||||
|
@ -229,54 +210,43 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositTo",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, constants.address_zero, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawInstantlyFrom",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, amount, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI Balance equals 0`).to.be.eq(ethers.utils.parseEther("100"));
|
||||
|
||||
// PT Dai Ticket is 100
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, controlledToken)
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, PT_DAI_TICKET_ADDR)
|
||||
const balance = await cToken.balanceOf(dsaWallet0.address)
|
||||
const tokenName = await cToken.name()
|
||||
console.log("\tBalance before: ", balance.toString(), tokenName)
|
||||
expect(balance, `PoolTogether DAI Ticket equals 0`).to.be.eq(0);
|
||||
|
||||
// PoolToken is 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `PoolTogether Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address)
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be less than 100, because of early withdrawal fee
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.lt(ethers.utils.parseEther("100"));
|
||||
expect(daiBalance,
|
||||
`DAI balance to be less than 100, because of early withdrawal fee`
|
||||
).to.be.lt(ethers.utils.parseEther("100"));
|
||||
|
||||
// Expect PT Dai Ticket to equal 0
|
||||
const balanceAfter = await cToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", balanceAfter.toString(), tokenName)
|
||||
expect(balanceAfter.toNumber()).to.be.eq(0);
|
||||
expect(balanceAfter, `PoolTogether Dai Ticket to equal 0`).to.be.eq(0);
|
||||
|
||||
// Expect Pool Token Balance to greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `POOL Token Balance to greater than 0`).to.be.gt(ethers.utils.parseEther("0"));
|
||||
|
||||
});
|
||||
|
||||
|
@ -286,7 +256,7 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositTo",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, constants.address_zero, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, constants.address_zero, 0, 0]
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -294,33 +264,27 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawInstantlyFrom",
|
||||
args: [prizePool, dsaWallet0.address, amount, controlledToken, amount, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, dsaWallet0.address, amount, PT_DAI_TICKET_ADDR, amount, 0, 0]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "claimAll",
|
||||
args: [tokenFaucetProxyFactory, dsaWallet0.address, [daiPoolFaucet]]
|
||||
args: [TOKEN_FAUCET_PROXY_FACTORY_ADDR, dsaWallet0.address, [DAI_POOL_FAUCET_ADDR]]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI balance less than 100`).to.be.lt(ethers.utils.parseEther("100"));
|
||||
|
||||
// PT Dai Ticket is 0
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, controlledToken)
|
||||
let cToken = await ethers.getContractAt(abis.basic.erc20, PT_DAI_TICKET_ADDR)
|
||||
const balance = await cToken.balanceOf(dsaWallet0.address)
|
||||
const tokenName = await cToken.name()
|
||||
console.log("\tBalance before: ", balance.toString(), tokenName)
|
||||
expect(balance, `PoolTogether DAI Ticket equal 0`).to.be.eq(0);
|
||||
|
||||
// PoolToken is 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token is greater than 0`).to.be.gt(ethers.utils.parseEther("0"));
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(depositSpells), wallet1.address)
|
||||
|
@ -334,74 +298,55 @@ describe("PoolTogether", function () {
|
|||
const receipt2 = await tx2.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be 99
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.eq(ethers.utils.parseEther("99"));
|
||||
expect(daiBalance, `DAI balance equals 99`).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// Expect PT Dai Ticket to equal 0
|
||||
const balanceAfter = await cToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", balanceAfter.toString(), tokenName)
|
||||
expect(balanceAfter.toNumber()).to.be.eq(0);
|
||||
expect(balanceAfter, `PoolTogether DAI Ticket equal 0`).to.be.eq(0);
|
||||
|
||||
// Expect Pool Token Balance to be greateir than 0
|
||||
// Expect
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `Pool Token to be greateir than 0`).to.be.gt(ethers.utils.parseEther("0"));
|
||||
});
|
||||
})
|
||||
|
||||
describe("Main - DAI Pod Test", function() {
|
||||
it("Should deposit in Pod", async function() {
|
||||
it("Should deposit 99 DAI in DAI Pod", async function() {
|
||||
const amount = ethers.utils.parseEther("99") // 99 DAI
|
||||
const spells = [
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositToPod",
|
||||
args: [prizePool, daiPod, dsaWallet0.address, amount, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, dsaWallet0.address, amount, 0, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 99
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI balance equals 99`).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// PoolToken is 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// PodToken is 0
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, daiPod)
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, DAI_POD_ADDR)
|
||||
const podBalance = await podToken.balanceOf(dsaWallet0.address)
|
||||
const podTokenName = await podToken.name()
|
||||
console.log("\tBalance before: ", podBalance.toString(), podTokenName)
|
||||
expect(podBalance, `Pod DAI Token equals 0`).to.be.eq(0);
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address)
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be less than 100, because of early withdrawal fee
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.lt(ethers.utils.parseEther("100"));
|
||||
expect(daiBalance, `DAI equals 0`).to.be.eq(0);
|
||||
|
||||
// Expect Pool Token Balance to greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `POOL Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// Expect Pod Token Balance to greater than 0
|
||||
const podBalanceAfter = await podToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", podBalanceAfter.toString(), podTokenName)
|
||||
expect(podBalanceAfter).to.be.eq(ethers.utils.parseEther("99"));
|
||||
expect(podBalanceAfter, `Pod DAI token greater than 0`).to.be.eq(ethers.utils.parseEther("99"));
|
||||
});
|
||||
|
||||
it("Should wait 11 days, withdraw all podTokens, get back 99 DAI", async function () {
|
||||
|
@ -411,28 +356,22 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawFromPod",
|
||||
args: [daiPod, amount, maxFee, 0, 0]
|
||||
args: [DAI_POD_ADDR, amount, maxFee, 0, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI Balance equals 0`).to.be.eq(0);
|
||||
|
||||
// PoolToken is 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token balance greater than 0`).to.be.gt(0);
|
||||
|
||||
// PodToken is 99
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, daiPod)
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, DAI_POD_ADDR)
|
||||
const podBalance = await podToken.balanceOf(dsaWallet0.address)
|
||||
const podTokenName = await podToken.name()
|
||||
console.log("\tBalance before: ", podBalance.toString(), podTokenName)
|
||||
expect(podBalance, `Pod DAI Token equals 99`).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// Increase time by 11 days so we get back all DAI without early withdrawal fee
|
||||
await ethers.provider.send("evm_increaseTime", [11*24*60*60]);
|
||||
|
@ -442,21 +381,16 @@ describe("PoolTogether", function () {
|
|||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be equal to 99, because of no early withdrawal fee
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.eq(ethers.utils.parseEther("99"));
|
||||
expect(daiBalance,
|
||||
`DAI balance equals 99, because of no early withdrawal fee`
|
||||
).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// Expect Pool Token Balance to be greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `POOL Token to be greater than 0`).to.be.gt(0);
|
||||
|
||||
// Expect Pod Token Balance to equal 0
|
||||
const podBalanceAfter = await podToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", podBalanceAfter.toString(), podTokenName)
|
||||
expect(podBalanceAfter).to.be.eq(ethers.utils.parseEther("0"));
|
||||
expect(podBalanceAfter, `Pod DAI Token equals 0`).to.be.eq(0);
|
||||
});
|
||||
|
||||
it("Should deposit and withdraw from pod, get back same amount of 99 DAI", async function() {
|
||||
|
@ -467,54 +401,45 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositToPod",
|
||||
args: [prizePool, daiPod, dsaWallet0.address, amount, 0, 0]
|
||||
args: [DAI_PRIZE_POOL_ADDR, DAI_POD_ADDR, dsaWallet0.address, amount, 0, 0]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawFromPod",
|
||||
args: [daiPod, amount, maxFee, 0, 0]
|
||||
args: [DAI_POD_ADDR, amount, maxFee, 0, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
// DAI balance is 0
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, token)
|
||||
let daiToken = await ethers.getContractAt(abis.basic.erc20, DAI_TOKEN_ADDR)
|
||||
let daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("Before Spell:")
|
||||
console.log("\tBalance before: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance, `DAI equals 99`).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// PoolToken is greater than 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// PodToken is 0
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, daiPod)
|
||||
let podToken = await ethers.getContractAt(abis.basic.erc20, DAI_POD_ADDR)
|
||||
const podBalance = await podToken.balanceOf(dsaWallet0.address)
|
||||
const podTokenName = await podToken.name()
|
||||
console.log("\tBalance before: ", podBalance.toString(), podTokenName)
|
||||
expect(podBalance, `Pod DAI Token equals 0`).to.be.eq(0);
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address)
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// Expect DAI balance to be equal to 99, because funds still in 'float'
|
||||
daiBalance = await daiToken.balanceOf(dsaWallet0.address);
|
||||
console.log("After spell: ");
|
||||
console.log("\tBalance after: ", daiBalance.toString(), tokens.dai.symbol);
|
||||
expect(daiBalance).to.be.eq(ethers.utils.parseEther("99"));
|
||||
expect(daiBalance,
|
||||
`DAI balance to be equal to 99, because funds still in 'float`
|
||||
).to.be.eq(ethers.utils.parseEther("99"));
|
||||
|
||||
// Expect Pool Token Balance to greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolBalanceAfter, `POOL Token same as before spell`).to.be.eq(poolBalance);
|
||||
|
||||
// Expect Pod Token Balance to equal 0
|
||||
const podBalanceAfter = await podToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", podBalanceAfter.toString(), podTokenName)
|
||||
expect(podBalanceAfter).to.be.eq(ethers.utils.parseEther("0"));
|
||||
expect(podBalanceAfter, `Pod DAI Token equals 0`).to.be.eq(ethers.utils.parseEther("0"));
|
||||
});
|
||||
})
|
||||
|
||||
|
@ -528,82 +453,65 @@ describe("PoolTogether", function () {
|
|||
"function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)"
|
||||
];
|
||||
|
||||
// Get amount of ETH for 100 POOL from Uniswap
|
||||
const UniswapV2Router02 = await ethers.getContractAt(UniswapV2Router02ABI, "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D");
|
||||
const amounts = await UniswapV2Router02.getAmountsOut(amount, [poolTokenAddress, WETHAddress]);
|
||||
const amounts = await UniswapV2Router02.getAmountsOut(amount, [POOL_TOKEN_ADDRESS, WETH_ADDR]);
|
||||
const unitAmount = ethers.utils.parseEther(((amounts[1]*1.03)/amounts[0]).toString());
|
||||
|
||||
const spells = [
|
||||
{
|
||||
connector: uniswapConnectorName,
|
||||
method: "buy",
|
||||
args: [poolTokenAddress, tokens.eth.address, amount, unitAmount, 0, setId]
|
||||
args: [POOL_TOKEN_ADDRESS, tokens.eth.address, amount, unitAmount, 0, setId]
|
||||
},
|
||||
{
|
||||
connector: uniswapConnectorName,
|
||||
method: "deposit",
|
||||
args: [poolTokenAddress, tokens.eth.address, amount, unitAmount, slippage, 0, setId]
|
||||
args: [POOL_TOKEN_ADDRESS, tokens.eth.address, amount, unitAmount, slippage, 0, setId]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositTo",
|
||||
args: [uniswapPoolETHLPPrizePool, dsaWallet0.address, 0, ptUniswapPOOLETHLPTicket, constants.address_zero, setId, 0]
|
||||
args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, dsaWallet0.address, 0, PT_UNISWAP_POOLETHLP_TICKET_ADDR, constants.address_zero, setId, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before Spell
|
||||
// ETH balance
|
||||
let ethBalance = await ethers.provider.getBalance(dsaWallet0.address);
|
||||
console.log("Before spell:");
|
||||
console.log("\tBalance before: ", ethBalance.toString(), "ETH");
|
||||
expect(ethBalance, `ETH Balance equals 9`).to.be.eq(ethers.utils.parseEther("9"));
|
||||
|
||||
// PoolToken > 0
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// Uniswap POOL/ETH LP is 0
|
||||
let uniswapLPToken = await ethers.getContractAt(abis.basic.erc20, uniswapPOOLETHLPToken)
|
||||
let uniswapLPToken = await ethers.getContractAt(abis.basic.erc20, UNISWAP_POOLETHLP_TOKEN_ADDR)
|
||||
const uniswapPoolEthBalance = await uniswapLPToken.balanceOf(dsaWallet0.address)
|
||||
const uniswapPoolEthLPTokenName = await uniswapLPToken.name()
|
||||
console.log("\tBalance before: ", uniswapPoolEthBalance.toString(), uniswapPoolEthLPTokenName)
|
||||
expect(uniswapPoolEthBalance, `Uniswap POOL/ETH LP equals 0`).to.be.eq(0);
|
||||
|
||||
// Expect PT Uniswap POOL/ETH LP is 0
|
||||
let ptUniswapPoolEthToken = await ethers.getContractAt(abis.basic.erc20, ptUniswapPOOLETHLPTicket)
|
||||
let ptUniswapPoolEthToken = await ethers.getContractAt(abis.basic.erc20, PT_UNISWAP_POOLETHLP_TICKET_ADDR)
|
||||
const ptUniswapPoolEthBalance = await ptUniswapPoolEthToken.balanceOf(dsaWallet0.address)
|
||||
const ptUniswapPoolEthLPTokenName = await ptUniswapPoolEthToken.name()
|
||||
console.log("\tBalance before: ", ptUniswapPoolEthBalance.toString(), ptUniswapPoolEthLPTokenName)
|
||||
expect(ptUniswapPoolEthBalance, `PoolTogether Uniswap POOL?ETH LP equals 0`).to.be.eq(0);
|
||||
|
||||
// Run spell transaction
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address)
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
// ETH balance < 0
|
||||
ethBalance = await ethers.provider.getBalance(dsaWallet0.address);
|
||||
console.log("After spell:");
|
||||
console.log("\tBalance after: ", ethBalance.toString(), "ETH");
|
||||
expect(ethBalance, `ETH Balance less than 9`).to.be.lt(ethers.utils.parseEther("9"));
|
||||
|
||||
// Expect Pool Token Balance to greater than 0
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.eq(poolBalance);
|
||||
expect(poolBalanceAfter, `POOL Token to be same after spell`).to.be.eq(poolBalance);
|
||||
|
||||
// Expect Uniswap POOL/ETH LP to greater than 0
|
||||
const uniswapPoolEthBalanceAfter = await uniswapLPToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", uniswapPoolEthBalanceAfter.toString(), uniswapPoolEthLPTokenName)
|
||||
expect(uniswapPoolEthBalanceAfter).to.be.eq(ethers.utils.parseEther("0"));
|
||||
expect(uniswapPoolEthBalanceAfter, `Uniswap POOL/ETH LP equals 0`).to.be.eq(0);
|
||||
|
||||
// Expect PT Uniswap POOL/ETH LP to greater than 0
|
||||
const ptUniswapPoolEthBalanceAfter = await ptUniswapPoolEthToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", ptUniswapPoolEthBalanceAfter.toString(), ptUniswapPoolEthLPTokenName)
|
||||
expect(ptUniswapPoolEthBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9"));
|
||||
expect(ptUniswapPoolEthBalanceAfter, `PT Uniswap POOL/ETH LP to greater than 0`).to.be.gt(0);
|
||||
});
|
||||
|
||||
it("Should wait 11 days, withdraw all PrizePool, get back Uniswap LP, claim POOL, deposit claimed POOL into Pool PrizePool", async function () {
|
||||
let ptUniswapPoolEthToken = await ethers.getContractAt(abis.basic.erc20, ptUniswapPOOLETHLPTicket)
|
||||
let ptUniswapPoolEthToken = await ethers.getContractAt(abis.basic.erc20, PT_UNISWAP_POOLETHLP_TICKET_ADDR)
|
||||
const ptUniswapPoolEthBalance = await ptUniswapPoolEthToken.balanceOf(dsaWallet0.address)
|
||||
const setId = "83478237"
|
||||
|
||||
|
@ -611,43 +519,35 @@ describe("PoolTogether", function () {
|
|||
{
|
||||
connector: ptConnectorName,
|
||||
method: "withdrawInstantlyFrom",
|
||||
args: [uniswapPoolETHLPPrizePool, dsaWallet0.address, ptUniswapPoolEthBalance, ptUniswapPOOLETHLPTicket, 0, 0, 0]
|
||||
args: [UNISWAP_POOLETHLP_PRIZE_POOL_ADDR, dsaWallet0.address, ptUniswapPoolEthBalance, PT_UNISWAP_POOLETHLP_TICKET_ADDR, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "claim",
|
||||
args: [uniswapPoolETHLPFaucet , dsaWallet0.address, setId]
|
||||
args: [UNISWAP_POOLETHLP_FAUCET_ADDR , dsaWallet0.address, setId]
|
||||
},
|
||||
{
|
||||
connector: ptConnectorName,
|
||||
method: "depositTo",
|
||||
args: [poolPoolPrizePool, dsaWallet0.address, 0, ptPoolTicket, constants.address_zero, setId, 0]
|
||||
args: [POOL_PRIZE_POOL_ADDR, dsaWallet0.address, 0, PT_POOL_TICKET_ADDR, constants.address_zero, setId, 0]
|
||||
}
|
||||
]
|
||||
|
||||
// Before spell
|
||||
console.log("Before spell:");
|
||||
// PoolToken
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, poolTokenAddress)
|
||||
let poolToken = await ethers.getContractAt(abis.basic.erc20, POOL_TOKEN_ADDRESS)
|
||||
const poolBalance = await poolToken.balanceOf(dsaWallet0.address)
|
||||
const poolTokenName = await poolToken.name()
|
||||
console.log("\tBalance before: ", poolBalance.toString(), poolTokenName)
|
||||
expect(poolBalance, `POOL Token greater than 0`).to.be.gt(0);
|
||||
|
||||
// Uniswap POOL/ETH LP is 0
|
||||
let uniswapLPToken = await ethers.getContractAt(abis.basic.erc20, uniswapPOOLETHLPToken)
|
||||
let uniswapLPToken = await ethers.getContractAt(abis.basic.erc20, UNISWAP_POOLETHLP_TOKEN_ADDR)
|
||||
const uniswapPoolEthBalance = await uniswapLPToken.balanceOf(dsaWallet0.address)
|
||||
const uniswapPoolEthLPTokenName = await uniswapLPToken.name()
|
||||
console.log("\tBalance before: ", uniswapPoolEthBalance.toString(), uniswapPoolEthLPTokenName)
|
||||
expect(uniswapPoolEthBalance, `Uniswap POOL/ETH LP equals 0`).to.be.eq(0);
|
||||
|
||||
// Expect PT Uniswap POOL/ETH LP > 0
|
||||
const ptUniswapPoolEthLPTokenName = await ptUniswapPoolEthToken.name()
|
||||
console.log("\tBalance before: ", ptUniswapPoolEthBalance.toString(), ptUniswapPoolEthLPTokenName)
|
||||
expect(ptUniswapPoolEthBalance, `PT Uniswap POOL/ETH LP greater than 0`).to.be.gt(0);
|
||||
|
||||
// PoolTogether Pool Ticket
|
||||
let poolPoolTicket = await ethers.getContractAt(abis.basic.erc20, ptPoolTicket)
|
||||
let poolPoolTicket = await ethers.getContractAt(abis.basic.erc20, PT_POOL_TICKET_ADDR)
|
||||
const poolPoolTicketBalance = await poolPoolTicket.balanceOf(dsaWallet0.address)
|
||||
const poolPoolTicketName = await poolPoolTicket.name()
|
||||
console.log("\tBalance before: ", poolPoolTicketBalance.toString(), poolPoolTicketName)
|
||||
expect(poolPoolTicketBalance, `PoolTogether POOL Ticket equals 0`).to.be.eq(0);
|
||||
|
||||
// Increase time by 11 days so we get back all DAI without early withdrawal fee
|
||||
await ethers.provider.send("evm_increaseTime", [11*24*60*60]);
|
||||
|
@ -657,26 +557,17 @@ describe("PoolTogether", function () {
|
|||
const receipt = await tx.wait()
|
||||
|
||||
// After spell
|
||||
console.log("After spell:");
|
||||
// Expect Pool Token Balance to be greater than balance before spell
|
||||
const poolBalanceAfter = await poolToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolBalanceAfter.toString(), poolTokenName)
|
||||
expect(poolBalanceAfter).to.be.eq(poolBalance);
|
||||
expect(poolBalanceAfter, `Pool Token Balance equal to balance before spell`).to.be.eq(poolBalance);
|
||||
|
||||
// Expect Uniswap POOL/ETH LP to greater than 0
|
||||
const uniswapPoolEthBalanceAfter = await uniswapLPToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", uniswapPoolEthBalanceAfter.toString(), uniswapPoolEthLPTokenName)
|
||||
expect(uniswapPoolEthBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(uniswapPoolEthBalanceAfter, `Uniswap POOL/ETH LP to greater than 0`).to.be.gt(0);
|
||||
|
||||
// Expect PT Uniswap POOL/ETH LP equal 0
|
||||
const ptUniswapPoolEthBalanceAfter = await ptUniswapPoolEthToken.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", ptUniswapPoolEthBalanceAfter.toString(), ptUniswapPoolEthLPTokenName)
|
||||
expect(ptUniswapPoolEthBalanceAfter).to.be.eq(ethers.utils.parseEther("0"));
|
||||
expect(ptUniswapPoolEthBalanceAfter, `PT Uniswap POOL/ETH LP equal 0`).to.be.eq(0);
|
||||
|
||||
// Expoect PoolTogether Pool Ticket > 0
|
||||
const poolPoolTicketBalanceAfter = await poolPoolTicket.balanceOf(dsaWallet0.address)
|
||||
console.log("\tBalance after: ", poolPoolTicketBalanceAfter.toString(), poolPoolTicketName)
|
||||
expect(poolPoolTicketBalanceAfter).to.be.gt(ethers.utils.parseEther("0"));
|
||||
expect(poolPoolTicketBalanceAfter, `PoolTogether POOL Ticket greater than 0`).to.be.gt(0);
|
||||
});
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user