Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quant-961 making it e18 #9

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bluefin_v2_client"
version = "2.0.3"
version = "2.0.4"
description = "Library to interact with Bluefin exchange protocol including its off-chain api-gateway and on-chain contracts"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
28 changes: 12 additions & 16 deletions src/bluefin_v2_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,9 @@ def create_signed_order(self, req: OrderSignatureRequest) -> OrderSignatureRespo
OrderSignatureResponse: order raw info and generated signature
"""
sui_params = deepcopy(req)
sui_params["price"] = self._to_sui_base(req["price"])
sui_params["quantity"] = self._to_sui_base(req["quantity"])
sui_params["leverage"] = self._to_sui_base(req["leverage"])

price_base18 = toDapiBase(req["price"])
quantity_base18 = toDapiBase(req["quantity"])
leverage_base18 = toDapiBase(req["leverage"])
sui_params["price"] = toDapiBase(req["price"])
sui_params["quantity"] = toDapiBase(req["quantity"])
sui_params["leverage"] = toDapiBase(req["leverage"])

order = self.create_order_to_sign(sui_params)
symbol = sui_params["symbol"].value
Expand All @@ -169,10 +165,10 @@ def create_signed_order(self, req: OrderSignatureRequest) -> OrderSignatureRespo
order_signature = order_signature + self.account.publicKeyBase64.decode()
return OrderSignatureResponse(
symbol=symbol,
price=price_base18,
quantity=quantity_base18,
price=sui_params["price"],
quantity=sui_params["quantity"],
side=sui_params["side"],
leverage=leverage_base18,
leverage=sui_params["leverage"],
reduceOnly=default_value(sui_params, "reduceOnly", False),
salt=order["salt"],
expiration=order["expiration"],
Expand All @@ -197,9 +193,9 @@ def create_signed_cancel_order(
OrderSignatureResponse: generated cancel signature
"""
sui_params = deepcopy(params)
sui_params["price"] = self._to_sui_base(params["price"])
sui_params["quantity"] = self._to_sui_base(params["quantity"])
sui_params["leverage"] = self._to_sui_base(params["leverage"])
sui_params["price"] = toDapiBase(params["price"])
sui_params["quantity"] = toDapiBase(params["quantity"])
sui_params["leverage"] = toDapiBase(params["leverage"])

order_to_sign = self.create_order_to_sign(sui_params)
hash_val = self.order_signer.get_order_hash(order_to_sign, withBufferHex=False)
Expand Down Expand Up @@ -449,7 +445,7 @@ async def adjust_leverage(self, symbol, leverage, parentAddress: str = ""):
callArgs.append(self.contracts.get_bank_id())
callArgs.append(self.contracts.get_sub_account_id())
callArgs.append(account_address)
callArgs.append(str(self._to_sui_base(leverage)))
callArgs.append(str(toDapiBase(leverage)))
callArgs.append(self.contracts.get_price_oracle_object_id(symbol))
txBytes = rpc_unsafe_moveCall(
self.url,
Expand Down Expand Up @@ -511,7 +507,7 @@ async def adjust_margin(

callArgs.append(self.contracts.get_sub_account_id())
callArgs.append(self.account.getUserAddress())
callArgs.append(str(toSuiBase(amount)))
callArgs.append(str(toDapiBase(amount)))
callArgs.append(self.contracts.get_price_oracle_object_id(symbol))
if operation == ADJUST_MARGIN.ADD:
txBytes = rpc_unsafe_moveCall(
Expand Down Expand Up @@ -629,7 +625,7 @@ async def get_margin_bank_balance(self) -> float:
self.url, call_args, method="suix_getDynamicFieldObject"
)

balance = self._from_sui_base(
balance = fromDapiBase(
result["data"]["content"]["fields"]["value"]["fields"]["balance"]
)
return balance
Expand Down
Loading