Skip to content

Commit 0a959df

Browse files
Lint demos (#231)
1 parent 5ce352a commit 0a959df

12 files changed

+30
-30
lines changed

src/demo_quipuswap/handlers/on_fa12_divest_liquidity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ async def on_fa12_divest_liquidity(
2525
position, _ = await models.Position.get_or_create(trader=trader, symbol=symbol)
2626

2727
assert transaction_1.amount is not None
28-
tez_qty = Decimal(transaction_1.amount) / (10 ** 6)
29-
token_qty = Decimal(transfer.parameter.value) / (10 ** decimals)
28+
tez_qty = Decimal(transaction_1.amount) / (10**6)
29+
token_qty = Decimal(transfer.parameter.value) / (10**decimals)
3030
shares_qty = int(divest_liquidity.parameter.shares)
3131

32-
tez_pool = Decimal(storage.storage.tez_pool) / (10 ** 6)
33-
token_pool = Decimal(storage.storage.token_pool) / (10 ** decimals)
32+
tez_pool = Decimal(storage.storage.tez_pool) / (10**6)
33+
token_pool = Decimal(storage.storage.token_pool) / (10**decimals)
3434

3535
# NOTE: Empty pools mean exchange is not initialized yet
3636
if not tez_pool and not token_pool:

src/demo_quipuswap/handlers/on_fa12_invest_liquidity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ async def on_fa12_invest_liquidity(
2323
position, _ = await models.Position.get_or_create(trader=trader, symbol=symbol)
2424

2525
assert invest_liquidity.data.amount is not None
26-
tez_qty = Decimal(invest_liquidity.data.amount) / (10 ** 6)
27-
token_qty = Decimal(transfer.parameter.value) / (10 ** decimals)
26+
tez_qty = Decimal(invest_liquidity.data.amount) / (10**6)
27+
token_qty = Decimal(transfer.parameter.value) / (10**decimals)
2828
new_shares_qty = int(storage.storage.ledger[trader].balance) + int(storage.storage.ledger[trader].frozen_balance) # type: ignore
2929

30-
price = (Decimal(storage.storage.tez_pool) / (10 ** 6)) / (Decimal(storage.storage.token_pool) / (10 ** decimals))
30+
price = (Decimal(storage.storage.tez_pool) / (10**6)) / (Decimal(storage.storage.token_pool) / (10**decimals))
3131
value = tez_qty + price * token_qty
3232
share_px = value / (new_shares_qty - position.shares_qty)
3333
assert share_px > 0, invest_liquidity.data.hash

src/demo_quipuswap/handlers/on_fa12_tez_to_token.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ async def on_fa12_tez_to_token(
1818
symbol = ctx.template_values['symbol']
1919
trader = tez_to_token_payment.data.sender_address
2020

21-
min_token_quantity = Decimal(tez_to_token_payment.parameter.min_out) / (10 ** decimals)
22-
token_quantity = Decimal(transfer.parameter.value) / (10 ** decimals)
21+
min_token_quantity = Decimal(tez_to_token_payment.parameter.min_out) / (10**decimals)
22+
token_quantity = Decimal(transfer.parameter.value) / (10**decimals)
2323
assert tez_to_token_payment.data.amount is not None
24-
tez_quantity = Decimal(tez_to_token_payment.data.amount) / (10 ** 6)
24+
tez_quantity = Decimal(tez_to_token_payment.data.amount) / (10**6)
2525
assert min_token_quantity <= token_quantity, tez_to_token_payment.data.hash
2626

2727
trade = models.Trade(

src/demo_quipuswap/handlers/on_fa12_token_to_tez.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ async def on_fa12_token_to_tez(
2020
symbol = ctx.template_values['symbol']
2121
trader = token_to_tez_payment.data.sender_address
2222

23-
min_tez_quantity = Decimal(token_to_tez_payment.parameter.min_out) / (10 ** 6)
24-
token_quantity = Decimal(token_to_tez_payment.parameter.amount) / (10 ** decimals)
23+
min_tez_quantity = Decimal(token_to_tez_payment.parameter.min_out) / (10**6)
24+
token_quantity = Decimal(token_to_tez_payment.parameter.amount) / (10**decimals)
2525
assert transaction_0.amount is not None
26-
tez_quantity = Decimal(transaction_0.amount) / (10 ** 6)
26+
tez_quantity = Decimal(transaction_0.amount) / (10**6)
2727
assert min_tez_quantity <= tez_quantity, token_to_tez_payment.data.hash
2828

2929
trade = models.Trade(

src/demo_quipuswap/handlers/on_fa12_withdraw_profit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ async def on_fa12_withdraw_profit(
2020
position, _ = await models.Position.get_or_create(trader=trader, symbol=symbol)
2121
if transaction_0:
2222
assert transaction_0.amount is not None
23-
position.realized_pl += Decimal(transaction_0.amount) / (10 ** 6) # type: ignore
23+
position.realized_pl += Decimal(transaction_0.amount) / (10**6) # type: ignore
2424

2525
await position.save()

src/demo_quipuswap/handlers/on_fa2_divest_liquidity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ async def on_fa2_divest_liquidity(
2525
position, _ = await models.Position.get_or_create(trader=trader, symbol=symbol)
2626

2727
assert transaction_1.amount is not None
28-
tez_qty = Decimal(transaction_1.amount) / (10 ** 6)
29-
token_qty = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10 ** decimals)
28+
tez_qty = Decimal(transaction_1.amount) / (10**6)
29+
token_qty = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10**decimals)
3030
shares_qty = int(divest_liquidity.parameter.shares)
3131

32-
tez_pool = Decimal(storage.storage.tez_pool) / (10 ** 6)
33-
token_pool = Decimal(storage.storage.token_pool) / (10 ** decimals)
32+
tez_pool = Decimal(storage.storage.tez_pool) / (10**6)
33+
token_pool = Decimal(storage.storage.token_pool) / (10**decimals)
3434

3535
# NOTE: Empty pools mean exchange is not initialized yet
3636
if not tez_pool and not token_pool:

src/demo_quipuswap/handlers/on_fa2_invest_liquidity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ async def on_fa2_invest_liquidity(
2323
position, _ = await models.Position.get_or_create(trader=trader, symbol=symbol)
2424

2525
assert invest_liquidity.data.amount is not None
26-
tez_qty = Decimal(invest_liquidity.data.amount) / (10 ** 6)
27-
token_qty = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10 ** decimals)
26+
tez_qty = Decimal(invest_liquidity.data.amount) / (10**6)
27+
token_qty = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10**decimals)
2828
new_shares_qty = int(storage.storage.ledger[trader].balance) + int(storage.storage.ledger[trader].frozen_balance) # type: ignore
2929

30-
price = (Decimal(storage.storage.tez_pool) / (10 ** 6)) / (Decimal(storage.storage.token_pool) / (10 ** decimals))
30+
price = (Decimal(storage.storage.tez_pool) / (10**6)) / (Decimal(storage.storage.token_pool) / (10**decimals))
3131
value = tez_qty + price * token_qty
3232
share_px = value / (new_shares_qty - position.shares_qty)
3333
assert share_px > 0, invest_liquidity.data.hash

src/demo_quipuswap/handlers/on_fa2_tez_to_token.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ async def on_fa2_tez_to_token(
1818
symbol = ctx.template_values['symbol']
1919
trader = tez_to_token_payment.data.sender_address
2020

21-
min_token_quantity = Decimal(tez_to_token_payment.parameter.min_out) / (10 ** decimals)
21+
min_token_quantity = Decimal(tez_to_token_payment.parameter.min_out) / (10**decimals)
2222
assert tez_to_token_payment.data.amount is not None
23-
token_quantity = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10 ** decimals)
24-
tez_quantity = Decimal(tez_to_token_payment.data.amount) / (10 ** 6)
23+
token_quantity = sum(Decimal(tx.amount) for tx in transfer.parameter.__root__[0].txs) / (10**decimals)
24+
tez_quantity = Decimal(tez_to_token_payment.data.amount) / (10**6)
2525
assert min_token_quantity <= token_quantity, tez_to_token_payment.data.hash
2626

2727
trade = models.Trade(

src/demo_quipuswap/handlers/on_fa2_token_to_tez.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ async def on_fa2_token_to_tez(
2020
symbol = ctx.template_values['symbol']
2121
trader = token_to_tez_payment.data.sender_address
2222

23-
min_tez_quantity = Decimal(token_to_tez_payment.parameter.min_out) / (10 ** decimals)
24-
token_quantity = Decimal(token_to_tez_payment.parameter.amount) / (10 ** decimals)
23+
min_tez_quantity = Decimal(token_to_tez_payment.parameter.min_out) / (10**decimals)
24+
token_quantity = Decimal(token_to_tez_payment.parameter.amount) / (10**decimals)
2525
assert transaction_0.amount is not None
26-
tez_quantity = Decimal(transaction_0.amount) / (10 ** 6)
26+
tez_quantity = Decimal(transaction_0.amount) / (10**6)
2727
assert min_tez_quantity <= tez_quantity, token_to_tez_payment.data.hash
2828

2929
trade = models.Trade(

src/demo_quipuswap/handlers/on_fa2_withdraw_profit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ async def on_fa2_withdraw_profit(
2121

2222
if transaction_0:
2323
assert transaction_0.amount is not None
24-
position.realized_pl += Decimal(transaction_0.amount) / (10 ** 6) # type: ignore
24+
position.realized_pl += Decimal(transaction_0.amount) / (10**6) # type: ignore
2525

2626
await position.save()

0 commit comments

Comments
 (0)