4.0.0 • Published 2 years ago

@elevenyellow.com/switchain-api-client v4.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

Install

npm i @elevenyellow.com/switchain-api-client

Docs

https://apidoc.switchain.com/

Initialize

const { init } = require('switchain-api-client')
const SwitchainApi = init({
  apiKey: 'xxxxxxxx-yyyy-zzzz-0000-999999999999',
  apiUrl: 'http://localhost:3020/rest/v1/' // optional
})

API

getOffers

Returns

{
    info: [ { signature, expiryTs, pair, fromChains, toChains, quote, maxLimit, minLimit, minerFees }, ... ]
}

Example

const { info } = SwitchainApi.getOffers()

getOffer

Params

  • pair: string (required)
  • amountFrom: string
  • orderIdSeed: string

Returns

{
  offer: {
    signature, expiryTs, pair, quote, maxLimit, minLimit
  }
}

Example

const { offer } = SwitchainApi.getOffer({
  pair: 'ETH-DAI'
})

postOrder

Params

  • pair: string
  • toAddress: string
  • refundAddress: string
  • fromAmount: string
  • signature: string

Returns

{
  order: {
    orderId, fromAmount, rate, exchangeAddress, toAddress, refundAddress
  }
}

Example

const { offer } = SwitchainApi.postOrder({
  toAddress,
  refundAddress,
  pair,
  fromAmount,
  signature
})

getOrder

Params

  • orderId: string

Returns

{
  status: {
    status, fromAmount, rate, exchangeAddress, toAddress, refundAddress, toTx
  }
}

Example

const { status } = SwitchainApi.getOrder({ orderId })
4.0.0

2 years ago

3.6.0

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago