|
|
|
@ -66,6 +66,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: parseShare(1), |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: parseToken(1), |
|
|
|
|
shares: parseShare(1), |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('mint', async function () { |
|
|
|
@ -85,6 +92,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: parseShare(1), |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: parseToken(1), |
|
|
|
|
shares: parseShare(1), |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('withdraw', async function () { |
|
|
|
@ -104,6 +118,14 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: '0', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: '0', |
|
|
|
|
shares: '0', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('redeem', async function () { |
|
|
|
@ -123,6 +145,14 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: '0', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: '0', |
|
|
|
|
shares: '0', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -171,6 +201,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: expectedShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: depositAssets, |
|
|
|
|
shares: expectedShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -207,6 +244,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: mintShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: expectedAssets, |
|
|
|
|
shares: mintShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('withdraw', async function () { |
|
|
|
@ -226,6 +270,14 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: '0', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: '0', |
|
|
|
|
shares: '0', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('redeem', async function () { |
|
|
|
@ -245,6 +297,14 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: '0', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: '0', |
|
|
|
|
shares: '0', |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -292,6 +352,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: expectedShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: depositAssets, |
|
|
|
|
shares: expectedShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -326,6 +393,13 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: recipient, |
|
|
|
|
value: mintShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Deposit', { |
|
|
|
|
sender: holder, |
|
|
|
|
owner: recipient, |
|
|
|
|
assets: expectedAssets, |
|
|
|
|
shares: mintShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('withdraw', async function () { |
|
|
|
@ -351,6 +425,14 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: expectedShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: withdrawAssets, |
|
|
|
|
shares: expectedShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('withdraw with approval', async function () { |
|
|
|
@ -363,21 +445,35 @@ contract('ERC4626', function (accounts) { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('redeem', async function () { |
|
|
|
|
expect(await this.vault.maxRedeem(holder)).to.be.bignumber.equal(parseShare(100)); |
|
|
|
|
expect(await this.vault.previewRedeem(parseShare(100))).to.be.bignumber.equal(parseToken(1)); |
|
|
|
|
const effectiveAssets = await this.vault.totalAssets().then(x => x.add(virtualAssets)); |
|
|
|
|
const effectiveShares = await this.vault.totalSupply().then(x => x.add(virtualShares)); |
|
|
|
|
|
|
|
|
|
const redeemShares = parseShare(100); |
|
|
|
|
const expectedAssets = redeemShares.mul(effectiveAssets).div(effectiveShares); |
|
|
|
|
|
|
|
|
|
const { tx } = await this.vault.redeem(parseShare(100), recipient, holder, { from: holder }); |
|
|
|
|
expect(await this.vault.maxRedeem(holder)).to.be.bignumber.equal(redeemShares); |
|
|
|
|
expect(await this.vault.previewRedeem(redeemShares)).to.be.bignumber.equal(expectedAssets); |
|
|
|
|
|
|
|
|
|
const { tx } = await this.vault.redeem(redeemShares, recipient, holder, { from: holder }); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.token, 'Transfer', { |
|
|
|
|
from: this.vault.address, |
|
|
|
|
to: recipient, |
|
|
|
|
value: parseToken(1), |
|
|
|
|
value: expectedAssets, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Transfer', { |
|
|
|
|
from: holder, |
|
|
|
|
to: constants.ZERO_ADDRESS, |
|
|
|
|
value: parseShare(100), |
|
|
|
|
value: redeemShares, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
await expectEvent.inTransaction(tx, this.vault, 'Withdraw', { |
|
|
|
|
sender: holder, |
|
|
|
|
receiver: recipient, |
|
|
|
|
owner: holder, |
|
|
|
|
assets: expectedAssets, |
|
|
|
|
shares: redeemShares, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|