-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evaluate whether a constant vault share price is an appropriate invar…
…iant - Removed rebalancing from sandwich tests since the situation is supposed to be atomic - Keeping share price constant has the exact same effect as not distributing losses. - This results in bad UX + a DOS vector for small position sizes. - In the case of bonds devaluing via huge LP, this loss should affect others. - No need to handle the case where a redemption would be zero, with distributed losses this isn't possible. - Vault share price decreases on deposit, remains constant on redemption (for base atomic case).
- Loading branch information
Showing
7 changed files
with
118 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.22; | ||
|
||
import { console2 as console } from "forge-std/console2.sol"; | ||
import { FixedPointMath } from "hyperdrive/contracts/src/libraries/FixedPointMath.sol"; | ||
import { Lib } from "hyperdrive/test/utils/Lib.sol"; | ||
import { HyperdriveUtils } from "hyperdrive/test/utils/HyperdriveUtils.sol"; | ||
import { IERC20 } from "openzeppelin/interfaces/IERC20.sol"; | ||
import { EverlongTest } from "../harnesses/EverlongTest.sol"; | ||
import { IEverlong } from "../../contracts/interfaces/IEverlong.sol"; | ||
import { HyperdriveExecutionLibrary } from "../../contracts/libraries/HyperdriveExecution.sol"; | ||
|
||
contract TestVaultSharePrice is EverlongTest { | ||
using FixedPointMath for uint256; | ||
using Lib for *; | ||
using HyperdriveUtils for *; | ||
using HyperdriveExecutionLibrary for *; | ||
|
||
function test_vault_share_price_deposit_redeem() external { | ||
// Skip this test unless disabled manually. | ||
vm.skip(true); | ||
|
||
deployEverlong(); | ||
|
||
// Alice makes a deposit. | ||
uint256 aliceDeposit = 10_000e18; | ||
uint256 aliceShares = depositEverlong(aliceDeposit, alice); | ||
|
||
console.log( | ||
"Vault Share Price 1: %e", | ||
everlong.totalAssets().divDown(everlong.totalSupply()) | ||
); | ||
|
||
// Bob makes a deposit. | ||
uint256 bobDeposit = 10_000e18; | ||
uint256 bobShares = depositEverlong(bobDeposit, bob); | ||
console.log( | ||
"Vault Share Price 2: %e", | ||
everlong.totalAssets().divDown(everlong.totalSupply()) | ||
); | ||
|
||
// Celine makes a deposit. | ||
uint256 celineDeposit = 10_000e18; | ||
uint256 celineShares = depositEverlong(celineDeposit, celine); | ||
console.log( | ||
"Vault Share Price 3: %e", | ||
everlong.totalAssets().divDown(everlong.totalSupply()) | ||
); | ||
|
||
// Bob redeems. | ||
redeemEverlong(bobShares, bob); | ||
console.log( | ||
"Vault Share Price 4: %e", | ||
everlong.totalAssets().divDown(everlong.totalSupply()) | ||
); | ||
|
||
// Celine redeems. | ||
redeemEverlong(celineShares, celine); | ||
console.log( | ||
"Vault Share Price 5: %e", | ||
everlong.totalAssets().divDown(everlong.totalSupply()) | ||
); | ||
|
||
console.log( | ||
"Everlong Balance: %e", | ||
IERC20(everlong.asset()).balanceOf(address(everlong)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters