Skip to content

Commit

Permalink
Merge pull request #82 from curvefi/fix-eth-burner
Browse files Browse the repository at this point in the history
Allow ETH burner to target Ether for an intermediate swap
  • Loading branch information
iamdefinitelyahuman authored Jan 5, 2021
2 parents 0ce6fe2 + 0b1f089 commit beb6693
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
41 changes: 28 additions & 13 deletions contracts/burners/ETHBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ def __init__(_receiver: address, _recovery: address, _owner: address, _emergency
self.owner = _owner
self.emergency_owner = _emergency_owner

self.swap_for[0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84] = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE # stETH


@payable
@external
def __default__():
# required to receive ether during intermediate swaps
pass


@external
def set_swap_for(_coin: address, _swap_for: address) -> bool:
Expand Down Expand Up @@ -167,7 +176,10 @@ def burn(_coin: address) -> bool:
# sometimes an intermediate swap is required to get to sETH
self._swap(registry_swap, coin, swap_for, amount, self)
coin = swap_for
amount = ERC20(coin).balanceOf(self)
if coin == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE:
amount = self.balance
else:
amount = ERC20(coin).balanceOf(self)

# swap to sETH
self._swap(registry_swap, coin, SETH, amount, self)
Expand Down Expand Up @@ -213,18 +225,21 @@ def recover_balance(_coin: address) -> bool:
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner

amount: uint256 = ERC20(_coin).balanceOf(self)
response: Bytes[32] = raw_call(
_coin,
concat(
method_id("transfer(address,uint256)"),
convert(self.recovery, bytes32),
convert(amount, bytes32),
),
max_outsize=32,
)
if len(response) != 0:
assert convert(response, bool)
if _coin == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE:
raw_call(self.recovery, b"", value=self.balance)
else:
amount: uint256 = ERC20(_coin).balanceOf(self)
response: Bytes[32] = raw_call(
_coin,
concat(
method_id("transfer(address,uint256)"),
convert(self.recovery, bytes32),
convert(amount, bytes32),
),
max_outsize=32,
)
if len(response) != 0:
assert convert(response, bool)

return True

Expand Down
2 changes: 1 addition & 1 deletion deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"ABurner": "0xAbADFd391b3821f3C80D48a59229769D0b677d2E",
"BTCBurner": "0x00702BbDEaD24C40647f235F15971dB0867F6bdB",
"CBurner": "0x55858AdaBb9EA24dDd0678DB0E9b41D8bD48e7EE",
"ETHBurner": "0x02C57fedb33D89e12CF6C482CD2D17481A60E311",
"ETHBurner": "0xD782EbD4bAbd95c2D8255112eFc6DD865c849394",
"EuroBurner": "0x3a16b6001201577CC67bDD8aAE5A105bbB035882",
"IdleBurner": "0xd1EBEf836f25047bB6AaC2DCD8618Efe2DC17D67",
"LPBurner": "0xaa42C0CD9645A58dfeB699cCAeFBD30f19B1ff81",
Expand Down
3 changes: 2 additions & 1 deletion scripts/burners/claim_and_burn_fees.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68", # oBTC

# ETH burner, converts to USDC and sends to underlying burner
"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", # stETH
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # ETH
"0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb", # sETH

Expand Down Expand Up @@ -93,7 +94,7 @@
# to the three minute settlement time.
SYNTH_BURNERS = [
"0x00702BbDEaD24C40647f235F15971dB0867F6bdB", # BtcBurner
"0x02C57fedb33D89e12CF6C482CD2D17481A60E311", # EthBurner
"0xD782EbD4bAbd95c2D8255112eFc6DD865c849394", # EthBurner
"0x3a16b6001201577CC67bDD8aAE5A105bbB035882", # EuroBurner
]

Expand Down
1 change: 1 addition & 0 deletions tests/fork/Burners/test_eth_burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def burner(ETHBurner, alice, receiver):

tokens = (
("0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb", "sETH"),
("0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", "stETH"),
)


Expand Down

0 comments on commit beb6693

Please sign in to comment.