|
9 | 9 | tusdUnits, |
10 | 10 | getOracleAddress, |
11 | 11 | setOracleTokenPriceUsd, |
| 12 | + expectApproxSupply, |
12 | 13 | loadFixture, |
13 | 14 | } = require("../helpers"); |
14 | 15 |
|
@@ -174,7 +175,7 @@ describe("Vault rebasing", async () => { |
174 | 175 | await expect(await vault.getStrategyCount()).to.equal(0); |
175 | 176 | await vault.connect(governor).allocate(); |
176 | 177 |
|
177 | | - // All assets sould still remain in Vault |
| 178 | + // All assets should still remain in Vault |
178 | 179 |
|
179 | 180 | // Note defaultFixture sets up with 200 DAI already in the Strategy |
180 | 181 | // 200 + 100 = 300 |
@@ -217,3 +218,37 @@ describe("Vault rebasing", async () => { |
217 | 218 | await expect(await vault.priceProvider()).to.be.equal(oracle); |
218 | 219 | }); |
219 | 220 | }); |
| 221 | + |
| 222 | +describe("Vault yield accrual to OGN", async () => { |
| 223 | + [ |
| 224 | + { yield: "1000", basis: 100, expectedFee: "10" }, |
| 225 | + { yield: "1000", basis: 5000, expectedFee: "500" }, |
| 226 | + { yield: "1523", basis: 900, expectedFee: "137.07" }, |
| 227 | + { yield: "0.000001", basis: 10, expectedFee: "0.00000001" }, |
| 228 | + { yield: "0", basis: 1000, expectedFee: "0" }, |
| 229 | + ].forEach((options) => { |
| 230 | + const { yield, basis, expectedFee } = options; |
| 231 | + it(`should collect on rebase a ${expectedFee} fee from ${yield} yield at ${basis}bp `, async function () { |
| 232 | + const fixture = await loadFixture(defaultFixture); |
| 233 | + const { matt, governor, ousd, usdt, vault, mockNonRebasing } = fixture; |
| 234 | + const trustee = mockNonRebasing; |
| 235 | + |
| 236 | + // Setup trustee trustee on vault |
| 237 | + await vault.connect(governor).setTrusteeAddress(trustee.address); |
| 238 | + await vault.connect(governor).setTrusteeFeeBps(900); |
| 239 | + await expect(trustee).has.a.balanceOf("0", ousd); |
| 240 | + |
| 241 | + // Create yield for the vault |
| 242 | + await usdt.connect(matt).mint(usdcUnits("1523")); |
| 243 | + await usdt.connect(matt).transfer(vault.address, usdcUnits("1523")); |
| 244 | + // Do rebase |
| 245 | + const supplyBefore = await ousd.totalSupply(); |
| 246 | + await vault.rebase(); |
| 247 | + // OUSD supply increases correctly |
| 248 | + await expectApproxSupply(ousd, supplyBefore.add(ousdUnits("1523"))); |
| 249 | + // ogntrustee address increases correctly |
| 250 | + // 1523 * 0.09 = 137.07 |
| 251 | + await expect(trustee).has.a.balanceOf("137.07", ousd); |
| 252 | + }); |
| 253 | + }); |
| 254 | +}); |
0 commit comments