Skip to content

Latest commit

 

History

History
333 lines (214 loc) · 11.6 KB

api-doc.md

File metadata and controls

333 lines (214 loc) · 11.6 KB

api.stablecoin.services

The stablecoin.services api at https://api.stablecoin.services is a relaying service which accepts signed messages as specified by the DACH contract and submits them to the ethereum blockchain.

Front end developers can integrate with this api to provide gas-free version of the following operations:

  • Dai transfers
  • Chai transfers
  • Dai -> Eth uniswap trades
  • Chai -> Eth uniswap trades
  • Dai <-> Chai conversion

Instead, a dai or chai fee must be provided to pay for the cost of relaying. The necessary fee for an operation can be determined by calling the <operation>/fee GET method.

First time users which have not yet given the Dach contract an allowance can do so by using the <operation>WithPermit version of the appropriate operation. This first submits a permit message to the appropriate token contract before initiating the cheque, swap or conversion.

The api provides the following methods:

Table of Contents

The api accepts ERC712 signed messages. There are 5 different kinds of messages, permit, cheque, swap, join, and exit. For an example of how to generate ERC712 signed messages for these, you can look at the stablecoin.services source at https://github.com/MrChico/stablecoin.services/

Types

Permit

The permit comes in two forms, a dai.permit and a chai.permit, both comprised of the following fields:

  • Holder, the address which is giving permission.
  • Spender, the address to which permission is given.
  • expiry (optional with default := 0), the time the permit can no longer be submitted.
  • allowed (optional with default := true), whether or not permission is given. Must be true.
  • v
  • r
  • s, the signature details of the ERC712 dai or chai permit.

Cheque

A cheque consists of:

  • sender, the address sending dai/chai.
  • receiver, the address receiving dai/chai.
  • amount, a string or number representing the the dai/chai to be spent (with 18 decimal places).
  • nonce, (optional with default := 0) a string or number representing the dach nonce of the sender.
  • fee, a string or number value of dai/chai to be given to the relayer. Must be at least cheque/fee.
  • relayer, an address to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".
  • v
  • r
  • s, signature details of the ERC712 dai or chai Cheque.

Swap

A swap consists of:

  • sender, the address sending dai/chai.
  • amount, a string or number representing the the dai/chai to sold on in the uniswap contract (with 18 decimal places).
  • min_eth, a string or number representing the minimal eth to be received.
  • nonce, (optional with default := 0) a string or number representing the dach nonce of the sender.
  • fee, a string or number value of dai/chai to be given to the relayer. Must be at least swap/fee.
  • relayer, an address to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".
  • v
  • r
  • s, signature details of the ERC712 dai or chai swap.

Join/Exit

A join or exit consists of:

  • sender, the address converting dai to chai or vice versa.
  • receiver, the address receiving dai/chai.
  • amount, a string or number representing the the dai/chai to be spent (with 18 decimal places).
  • nonce, (optional with default := 0) a string or number representing the dach nonce of the sender.
  • fee, a string or number value of dai/chai to be given to the relayer. Must be at least join/fee.
  • relayer, an address to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".
  • v
  • r
  • s, signature details of the ERC712 chaiJoin or chaiExit.

GET methods:

/v1/daiChequeWithPermit/fee

Parameters:

None.

Returns

The minimal dai fee required for a daiChequeWithPermit to be accepted (with 18 decimal places).

/v1/daiSwapWithPermit/fee

Parameters:

None.

Returns

The minimal dai fee required for a daiSwapWithPermit to be accepted (with 18 decimal places).

/v1/chaiChequeWithPermit/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiChequeWithPermit to be accepted (with 18 decimal places).

/v1/chaiSwapWithPermit/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiSwapWithPermit to be accepted (with 18 decimal places).

/v1/chaiJoinWithPermit/fee

Parameters:

None.

Returns

The minimal dai fee required for a chaiJoinWithPermit to be accepted (with 18 decimal places).

  • Note that the permit required for the chaiJoinWithPermit operation is that of the Dai contract.

/v1/chaiExitWithPermit/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiExitWithPermit to be accepted (with 18 decimal places).

  • Note that the permit required for the chaiExitWithPermit operation is that of the Chai contract

/v1/daiCheque/fee

Parameters:

None.

Returns

The minimal dai fee required for a daiCheque to be accepted (with 18 decimal places).

/v1/daiSwap/fee

Parameters:

None.

Returns

The minimal dai fee required for a daiSwap to be accepted (with 18 decimal places).

/v1/chaiCheque/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiCheque to be accepted (with 18 decimal places).

/v1/chaiSwap/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiSwap to be accepted (with 18 decimal places).

/v1/chaiJoin/fee

Parameters:

None.

Returns

The minimal dai fee required for a chaiJoin to be accepted (with 18 decimal places).

/v1/chaiExit/fee

Parameters:

None.

Returns

The minimal chai fee required for a chaiExit to be accepted (with 18 decimal places).

POST methods

/v1/daiChequeWithPermit

Parameters:

A json object containing a dai permit and dai cheque.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a chequeHash containing the hash of the transaction submitting the permit and cheque.

/v1/daiSwapWithPermit

Parameters:

A json object containing a dai permit and dai swap.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a swapHash containing the hash of the transaction submitting the permit and swap.

/v1/chaiChequeWithPermit

Parameters:

A json object containing a chai permit and chai cheque.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a chequeHash containing the hash of the transaction submitting the permit and cheque.

/v1/chaiSwapWithPermit

Parameters:

A json object containing a chai permit and chai swap.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a swapHash containing the hash of the transaction submitting the permit and swap.

/v1/chaiJoinWithPermit

Parameters:

A json object containing a dai permit and chai Join.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a joinHash containing the hash of the transaction submitting the permit and join.

/v1/chaiExitWithPermit

Parameters:

A json object containing a chai permit and chai Exit.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a exitHash containing the hash of the transaction submitting the permit and exit.

/v1/daiCheque

Parameters:

A json object containing a dai cheque.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a chequeHash containing the hash of the transaction submitting the cheque.

/v1/daiSwap

Parameters:

A json object containing a dai swap.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a swapHash containing the hash of the transaction submitting the swap.

/v1/chaiCheque

Parameters:

A json object containing a chai cheque.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a chequeHash containing the hash of the transaction submitting the cheque.

/v1/chaiSwap

Parameters:

A json object containing a chai swap.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a swapHash containing the hash of the transaction submitting the swap.

/v1/chaiJoin

Parameters:

A json object containing a chai Join.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a joinHash containing the hash of the transaction submitting the join.

/v1/chaiExit

Parameters:

A json object containing a chai Exit.

Returns

A json object containing the fields success and message, where message either contains an error message, or, if success is true, a exitHash containing the hash of the transaction submitting the exit.