Skip to content

Commit

Permalink
Merge branch 'master' into clement/base_curve_amo
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-ux committed Feb 7, 2025
2 parents 9ef6591 + ce1363a commit 07b6933
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 7 deletions.
3 changes: 2 additions & 1 deletion brownie/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
BIGWALLET = '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503'

# Governance
STRATEGIST = '0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC'
OLD_STRATEGIST = '0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC'
MULTICHAIN_STRATEGIST = '0x4FF1b9D9ba8558F5EAfCec096318eA0d8b541971'
STRATEGIST = MULTICHAIN_STRATEGIST
GOVERNOR = '0x72426ba137dec62657306b12b1e869d43fec6ec7'
GOV_MULTISIG = '0xbe2AB3d3d8F6a32b96414ebbd865dBD276d3d899'
ORIGINTEAM = '0x449e0b5564e0d141b3bc3829e74ffa0ea8c08ad5'
Expand Down
83 changes: 82 additions & 1 deletion brownie/runlogs/2025_02_strategist.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,85 @@ def main():
extra_data, # extraData
{'value': weth_received, 'from': MULTICHAIN_STRATEGIST}
)
)
)

# -------------------------------------
# Feb 5, 2025 - Remove from wOETH strategy
# -------------------------------------
from aerodrome_harvest import *
from brownie import accounts
import eth_abi
def main():
with TemporaryForkForReallocations() as txs:
strategist = accounts.at(MULTICHAIN_STRATEGIST, force=True)
gas_buffer = 0.03 * 10**18
eth_amount = strategist.balance() - gas_buffer

existing_oethb_amount = 0

# Update oracle price
txs.append(woeth_strat.updateWOETHOraclePrice({ 'from': OETHB_MULTICHAIN_STRATEGIST }))

# Rebase
txs.append(vault_core.rebase({ 'from': OETHB_MULTICHAIN_STRATEGIST }))

# Take Vault snapshot
txs.append(vault_value_checker.takeSnapshot({ 'from': OETHB_MULTICHAIN_STRATEGIST }))

# Mint OETHb with WETH
txs.append(zapper.deposit({'from': MULTICHAIN_STRATEGIST, 'value': eth_amount}))

woeth_amount_before = woeth.balanceOf(OETHB_MULTICHAIN_STRATEGIST)

# # Approve wOETH to wOETH strategy (one-time)
# txs.append(oethb.approve(woeth_strat.address, "115792089237316195423570985008687907853269984665640564039457584007913129639935", { 'from': OETHB_MULTICHAIN_STRATEGIST }))

# Withdraw from wOETH strategy
txs.append(woeth_strat.withdrawBridgedWOETH(eth_amount + existing_oethb_amount, { 'from': OETHB_MULTICHAIN_STRATEGIST }))

woeth_amount = woeth.balanceOf(OETHB_MULTICHAIN_STRATEGIST) - woeth_amount_before

# Check Vault Value against snapshot
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(OETHB_MULTICHAIN_STRATEGIST)[0]
supply_change = oethb.totalSupply() - vault_value_checker.snapshots(OETHB_MULTICHAIN_STRATEGIST)[1]
profit = vault_change - supply_change

txs.append(vault_value_checker.checkDelta(profit, (0.3 * 10**18), vault_change, (1 * 10**18), {'from': OETHB_MULTICHAIN_STRATEGIST}))

print(to_gnosis_json(txs, OETHB_MULTICHAIN_STRATEGIST, "8453"))

print("--------------------")
print("Minted superOETHb ", c18(eth_amount), eth_amount)
print("Redeemed superOETHb ", c18(eth_amount + existing_oethb_amount), eth_amount + existing_oethb_amount)
print("Withdrawn wOETH ", c18(woeth_amount), woeth_amount)
print("--------------------")
print("Profit ", c18(profit), profit)
print("Vault Change ", c18(vault_change), vault_change)
print("--------------------")

# Bridge wOETH to Ethereum using CCIP
txs.append(woeth.approve(BASE_CCIP_ROUTER, woeth_amount, { 'from': OETHB_MULTICHAIN_STRATEGIST }))

eth_chain_selector = 5009297550715157269

ccip_message = [
eth_abi.encode(['address'], [MULTICHAIN_STRATEGIST]),
'0x',
[(BRIDGED_WOETH_BASE, woeth_amount)],
ADDR_ZERO,
'0x97a657c9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
]

ccip_fee = ccip_router.getFee(eth_chain_selector, ccip_message)
print("--------------------")
print("CCIP fee ", c18(ccip_fee), ccip_fee)
ccip_fee = int(ccip_fee * 1.2)
print("Premium ", c18(0), pcts(20))
print("Net fee ", c18(ccip_fee), ccip_fee)
print("--------------------")

txs.append(ccip_router.ccipSend(
eth_chain_selector,
ccip_message,
{'from': OETHB_MULTICHAIN_STRATEGIST, 'value': ccip_fee}
))
13 changes: 13 additions & 0 deletions brownie/world_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ def scale_amount(from_token, to_token, amount, decimals=0):

