-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce spot portfolio and account for portfolio balance in _transf…
…er_in: this prevents hackers from stealing from spot wallets
- Loading branch information
1 parent
e601564
commit 71c58d6
Showing
4 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import boa | ||
|
||
from tests.fixtures.pool import INITIAL_PRICES | ||
from tests.utils.tokens import mint_for_testing | ||
|
||
|
||
def test_no_steal_from_wallet(swap, coins, user, hacker): | ||
quantities = [10**36 // p for p in INITIAL_PRICES] # $3M worth | ||
|
||
for coin, q in zip(coins, quantities): | ||
mint_for_testing(coin, user, q) | ||
with boa.env.prank(user): | ||
coin.approve(swap, 2**256 - 1) | ||
|
||
split_quantities = [quantities[0] // 2, quantities[1] // 2] | ||
with boa.env.prank(user): | ||
swap.add_liquidity(split_quantities, 0) | ||
swap.deposit_to_spot_wallet(split_quantities, user) | ||
|
||
with boa.env.prank(hacker), boa.reverts(dev="user didn't give us coins"): | ||
swap.exchange_received(0, 1, 10**17, 0, hacker) |