Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
583 changes: 428 additions & 155 deletions .gas-snapshot

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "lib/yield-utils-v2"]
path = lib/yield-utils-v2
url = https://github.com/yieldprotocol/yield-utils-v2
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.2.0
[submodule "lib/yield-utils-v2"]
path = lib/yield-utils-v2
url = https://github.com/yieldprotocol/yield-utils-v2
10 changes: 5 additions & 5 deletions src/Pool/Modules/PoolEuler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract PoolEuler is Pool {
if (baseOut == 0) return 0;

IEToken(address(sharesToken)).deposit(0, baseOut); // first param is subaccount, 0 for primary
shares = _getSharesBalance() - sharesCached; // this includes any shares in pool previously
shares = _getSharesBalance() - sharesReserves; // this includes any shares in pool previously
if (receiver != address(this)) {
sharesToken.safeTransfer(receiver, shares);
}
Expand All @@ -97,7 +97,7 @@ contract PoolEuler is Pool {
/// @param receiver The address the wrapped tokens should be sent.
/// @return assets The amount of assets sent to the receiver in native decimals.
function _unwrap(address receiver) internal virtual override returns (uint256 assets) {
uint256 surplus = _getSharesBalance() - sharesCached;
uint256 surplus = _getSharesBalance() - sharesReserves;
if (surplus == 0) return 0;
// convert to base
assets = _unwrapPreview(surplus);
Expand Down Expand Up @@ -126,9 +126,9 @@ contract PoolEuler is Pool {
/// @param to Address of the recipient of the shares tokens.
/// @return retrieved The amount of shares tokens sent (in eToken decimals -- 18).
function retrieveShares(address to) external virtual override returns (uint128 retrieved) {
// sharesCached is stored by Yield with the same decimals as the underlying base, but actually the Euler
// eTokens are always fp18. So we scale up the sharesCached and subtract from real eToken balance.
retrieved = (sharesToken.balanceOf(address(this)) - (sharesCached * scaleFactor)).u128();
// sharesReserves is stored by Yield with the same decimals as the underlying base, but actually the Euler
// eTokens are always fp18. So we scale up the sharesReserves and subtract from real eToken balance.
retrieved = (sharesToken.balanceOf(address(this)) - (sharesReserves * scaleFactor)).u128();
sharesToken.safeTransfer(to, retrieved);
// Now the current balances match the cache, so no need to update the TWAR
}
Expand Down
8 changes: 4 additions & 4 deletions src/Pool/Modules/PoolNonTv.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ contract PoolNonTv is Pool {
/// @return retrieved The amount of shares/base tokens sent.
function _retrieveBase(address to) internal virtual returns (uint128 retrieved) {
// For PoolNonTv, sharesToken == baseToken. This allows for the use of the core Pool.sol contract logic with
// non-yield-bearing tokens. As such the sharesCached state var actually represents baseTokens, since they
// non-yield-bearing tokens. As such the sharesReserves state var actually represents baseTokens, since they
// are the same.
retrieved = (sharesToken.balanceOf(address(this)) - sharesCached).u128();
retrieved = (sharesToken.balanceOf(address(this)) - sharesReserves).u128();
sharesToken.safeTransfer(to, retrieved);
}

Expand All @@ -92,7 +92,7 @@ contract PoolNonTv is Pool {
/// Since there is nothing to unwrap, we return the surplus balance.
/// @return shares The amount of wrapped tokens that are sent to the receiver.
function _wrap(address receiver) internal virtual override returns (uint256 shares) {
shares = _getSharesBalance() - sharesCached;
shares = _getSharesBalance() - sharesReserves;
if (receiver != address(this)) {
sharesToken.safeTransfer(receiver, shares);
}
Expand All @@ -109,7 +109,7 @@ contract PoolNonTv is Pool {
/// Since there is nothing to unwrap, we return the surplus balance.
/// @return assets The amount of base assets sent to the receiver.
function _unwrap(address receiver) internal virtual override returns (uint256 assets) {
assets = _getSharesBalance() - sharesCached;
assets = _getSharesBalance() - sharesReserves;
if (receiver != address(this)) {
sharesToken.safeTransfer(receiver, assets);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pool/Modules/PoolYearnVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract PoolYearnVault is Pool {
/// @param receiver The address the wrapped tokens should be sent.
/// @return base_ The amount of base base sent to the receiver.
function _unwrap(address receiver) internal virtual override returns (uint256 base_) {
uint256 surplus = _getSharesBalance() - sharesCached;
uint256 surplus = _getSharesBalance() - sharesReserves;
if (surplus == 0) return 0;
base_ = IYVToken(address(sharesToken)).withdraw(surplus, receiver);
}
Expand Down
Loading