Carbon

Documentation

Welcome to Carbon's docs!

Get Started    

Atomic Swaps

Carbon allows you to swap coins using two different methods.

1: Atomics Swaps
2: OTC Swap

Atomic Swaps are covered below and is the recommended method for consumer facing applications to swap tokens quickly. This can thought of as similar to ShapeShift.

OTC Swaps involves more steps but allows for deposits, withdrawals, trades and more. This is more similar to an exchange API.

How Does It Work?

Simply request a quote with the required information, and then deposit funds into a temporary custody address. Within moments, the swapped funds are sent to the user's preferred address.

After requesting a quote for ETH or TRX, send the appropriate amount of funds to the address supplied in the 'depositAddr' field of the quote response. After requesting a quote for EOS or CUSD, send the appropriate amount of funds to the account 'carbonteswal' with the memo specified in the quote response. Please make sure to send the same amount of funds as specified in the 'quantity' parameter of your quote request.

Getting a Quote

GET

Super JWT Required

Parameters

Parameters
Access
Description

contactId

required

your contactId

recvAddr

required

address to receive swapped funds
NOTE: be sure to enter an address for the OUTPUT ASSET

input

required

the asset symbol you own and would like to trade
ex. 'cusd', 'eos', 'trx', 'eth'

output

required

the asset symbol you would like to receive
ex. 'cusd', 'eos', 'trx', 'eth'

quantity

required

the amount of input you would like to exchange
NOTE: quantities with more precision than the chain allows will be rounded

let jwtToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJlMzE3YjdlNy0yMzQ1LTQ0MWMtODA0Ni1kYjgxNTkyYmEyN2YiLCJzdXBlclVzZXIiOnRydWUsImNvbnRhY3QiOmZhbHNlLCJlbWFpbCI6ImRhbmllbEBjYXJib24ubW9uZXkiLCJpYXQiOjE1NTczMjc5MTR9.WZnSR5N1FebmT9nMu97PJvku49NY0jk4aKVPKm_1MlM';

let headers = {
  headers: {
    Authoriziation: `Bearer ${jwtToken}`
  }
};

let url = `${ROOT}/v1/otc/atomicQuote`;
const contactId = '?contactId=6b77dd4c-c70e-40c8-8ec1-d9050f8bba74';
const recvAddr = '&recvAddr=0x16d35D396fb1762359d3F04CF472aE1c7566168d';
const input = '&input=EOS';
const output = '&output=ETH';
const quantity = '&quantity=10';

axios.get(url + contactId + recvAddr + input + output + quantity, headers).then(result => console.log(result)).catch(err => console.log(err));
// TRX
{
    "exchangeRate": "0.000097723280571718851021",
    "input": "80 TRX",
    "output": "0.0078178624457375080817 ETH",
    "depositAddr": "TDQPTM12U1qaAzxDy9F9UbrHp7rvhqCQSF"
}

// ETH
{
    "exchangeRate": "224.78814550202799909",
    "input": "2.5 ETH",
    "output": "561.97036375506999773 CUSD",
    "depositAddr": "0xD55418fD136e4F2d6F8448346D3041965e14825e"
}

// EOS
{
    "exchangeRate": "0.018824618396005703068",
    "input": "10 EOS",
    "output": "0.18824618396005703068 ETH",
    "memo": "326f7de609d0117bfd6615"
}

// CUSD
{
    "exchangeRate": "47.537386895670506381",
    "input": "50 CUSD",
    "output": "2376.8693447835253191 TRX",
    "memo": "911e8fe33fb29ec58022bc"
}
// 400
{
    "message": "cannot have same asset for input and output",
    "code": 400
}

// 400
{
    "message": "invalid recvAddr",
    "code": 400
}

// 400
{
    "message": "quantity must be greater than 0",
    "code": 400
}

// 400
{
    "message": "input/output pair not currently supported",
    "code": 400
}
Thank you for your feedback

Atomic Swaps


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.