Skip to content

Commit

Permalink
Merge branch 'master' into PraneshASP/woeth-zapper
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVF authored Apr 24, 2024
2 parents 582550b + 682e38c commit df980bd
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 215 deletions.
152 changes: 152 additions & 0 deletions brownie/runlogs/2024_04_strategist.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,155 @@ def main():
print("OETH supply change", "{:.6f}".format(supply_change / 10**18), supply_change)
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
print("-----")

# -------------------------------------
# Apr 23, 2024 - FraxETH Redeem
# -------------------------------------
from world import *

def main():
with TemporaryForkForReallocations() as txs:
# Before
txs.append(vault_oeth_core.rebase(std))
txs.append(oeth_vault_value_checker.takeSnapshot(std))

outstanding_redeems = frxeth_redeem_strat.outstandingRedeems();

print("Outstanding redeems before:", outstanding_redeems)

txs.append(
frxeth_redeem_strat.redeemTickets(
[
350, 351, 352, 353, 354, 355, 356, 357, 358,
359, 360, 361, 362, 363, 364, 365, 366
],
outstanding_redeems,
std
)
)

print("Outstanding redeems after:", frxeth_redeem_strat.outstandingRedeems())

# Deposit WETH to Morpho Aave
txs.append(
vault_oeth_admin.depositToStrategy(
OETH_MORPHO_AAVE_STRAT,
[WETH],
[outstanding_redeems],
std
)
)

# After
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
profit = vault_change - supply_change
txs.append(oeth_vault_value_checker.checkDelta(profit, (1 * 10**18), vault_change, (1 * 10**18), std))
print("-----")
print("Profit", "{:.6f}".format(profit / 10**18), profit)
print("OETH supply change", "{:.6f}".format(supply_change / 10**18), supply_change)
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
print("-----")

# -------------------------------------
# Apr 24, 2024 - OETH Buyback
# -------------------------------------
from buyback import *
def main():
txs = []

oeth_for_ogv, oeth_for_cvx = get_balance_splits(OETH)

with TemporaryFork():
txs.append(
build_1inch_buyback_tx(
OETH,
OGV,
oeth_for_ogv,
3
)
)

txs.append(
build_1inch_buyback_tx(
OETH,
CVX,
oeth_for_cvx,
2
)
)

txs.append(
cvx_locker.processExpiredLocks(True, std)
)

print(to_gnosis_json(txs))

# -------------------------------------
# Apr 24, 2024 - Get some stETH
# -------------------------------------
from collateralSwap import *

def main():
with TemporaryForkForReallocations() as txs:
# Before
txs.append(vault_oeth_core.rebase(std))
txs.append(oeth_vault_value_checker.takeSnapshot(std))

# Withdraw 4607 WETH from Morpho Aave
txs.append(
vault_oeth_admin.withdrawFromStrategy(
OETH_MORPHO_AAVE_STRAT,
[WETH],
[4607 * 10**18],
std
)
)

# Swap to stETH
_, swap_data = build_swap_tx(WETH, STETH, 4600 * 10**18, 0.2, False)
decoded_input = oeth_vault_core.swapCollateral.decode_input(swap_data)
txs.append(
oeth_vault_core.swapCollateral(*decoded_input, std)
)

# After
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
profit = vault_change - supply_change
txs.append(oeth_vault_value_checker.checkDelta(profit, (1 * 10**18), vault_change, (1 * 10**18), std))
print("-----")
print("Profit", "{:.6f}".format(profit / 10**18), profit)
print("OETH supply change", "{:.6f}".format(supply_change / 10**18), supply_change)
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
print("-----")

# -------------------------------------
# Apr 24, 2024 - OUSD Buyback
# -------------------------------------
from buyback import *
def main():
txs = []

ousd_for_ogv, ousd_for_cvx = get_balance_splits(OUSD)

with TemporaryFork():
txs.append(
build_1inch_buyback_tx(
OUSD,
OGV,
ousd_for_ogv,
3
)
)

txs.append(
build_1inch_buyback_tx(
OUSD,
CVX,
ousd_for_cvx,
2
)
)

print(to_gnosis_json(txs))
33 changes: 31 additions & 2 deletions contracts/test/_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ async function oethDefaultFixture() {
async function oethCollateralSwapFixture() {
const fixture = await oethDefaultFixture();

// const { timelock, oethVault } = fixture;
const { weth, matt, strategist, timelock, oethVault } = fixture;
const { weth, matt, strategist, domen, frxETH, timelock, oethVault } =
fixture;

const bufferBps = await oethVault.vaultBuffer();
const shouldChangeBuffer = bufferBps.lt(oethUnits("1"));
Expand Down Expand Up @@ -698,6 +698,35 @@ async function oethCollateralSwapFixture() {
await oethVault.connect(strategist).setVaultBuffer(bufferBps);
}

const allStrats = await oethVault.getAllStrategies();
if (
allStrats
.map((x) => x.toLowerCase())
.includes(addresses.mainnet.FraxETHStrategy.toLowerCase())
) {
// Remove fraxETH strategy if it exists
// Because it no longer holds assets and causes this test to fail

// Send some dust to that first
await frxETH.connect(domen).transfer(oethVault.address, oethUnits("1"));

// Now make sure it's deposited
await oethVault
.connect(strategist)
.depositToStrategy(
addresses.mainnet.FraxETHStrategy,
[frxETH.address],
[oethUnits("1")]
);

await oethVault
.connect(timelock)
.setAssetDefaultStrategy(frxETH.address, addresses.zero);
await oethVault
.connect(timelock)
.removeStrategy(addresses.mainnet.FraxETHStrategy);
}

// Withdraw all from strategies so we have assets to swap
await oethVault.connect(timelock).withdrawAllFromStrategies();

Expand Down
14 changes: 12 additions & 2 deletions contracts/test/strategies/ousd-maker-dsr.fork-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ describe("ForkTest: Maker DSR Strategy", function () {
fixture = await loadFixture();
});
it("Vault should deposit some DAI to strategy", async function () {
const { dai, ousd, sDAI, makerDsrStrategy, vaultSigner } = fixture;
const {
dai,
ousd,
sDAI,
makerDsrStrategy,
vault,
strategist,
vaultSigner,
} = fixture;

const daiDepositAmount = await units("1000", dai);

Expand All @@ -106,6 +114,8 @@ describe("ForkTest: Maker DSR Strategy", function () {
.connect(vaultSigner)
.transfer(makerDsrStrategy.address, daiDepositAmount);

await vault.connect(strategist).rebase();

const ousdSupplyBefore = await ousd.totalSupply();

log(
Expand All @@ -129,7 +139,7 @@ describe("ForkTest: Maker DSR Strategy", function () {
const ousdSupplyAfter = await ousd.totalSupply();
expect(ousdSupplyAfter).to.approxEqualTolerance(
ousdSupplyBefore.add(daiDepositAmount),
0.01 // 0.01% or 1 basis point
0.1 // 0.1% or 10 basis point
);
});
it("Only vault can deposit some DAI to the strategy", async function () {
Expand Down
Loading

0 comments on commit df980bd

Please sign in to comment.