Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update runlogs #2028

Merged
merged 4 commits into from
Apr 24, 2024
Merged
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
105 changes: 104 additions & 1 deletion brownie/runlogs/2024_04_strategist.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,107 @@ def main():
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("-----")
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))
2 changes: 1 addition & 1 deletion contracts/slither.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"filter_paths": "mocks|echidna|crytic|OUSDResolutionUpgrade.sol|MixOracle.sol|VaultInitializer.sol|StableMath.sol|openzeppelin|@openzeppelin",
"exclude_low": true,
"exclude_informational": true,
"detectors_to_exclude": "conformance-to-solidity-naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality"
"detectors_to_exclude": "conformance-to-solidity-naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality,unused-return"
}
33 changes: 31 additions & 2 deletions contracts/test/_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,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 @@ -697,6 +697,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
Loading