Skip to content

Commit

Permalink
quant-961 making it e18 (#9)
Browse files Browse the repository at this point in the history
* making it e18

* Update pyproject.toml
  • Loading branch information
ibadia authored Sep 10, 2023
1 parent 294a4ab commit 8ff2a88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
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

0 comments on commit 8ff2a88

Please sign in to comment.