hyperliquid-dex / hyperliquid-python-sdk

SDK for Hyperliquid API trading with Python.
MIT License
238 stars 97 forks source link

USD Vault Transfer #55

Closed cgaspart closed 4 weeks ago

cgaspart commented 1 month ago

Hello,

I wanted to use this route: Hyperliquid: Doc

So here's what I did: exchange.py

def vault_usd_transfer(self, vault_address: str, is_deposit: bool, usd: int) -> Any:
        timestamp = get_timestamp_ms()
        vault_transfer_action = {
            "type": "vaultTransfer",
            "vaultAddress": vault_address,
            "isDeposit": is_deposit,
            "usd": usd}
        is_mainnet = self.base_url == MAINNET_API_URL
        signature = sign_vault_transfer_action(self.wallet, vault_transfer_action, is_mainnet)
        return (
            self._post_action(
                vault_transfer_action,
                signature,
                timestamp,
            )
        )

signing.py

def sign_vault_transfer_action(wallet, action, is_mainnet):
    return sign_user_signed_action(
        wallet,
        action,
        [
            {"name": "type", "type": "string"},
            {"name": "vaultAddress", "type": "address"},
            {"name": "isDeposit", "type": "bool"},
            {"name": "usd", "type": "uint64"},
        ],
        "HyperliquidTransaction:VaultTransfer",
        is_mainnet,
    )

I get this error:

  hyperliquid.utils.error.ClientError: (422, None, 'Failed to deserialize the JSON body into the target type', None, {'Server': 'nginx/1.22.1', 'Date': 'Sun, 22 Sep 2024 14:11:25 GMT', 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '56', 'Connection': 'keep-alive', 'access-control-allow-origin': '*', 'vary': 'origin, access-control-request-method, access-control-request-headers', 'access-control-expose-headers': '*'})

If anyone can help me with this :)

cgaspart commented 1 month ago

Well, found out that someone built a lib in TS and use l1 signing. https://github.com/nomeida/hyperliquid/blob/main/src/rest/exchange.ts#L318

I will implement this and try again

IceCaptain0715 commented 1 month ago

I tried vault transfer and it is working. you can ping me at telegram @CaptainDev0

cgaspart commented 1 month ago

I tried vault transfer and it is working. you can ping me at telegram @CaptainDev0

What do you mean I tried vault transfer ? There is no function named like this, do you use your own modified SDK?

If yes can you share your implementation, that would be very helpful

IceCaptain0715 commented 1 month ago

they don't publish vault transfer api yet. But able to implement it.

On Mon, Sep 23, 2024 at 10:27 AM Lox3ur @.***> wrote:

I tried vault transfer and it is working. you can ping me at telegram @CaptainDev0

What do you mean I tried vault transfer ? There is no function named like this, do you use your own modified SDK?

If yes can you share your implementation, that would be very helpful

— Reply to this email directly, view it on GitHub https://github.com/hyperliquid-dex/hyperliquid-python-sdk/issues/55#issuecomment-2367537513, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEA66YJO35EUHKI23VW7YJ3ZX7GFPAVCNFSM6AAAAABOUTH2EWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRXGUZTONJRGM . You are receiving this because you commented.Message ID: @.***>

cgaspart commented 1 month ago

PR open: #56