Skip to content

Commit

Permalink
feat: clean-up aave method
Browse files Browse the repository at this point in the history
  • Loading branch information
sajanrajdev committed Dec 6, 2023
1 parent 36d8bcb commit 80004d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions great_ape_safe/ape_api/aave.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def lever_up(self, collateral_token, borrow_token, perc):
)
self.deposit(collateral_token, to_reinvest)

def delever(self, collateral_token, borrow_token, gains_token):
def delever(self, collateral_token, borrow_token):
debt_to_repay = self._get_debt_in_token(borrow_token)
debt_paid = 0
while debt_paid < debt_to_repay:
Expand Down Expand Up @@ -214,12 +214,7 @@ def delever(self, collateral_token, borrow_token, gains_token):

bal_borrow_token_after = borrow_token.balanceOf(self.safe)

if gains_token == collateral_token:
## Swap remaining margin of borrow token back into collateral token
self.safe.init_uni_v3()
self.safe.uni_v3.swap(
[borrow_token, collateral_token],
bal_borrow_token_after - bal_borrow_token_before,
)

assert self._get_debt_in_token(borrow_token) == 0

## Return margin of borrow token in case a swap back to collateral is desired
return bal_borrow_token_after - bal_borrow_token_before
2 changes: 1 addition & 1 deletion scripts/issue/533/leveraged_wbtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def delever():
SAFE.take_snapshot([WBTC, AWBTC, USDC])

wbtc_bal_before = WBTC.balanceOf(SAFE.account)
SAFE.aave.delever(WBTC, USDC, USDC)
SAFE.aave.delever(WBTC, USDC)
SAFE.aave.withdraw_all(WBTC)
wbtc_bal_after = WBTC.balanceOf(SAFE.account)

Expand Down

0 comments on commit 80004d9

Please sign in to comment.