Buy/Sell Crypto
Fortress's APIs allow end users to buy and sell crypto for fiat directly within their custodial accounts. The trading pairs currently supported are:
- USD <-> BTC
- USD <-> ETH
- USD <-> USDC on Polygon and Ethereum Blockchains
- USD <-> MATIC
- USD <-> SOL
- USD <-> ADA
- USD <-> XLM
- USD <-> DOT
- USD <-> LINK
- USD <-> ALGO
- USD <-> AVAX
- USD <-> LTC
- USD <-> UNI
- USD <-> BUSD
- USD <-> BNB
- More trading pairs coming soon
Overview
The general workflow for crypto trades will look like the following:
- Pull the market price for the crypto your end user is looking to buy/sell from our API.
- Give the end user the ability to confirm a trade after looking at the market price.
- Call the Fortress API to initiate a
trade
- Monitor the webhooks sent for a change in the
status
of a trade. - Once completed, update your front end with the new balance for the end user.
Lets review each step a bit more.
1. Pull the market price
GET /api/trust/v1/crypto-currency/crypto-currency-price/{network}/{currency}
//Sample Response
{
"price": {
"buy": 21489.79,
"sell": 21457.19
}
}
Note: Currently it will be an API call to pull the market price at that time. Eventually we will implement a websocket that will stream prices to you.
2. Allow the end user to confirm that they want the trade after presenting them the market price.
3. Initiate a trade
using the API
POST /api/trust/v1/trades
//Sample Request
{
"accountId": "A3CA08AB-3058-4C3C-81E7-51DA24B171FF",
"type": "market", //only "market" is available at this time
"from": {
"asset": "usd",
"amount": 100
},
"to": {
"asset": "eth"
},
"comment": "Any Comment Here"
}
OR
POST /api/trust/v1/trades
// Sample Request
{
"accountId": "A3CA08AB-3058-4C3C-81E7-51DA24B171FF",
"type": "market", //only "market" is availbable at this time
"from": {
"asset": "eth",
"amount": 100
},
"to": {
"asset": "usd"
},
"comment": "Any Comment Here"
}
All in one
The
trades
endpoint facilitates both buys and sells by designating thefrom
andto
fields.
4. Monitor webhooks
An integrator will receive one webhook when the buy/sell crypto transaction is moved to the Processing
status and another webhook when the settlement process is completed. Here are a list of the status's available for the trades
endpoint:
-
Pending (the buy/sell crypto request is created)
-
Processing (the buy/sell crypto request is in progress, pending incoming crypto/fiat is displayed in an account
balance) -
Completed (settlement process is completed)
-
Aborted (processing of the buy/sell crypto request is failed)
5. Once a trade is completed, update your front end with the new balance
GET /custodial-accounts/{custodialAccountId}/balances
//Sample Response
{
"data": [
{
"assetType": "cryptoCurrency",
"assetFiatType": "eth",
"network": "mainnet",
"disbursable": .001,
"locked": 0,
"pending": 0,
"total": .001
}
]
}
Updated 9 days ago