Skip to content

Commit

Permalink
Merge pull request #24 from CreamFi/feature-add-yvweth
Browse files Browse the repository at this point in the history
removed checkpoint_token from USDCBurner, added set_receiver
  • Loading branch information
stitetsati authored Aug 19, 2021
2 parents 1c0ba41 + af74b4a commit 9196e6d
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 14 deletions.
12 changes: 12 additions & 0 deletions contracts/burners/CBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/CurveLPBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,15 @@ def accept_transfer_emergency_ownership() -> bool:
@payable
def __default__():
pass


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/MUSDBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/SynthBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
22 changes: 11 additions & 11 deletions contracts/burners/USDCBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ interface YVaultIB3CRV:
nonpayable


interface FeeDistributor:
def checkpoint_token():
nonpayable

def checkpoint_total_supply():
nonpayable


receiver: public(address)
recovery: public(address)
owner: public(address)
Expand Down Expand Up @@ -94,9 +86,6 @@ def burn(_coin: address) -> bool:
yvault_ib3_crv_amount: uint256 = YVaultIB3CRV(YVAULT_IB3CRV).deposit(
ib3_crv_amount, self.receiver
)
# checkpoint fee distributor
FeeDistributor(self.receiver).checkpoint_token()
FeeDistributor(self.receiver).checkpoint_total_supply()
log Burn(amount, yvault_ib3_crv_amount)
return True

Expand Down Expand Up @@ -204,3 +193,14 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True

@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/UniswapBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/UniswapLPBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/UniswapV3Burner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/VvspBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/XSushiBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ def accept_transfer_emergency_ownership() -> bool:
self.emergency_owner = msg.sender

return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
12 changes: 12 additions & 0 deletions contracts/burners/YearnVaultBurner.vy
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,15 @@ def accept_transfer_emergency_ownership() -> bool:
assert msg.sender == self.future_emergency_owner # dev: only owner
self.emergency_owner = msg.sender
return True


@external
def set_receiver(_receiver: address) -> bool:
"""
@notice Set receiver
@param _receiver Receiver address
@return bool success
"""
assert msg.sender in [self.owner, self.emergency_owner] # dev: only owner
self.receiver = _receiver
return True
2 changes: 2 additions & 0 deletions scripts/deployment/deploy_burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def development():
uniswap_burner, RECOVERY, OWNER_ADMIN, EMERGENCY_ADMIN, {"from": deployer}
)
yWeth = "0xe1237aa7f535b0cc33fd973d66cbf830354d16c7"
yvWeth = "0xa9fe4601811213c340e850ea305481aff02f5b28"
yearn_vault_burner.add_burnable_coin(yWeth, {"from": OWNER_ADMIN})
yearn_vault_burner.add_burnable_coin(yvWeth, {"from": OWNER_ADMIN})

# deploy and setup another yearn vault burner that sends result to curve lp burner
yearn_vault_burner_2 = YearnVaultBurner.deploy(
Expand Down
6 changes: 4 additions & 2 deletions tests/fork/Burners/test_uniswap_burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def burner(UniswapBurner, alice, receiver):
WOO = "0x4691937a7508860f876c9c0a2a617e7d9e945d4b"
YFI = "0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e"
WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"

LON = "0x0000000000095413afC295d19EDeb1Ad7B71c952"
PAX = "0x8E870D67F660D95d5be530380D0eC0bd388289E1"

# Iron Bank
EURS = "0xdb25f211ab05b1c97d595516f45794528a807ad8"
Expand Down Expand Up @@ -131,6 +132,8 @@ def burner(UniswapBurner, alice, receiver):
(EURS, "0x0ce6a5ff5217e38315f87032cf90686c96627caa"),
(FEI, "0xf5bce5077908a1b7370b9ae04adc565ebd643966"),
(RAI, "0x86b0e9e05f0295adb39799a402d2992d10439454"),
(PAX, "0xf977814e90da44bfa03b6295a0616a897441acec"),
(LON, "0x0e57941a7c55f96c9153de218effcbfc4ae8e9dc"),
]


Expand Down Expand Up @@ -158,7 +161,6 @@ def test_burn(MintableTestToken, USDC, alice, receiver, burner, token, whale):
amount = 1000 * (10 ** token.decimals())
token.transfer(alice, amount, {"from": whale})

assert token.balanceOf(alice) == amount
token.approve(burner, 2 ** 256 - 1, {"from": alice})

burner.burn(token, {"from": alice})
Expand Down
25 changes: 25 additions & 0 deletions tests/fork/Burners/test_xsushi_burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,28 @@ def test_burn_invalid_token(MintableTestToken, alice, burner):
sushi = MintableTestToken.from_abi("Sushi", SUSHI, abi=ERC20)
with brownie.reverts("only allows burning xsushi"):
burner.burn(sushi, {"from": alice})


def test_set_receiver(MintableTestToken, alice, receiver, burner, bob):
xSushi = MintableTestToken.from_abi("xSushi", XSUSHI, abi=ERC20)
sushi = MintableTestToken.from_abi("Sushi", SUSHI, abi=ERC20)
amount = 10 ** xSushi.decimals()

xSushi._mint_for_testing(alice, amount, {"from": alice})
xSushi.approve(burner, 2 ** 256 - 1, {"from": alice})

assert xSushi.balanceOf(alice) == amount
assert xSushi.balanceOf(burner) == 0
assert xSushi.balanceOf(receiver) == 0

burner.set_receiver(bob, {"from": alice})
burner.burn(xSushi, {"from": alice})

assert xSushi.balanceOf(alice) == 0
assert xSushi.balanceOf(burner) == 0
assert xSushi.balanceOf(receiver) == 0

assert sushi.balanceOf(alice) == 0
assert sushi.balanceOf(burner) == 0
assert sushi.balanceOf(receiver) == 0
assert sushi.balanceOf(bob) > 0
4 changes: 3 additions & 1 deletion tests/fork/Burners/test_yearn_vault_burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def burner(YearnVaultBurner, alice, receiver):
CrvSTETH = "0x06325440d014e39736583c165c2963ba99faf14e"

yWeth = "0xe1237aa7f535b0cc33fd973d66cbf830354d16c7"
yvWeth = "0xa9fe4601811213c340e850ea305481aff02f5b28"
WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"

yUSD = "0x4B5BfD52124784745c1071dcB244C6688d2533d3"
yCRV = "0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8" # Curve.fi yDAI/yUSDC/yUSDT/yTUSD
Y3Crv = "0x9cA85572E6A3EbF24dEDd195623F188735A5179f"
Crv3 = "0x6c3f90f043a72fa612cbac8115ee7e52bde6e490"
burnable_coins = {YVCrvSETH: CrvSETH, YVCrvSTETH: CrvSTETH, yUSD: yCRV, Y3Crv: Crv3}
burnable_coins = {YVCrvSETH: CrvSETH, YVCrvSTETH: CrvSTETH, yUSD: yCRV, Y3Crv: Crv3, yvWeth: WETH}

unburnable_coins = {
yWeth: WETH,
Expand Down

0 comments on commit 9196e6d

Please sign in to comment.