Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
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_sui"
version = "1.1.6"
version = "1.1.7"
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
1 change: 0 additions & 1 deletion src/bluefin_rfq_client/quote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

from sui_utils import *
from typing import Self


# Defines the Quote class
Expand Down
31 changes: 27 additions & 4 deletions src/bluefin_rfq_client/rfq.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ def withdraw_from_vault(self,

Returns:
Tuple of bool (indicating status of execution) and sui chain response (dict).
"""



"""
move_function_params = [
vault,
self.rfq_contracts.get_protocol_config(),
Expand Down Expand Up @@ -228,6 +225,32 @@ def withdraw_from_vault(self,
except Exception as e:
return False , res

def get_vault_coin_balance(self,
vault: str,
token_type: str
) -> str :
"""
get balance of specified token type locked in the vault

Parameters:
vault (str): on chain vault object ID.
token_type (str): on chain token type of the coin (i.e for USDC , usdc_Address::usdc::USDC)

Returns:
balance(str): balance of the coin scaled by coin decimals.
"""

res = rpc_sui_getDynamicFieldObject(
self.url,
vault,
strip_hex_prefix(token_type),
SUI_STRING_OBJECT_TYPE)
try:
balance = res["result"]["data"]["content"]["fields"]["value"]
return balance
except Exception as e:
raise Exception("Could not fetch coin balance",e)

def create_vault(self,
manager: str
) -> tuple[bool, dict] :
Expand Down
37 changes: 37 additions & 0 deletions src/sui_utils/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,43 @@ def rpc_sui_executeTransactionBlock(url, txBytes, signature, maxRetries=5):
time.sleep(1)
return result

def rpc_sui_getDynamicFieldObject(url:str, parentObjectId: str, fieldName: str,fieldSuiObjectType:str, maxRetries=5):
"""
Fetches the on-chain dynamic field object corresponding to specified input params
Input:
url: url of the sui chain node
parentObjectId: id of the parent object for which dynamic field needs to be queried
fieldName: name of the dynamic field
fieldSuiObjectType: sui object type for the dynamic field name (eg. for string use , `0x1::string::String`)

Output:
sui result object for the dynamic field
"""
base_dict = {}
base_dict["jsonrpc"] = "2.0"
base_dict["id"] = 5
base_dict["method"] = "suix_getDynamicFieldObject"
base_dict["params"] = []
base_dict["params"].append(parentObjectId)
base_dict["params"].append({
"type": fieldSuiObjectType,
"value": fieldName
})
payload = json.dumps(base_dict)

headers = {"Content-Type": "application/json"}

for i in range(0, maxRetries):
response = requests.request("POST", url, headers=headers, data=payload)
result = json.loads(response.text)
if "error" in result:
if result["error"]["message"].find(LOCKED_OBJECT_ERROR_CODE) == -1:
return result
else:
return result

time.sleep(1)
return result

def rpc_call_sui_function(url, params, method="suix_getCoins"):
"""
Expand Down
1 change: 1 addition & 0 deletions src/sui_utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
BASE_1E18 = 1000000000000000000
BASE_1E6 = 1000000 # 1e6 for USDC token
BASE_1E9 = 1000000000
SUI_STRING_OBJECT_TYPE = "0x1::string::String"


def getsha256Hash(callArgs: list) -> str:
Expand Down
Loading