View Source Hyperliquid.Api.Exchange.BorrowLend (hyperliquid v0.4.1)

Borrow or lend tokens in the Hyperliquid borrow/lend protocol.

Operations:

  • "supply" — lend tokens into the protocol
  • "withdraw" — withdraw a previously supplied position
  • "repay" — repay an outstanding borrow
  • "borrow" — borrow tokens from the protocol

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint

Usage

# Supply 20 units of token 0
{:ok, result} = BorrowLend.request("supply", 0, "20")

# Borrow, using nil to borrow the full available amount
{:ok, result} = BorrowLend.request("borrow", 0, nil)

# Repay full balance
{:ok, result} = BorrowLend.request("repay", 0, nil)

Summary

Functions

Execute a borrow/lend operation.

Functions

Link to this function

request(operation, token, amount, opts \\ [])

View Source

Execute a borrow/lend operation.

Parameters

  • operation: One of "supply", "withdraw", "repay", "borrow"
  • token: Integer token ID
  • amount: Amount as a decimal string, or nil for the full balance
  • opts: Optional parameters

Options

  • :private_key — Private key for signing (falls back to config)
  • :vault_address — Act on behalf of a vault

Returns

  • {:ok, response} — Result
  • {:error, term()} — Error details