LogoLogo
Join DiscordFollow on XBridge FundsLong $BERA
  • Doc Bros v1
    • Overview
    • Key Features
      • Speed & Liquidity is Key
      • Bropetual Markets
      • A Hub for Berachain DeFi
    • Proof-of-Liquidity
      • Reward Vault
    • Power of Points
    • Partners & Integrations
    • Campaigns
      • bro.trade Em Up
  • bullish bros
    • SuperBros NFT
  • Technicals
    • What is Proof-of-Liquidity?
    • One-Click Trading
    • Funding Rates
  • Liquidations & Insurance Fund
  • Vertex Edge Sequencer
  • Fees
  • PnL Settlements
  • Withdrawals
  • Pricing (Oracles)
  • links & resources
    • bro.trade Links
      • Website
      • Trade Bropetuals
      • Discord
      • X (Twitter)
      • Medium
      • Swap on OogaBooga
    • Berachain Links
      • Berachain.com
      • Official Bridge
      • BeraHub
      • Berascan
      • Bera Discord
      • Berachain X (Twitter)
      • Berachain Docs
    • FAQ
  • developer bros
    • API
      • Gateway
        • Executes
          • Place Order
          • Cancel Order
          • Cancel and Place
          • Cancel Product Order
          • Withdraw Colleteral
          • Transfer Quote
          • Liquidate Subaccount
          • Mint LP
          • Burn LP
          • Link Signer
        • Queries
          • All Products
          • Contracts
          • Fee Rates
          • Health Groups
          • Insurance
          • Linked Signer
          • Market Liquidity
          • Market Prices
          • Max Lp Mintable
          • Max Order Size
          • Max Withdrawable
          • Min Deposit Rates
          • Nonces
          • Order
          • Orders
          • Status
          • Subaccount Info
          • Symbols
        • Signing
          • Examples
          • Q A
      • Subscriptions
        • Authentication
        • Streams
        • Events
        • Rate Limits
      • Archive (indexer)
        • Candlesticks
        • Events
        • Funding Rate
        • Interest Funding Payments
        • Linked Signer Rate Limit
        • Liquidation Feed
        • Maker Statistics
        • Market Snapshots
        • Matches
        • Merkle Proofs
        • Oracle Price
        • Orders
        • Perp Prices
        • Product Snapshots
        • Rewards
        • Signatures
        • Subaccounts
        • Summary
        • HONEY Price
      • Trigger
        • Executes
          • Place Order
          • Cancel Orders
          • Cancel Product Orders
        • Queries
          • List Trigger Orders
      • V2
        • Apr
        • Assets
        • Contracts
        • Orderbook
        • Pairs
        • Tickers
        • Trades
      • Rate limits
      • Errors
      • Symbols
      • Depositing
      • Withdrawing (on-chain)
      • Integrate via Smart Contracts
      • Definitions / Formulas
    • On-Chain Contracts
Powered by GitBook
On this page
  • Rate limits
  • ​Request
  • ​Request Parameters
  • ​Signing
  • ​Response
  1. developer bros
  2. API
  3. Gateway
  4. Executes

Withdraw Colleteral

PreviousCancel Product OrderNextTransfer Quote

Last updated 2 months ago

Rate limits

  • With spot leverage: 60 withdrawals/min or 10 withdrawals every 10 seconds per wallet. (weight = 10)

  • Without spot leverage: 30 withdrawals/min or 5 withdrawals every 10 seconds per wallet. (weight=20)

See more details in .

Request

Connect

WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]

Message

{
  "withdraw_collateral": {
    "tx": {
      "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
      "productId": 1,
      "amount": "1000000000000000000",
      "nonce": "1"
    },
    "signature": "0x"
  }
}

POST [GATEWAY_REST_ENDPOINT]/execute

Body

{
  "withdraw_collateral": {
    "tx": {
      "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
      "productId": 1,
      "amount": "1000000000000000000",
      "nonce": "1"
    },
    "signature": "0x"
  }
}
Parameter
Type
Required
Description

tx

object

Yes

tx.sender

string

Yes

Hex string representing the subaccount’s 32 bytes (address + subaccount name) of the tx sender.

tx.productId

number

Yes

A spot product ID to withdraw from.

tx.amount

string

Yes

tx.nonce

string

Yes

signature

string

Yes

spot_leverage

boolean

No

Indicates whether leverage should be used; when set to false, the withdrawal fails if the transaction causes a borrow on the subaccount. Defaults to true.

The solidity typed data struct that needs to be signed is:

struct WithdrawCollateral {
    bytes32 sender;
    uint32 productId;
    uint128 amount;
    uint64 nonce;
}

sender: a bytes32 sent as a hex string; includes the address and the subaccount identifier.

productId: a uint32 that specifies the product you’d like to withdraw collateral from; must be for a spot product.

Note: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: nonce should be an uint64 for Signing but should be sent as a string in the final payload.

{
  "status": "success",
  "signature": {signature},
  "request_type": "execute_withdraw_collateral"
}
{
  "status": "failure",
  "signature": {signature},
  "error": "{error_msg}",
  "error_code": {error_code},
  "request_type": "execute_withdraw_collateral"
}

Request Parameters

Withdraw collateral transaction object. See section for details on the transaction fields.

The amount of the asset to withdraw, denominated in the base ERC20 token of the specified product e.g: USDC (product=0) has 6 decimals whereas wETH (product=3) has 18. See section for more details.

This is an incrementing nonce, can be obtained using the query.

Hex string representing hash of the signed transaction. See section for more details.

Signing

See more details and examples in our page.

amount: the amount of asset to withdraw, sent as a string. Note that this is different from the amounts provided in transactions that aren’t depositCollateral. This is the raw amount of the ERC20 token you want to receive, i.e. if USDC has 6 decimals and you want to withdraw 1 USDC, specify 1e6; if wETH has 18 decimals and you want to withdraw 1 wETH, specify 1e18. Use query to view the token address of the corresponding product which can be used to determine the correct decimals to use.

nonce: the tx_nonce. This is an incrementing nonce, can be obtained using the query.

Response

Success

Failure

API Rate limits
​
​
​
signing
all products
Nonces
​
​
​
Signing
Signing
Nonces
Signing