return int(scale_amount * 10**decimals) / (10**decimals)

def get_tick_liquidity(tick):
liquidityGross = amo_pool.ticks(tick)[0]
wethInTickTotal, oethbInTickTotal = aero_helper.getAmountsForLiquidity(
amo_pool.slot0()[0], #sqrtPriceX96
aero_helper.getSqrtRatioAtTick(tick),
aero_helper.getSqrtRatioAtTick(tick + 1),
liquidityGross
)
print("------------------")
print("WETH ", c18(wethInTickTotal))
print("OETHB ", c18(oethbInTickTotal))
print("------------------")

def amo_snapshot():
wethPoolBalance = weth.balanceOf(AERODROME_WETH_OETHB_POOL_BASE)
superOETHbPoolBalance = oethb.balanceOf(AERODROME_WETH_OETHB_POOL_BASE)
Expand Down
7 changes: 4 additions & 3 deletions contracts/contracts/vault/OETHVaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ contract OETHVaultCore is VaultCore {
}

// Amount excluding fees
uint256 amountMinusFee = _calculateRedeemOutputs(_amount)[
wethAssetIndex
];
// No fee for the strategist or the governor, makes it easier to do operations
uint256 amountMinusFee = (msg.sender == strategistAddr || isGovernor())
? _amount
: _calculateRedeemOutputs(_amount)[wethAssetIndex];

require(
amountMinusFee >= _minimumUnitAmount,
Expand Down
1 change: 1 addition & 0 deletions contracts/contracts/vault/VaultStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ contract VaultStorage is Initializable, Governable {
0xa2bd3d3cf188a41358c8b401076eb59066b09dec5775650c0de4c55187d17bd9;

/// @dev Address of the contract responsible for post rebase syncs with AMMs
// slither-disable-next-line constable-states
address private _deprecated_rebaseHooksAddr = address(0);

/// @dev Deprecated: Address of Uniswap
Expand Down
6 changes: 5 additions & 1 deletion contracts/fork-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ main()

# Run specific files when a param is given
if [[ ! -z "$1" ]]; then
params+="--testfiles $@"
if [[ $is_coverage == "true" ]]; then
params+="--testfiles $@"
else
params+="$@"
fi
fi

# Add trace flag if enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ describe("ForkTest: Aerodrome AMO Strategy (Base)", async function () {
it("Should have the correct initial state", async function () {
// correct pool weth share interval
expect(await aerodromeAmoStrategy.allowedWethShareStart()).to.equal(
oethUnits("0.05")
oethUnits("0.010000001")
);

expect(await aerodromeAmoStrategy.allowedWethShareEnd()).to.equal(
Expand Down
47 changes: 47 additions & 0 deletions contracts/test/vault/oeth-vault.mainnet.fork-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,53 @@ describe("ForkTest: OETH Vault", function () {
});
});

it("should allow strategist to redeem without fee", async () => {
const { oethVault, strategist, weth, oeth } = fixture;

const amount = oethUnits("10");

await weth.connect(strategist).approve(oethVault.address, amount);

// Mint 1:1
await oethVault.connect(strategist).mint(weth.address, amount, amount);

const oethBalanceBefore = await oeth.balanceOf(strategist.address);
const wethBalanceBefore = await weth.balanceOf(strategist.address);

// Redeem 1:1 instantly
await oethVault.connect(strategist).redeem(amount, amount);

const oethBalanceAfter = await oeth.balanceOf(strategist.address);
const wethBalanceAfter = await weth.balanceOf(strategist.address);

expect(oethBalanceAfter).to.equal(oethBalanceBefore.sub(amount));
expect(wethBalanceAfter).to.equal(wethBalanceBefore.add(amount));
});

it("should enforce fee on other users for instant redeem", async () => {
const { oethVault, josh, weth, oeth } = fixture;

const amount = oethUnits("10");
const expectedWETH = amount.mul("9990").div("10000");

await weth.connect(josh).approve(oethVault.address, amount);

// Mint 1:1
await oethVault.connect(josh).mint(weth.address, amount, amount);

const oethBalanceBefore = await oeth.balanceOf(josh.address);
const wethBalanceBefore = await weth.balanceOf(josh.address);

// Redeem 1:1 instantly
await oethVault.connect(josh).redeem(amount, expectedWETH);

const oethBalanceAfter = await oeth.balanceOf(josh.address);
const wethBalanceAfter = await weth.balanceOf(josh.address);

expect(oethBalanceAfter).to.equal(oethBalanceBefore.sub(amount));
expect(wethBalanceAfter).to.equal(wethBalanceBefore.add(expectedWETH));
});

it("should partially redeem 10 OETH", async () => {
const { domen, oeth, oethVault, weth } = fixture;

Expand Down

0 comments on commit 07b6933

Please sign in to comment.