Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Client

Index

Constructors

constructor

  • Create a new instance of Client

    Parameters

    Returns Client

    Example

    import { Client } from '@neon-exchange/api-client-typescript'
    
    const nash = new Client({
      apiURI: 'https://pathtoapiurl',
      casURI: 'https://pathtocasurl',
      debug: true
    })

Properties

Private account

account: any

assetData

assetData: object

Type declaration

Private assetNonces

assetNonces: object

Type declaration

  • [key: string]: number[]

Private casCookie

casCookie: string

Private gql

gql: ApolloClient<any>

Private initParams

initParams: InitParams

marketData

marketData: object

Type declaration

Private nashCoreConfig

nashCoreConfig: Config

Private noncesDirty

noncesDirty: boolean = true

Private opts

Private publicKey

publicKey: string

Private tradedAssets

tradedAssets: string[] = []

Private walletIndices

walletIndices: object

Type declaration

  • [key: string]: number

Methods

cancelAllOrders

  • cancelAllOrders(marketName?: string): Promise<boolean>
  • Cancel all orders by market name

    Parameters

    • Optional marketName: string

    Returns Promise<boolean>

    Example

    const result = await nash.cancelAllOrders('neo_gas')
    console.log(result)

cancelOrder

  • cancelOrder(orderID: string, marketName: string): Promise<CancelledOrder>
  • Cancel an order by ID.

    Parameters

    • orderID: string
    • marketName: string

    Returns Promise<CancelledOrder>

    Example

    const cancelledOrder = await nash.cancelOrder('11')
    console.log(cancelledOrder)

Private createAndUploadKeys

  • createAndUploadKeys(encryptionKey: Buffer, casCookie: string, presetWallets?: object): Promise<void>
  • creates and uploads wallet and encryption keys to the CAS.

    expects something like the following { "signature_public_key": "024b14170f0166ff85882356295f5aa0cf4a9a5d29725b5a9e410ec193d20ee98f", "encrypted_secret_key": "eb13bb0e89102d64700906c7082f9472", "encrypted_secret_key_nonce": "f6783fe349320f71acc2ca79", "encrypted_secret_key_tag": "7c8dc1020de77cd42dbbbb850f4335e8", "wallets": [ { "blockchain": "neo", "address": "Aet6eGnQMvZ2xozG3A3SvWrMFdWMvZj1cU", "public_key": "039fcee26c1f54024d19c0affcf6be8187467c9ba4749106a4b897a08b9e8fed23" }, { "blockchain": "ethereum", "address": "5f8b6d9d487c8136cc1ad87d6e176742af625de8", "public_key": "04d37f1a8612353ffbf20b0a68263b7aae235bd3af8d60877ed8135c27630d895894885f220a39acab4e70b025b1aca95fab1cd9368bf3dc912ef32dc65aecfa02" } ] }

    Parameters

    • encryptionKey: Buffer
    • casCookie: string
    • Optional presetWallets: object

    Returns Promise<void>

Private createTimestamp32

  • createTimestamp32(): number
  • Returns number

Private doTwoFactorLogin

  • doTwoFactorLogin(twoFaCode: string): Promise<any>
  • Parameters

    • twoFaCode: string

    Returns Promise<any>

Private fetchAssetData

  • fetchAssetData(): Promise<object>
  • Returns Promise<object>

Private fetchMarketData

  • fetchMarketData(): Promise<object>
  • Returns Promise<object>

getAccountBalance

  • Get AccountBalance for the given crypto currency.

    Parameters

    Returns Promise<AccountBalance>

    Example

    import { CryptoCurrency } from '@neon-exchange/api-client-typescript'
    
    const accountBalance = await nash.getAcountBalance(CryptoCurrency.ETH)
    console.log(accountBalance)

getAccountOrder

  • getAccountOrder(orderID: string): Promise<Order>
  • Get an order by ID.

    Parameters

    • orderID: string

    Returns Promise<Order>

    Example

    const order = await nash.getAccountOrder('999')
    console.log(order)

getAccountPortfolio

  • Get the AccountPortfolio for the current authenticated account.

    Parameters

    Returns Promise<AccountPortfolio>

    Example

    const accountPortfolio = await nash.getAccountPortfolio()
    console.log(accountPortfolio)

getAssetNonces

  • List all current asset nonces

    Parameters

    • assetList: string[]

    Returns Promise<GetAssetsNoncesData>

    Example

    const getNoncesData = await nash.getAssetNonces()
    console.log(getNoncesData)

getDepositAddress

  • Get the deposit address for the given crypto currency.

    Parameters

    Returns Promise<AccountDepositAddress>

    Example

    import { CryptoCurrency } from '@neon-exchange/api-client-typescript'
    
    const address = await nash.getDepositAddress(CryptoCurrency.NEO)
    console.log(address)

getMarket

  • getMarket(marketName: string): Promise<Market>
  • Get a specific Market by name.

    Parameters

    • marketName: string

    Returns Promise<Market>

    Example

    const market = await nash.getMarket('neo_gas')
    console.log(market)

getMovement

  • getMovement(movementID: number): Promise<Movement>
  • Get a Movement by the given id.

    Parameters

    • movementID: number

    Returns Promise<Movement>

    Example

    const movement = await nash.getMovement(1)
    console.log(movement)

Private getNoncesForTrade

  • Parameters

    Returns Promise<NonceSet>

getOrderBook

  • getOrderBook(marketName: string): Promise<OrderBook>
  • Get the OrderBook for the given market.

    Parameters

    • marketName: string

    Returns Promise<OrderBook>

    Example

    const orderBook = await nash.getOrderBook('neo_gas')
    console.log(orderBook.bids)

getOrdersForMovement

  • List all orders for a given movement

    Parameters

    • asset: string

    Returns Promise<GetOrdersForMovementData>

    Example

    const getOrdersForMovementData = await nash.getOrdersForMovement(unit)
    console.log(getOrdersForMovementData)

getSignAndSyncStates

  • getSignAndSyncStates(): Promise<boolean>
  • Gets Balance States, Signs Balance States, then Syncs Balance states to the server

    Returns Promise<boolean>

    Example

    const getSignSyncStates = await nash.getSignAndSyncStates()
    console.log(getSignSyncStates)

getStates

  • List all states and open orders to be signed for settlement

    Returns Promise<GetStatesData>

    Example

    const getStatesData = await nash.getStates()
    console.log(getStatesData)

getTicker

  • getTicker(marketName: string): Promise<Ticker>
  • Get a single Ticker for the given market name.

    Parameters

    • marketName: string

    Returns Promise<Ticker>

    Example

    const ticker = await nash.getTicker('neo_gas')
    console.log(ticker)

Private handleOrderError

  • handleOrderError(error: Error, signedPayload: any): any
  • Parameters

    • error: Error
    • signedPayload: any

    Returns any

listAccountBalances

  • listAccountBalances(ignoreLowBalance?: boolean): Promise<AccountBalance[]>
  • List all balances for current authenticated account.

    Parameters

    • Default value ignoreLowBalance: boolean = false

    Returns Promise<AccountBalance[]>

    Example

    const accountBalance = await nash.listAccountBalances()
    console.log(accountBalance)

listAccountOrders

  • list available orders for the current authenticated account.

    Parameters

    Returns Promise<AccountOrder>

    Example

    const accountOrder = await nash.listAccountOrders('neo_eth')
    console.log(accountOrder.orders)

listAccountTransactions

  • listAccountTransactions(cursor?: string, fiatSymbol?: string, limit?: number): Promise<AccountTransaction>
  • List available account transactions.

    Parameters

    • Optional cursor: string
    • Optional fiatSymbol: string
    • Optional limit: number

    Returns Promise<AccountTransaction>

    Example

    const accountTransaction = await nash.listAccountTransactions()
    console.log(accountTransaction.transactions)

listAccountVolumes

  • List all volumes for the current authenticated account.

    Returns Promise<AccountVolume>

    Example

    const accountVolume = await nash.listAccountVolumes()
    console.log(accountVolume.thirtyDayTotalVolumePercent)

listAssets

  • listAssets(): Promise<Asset[]>
  • Fetches as list of all available Asset that are active on the exchange.

    Returns Promise<Asset[]>

    Example

    const assets = await nash.listAssets()
    console.log(assets)

listCandles

  • List a CandleRange for the given market.

    Parameters

    Returns Promise<CandleRange>

    Example ` const candleRange = await nash.listCandles('neo_gas') console.log(candleRange)

listMarkets

  • listMarkets(): Promise<object>
  • List all available markets.

    Returns Promise<object>

    Example

    const {markets, error} = await nash.listMarkets()
    console.log(markets)

listMovements

  • List all movements for the current authenticated account.

    Parameters

    Returns Promise<Movement[]>

    Example

    const movements = await nash.listMovements()
    console.log(movements)

listTickers

  • listTickers(): Promise<Ticker[]>
  • Fetches as list of all available Ticker that are active on the exchange.

    Returns Promise<Ticker[]>

    Example

    const tickers = await nash.listTickers()
    console.log(tickers)

listTrades

  • Get TradeHistory for the given market name.

    Parameters

    Returns Promise<TradeHistory>

    Example

    const tradeHistory = await nash.listTrades('neo_gas')
    console.log(tradeHistory.trades)

login

  • login(email: string, password: string, twoFaCode?: string, walletIndices?: object, presetWallets?: object): Promise<boolean>
  • Login against the central account service. A login is required for all signed request.

    Parameters

    • email: string
    • password: string
    • Optional twoFaCode: string

      (optional)

    • Default value walletIndices: object = { neo: 1, eth: 1 }
      • [key: string]: number
    • Optional presetWallets: object

    Returns Promise<boolean>

    Example

    const email = '[email protected]`
    const password = `yourpassword`
    
    nash.login(email, password)
    .then(_ => console.log('login success'))
    .catch(e => console.log(`login failed ${e}`)

placeLimitOrder

  • Place a limit order.

    Parameters

    Returns Promise<OrderPlaced>

    Example

    import {
      createCurrencyAmount,
      createCurrencyPrice,
      OrderBuyOrSell,
      OrderCancellationPolicy
    } from '@neon-exchange/api-client-typescript'
    
    const order = await nash.placeLimitOrder(
      false,
      createCurrencyAmount('1', CryptoCurrency.NEO),
      OrderBuyOrSell.BUY,
      OrdeCancellationPolicy.GOOD_TILL_CANCELLED,
      createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
      'neo_gas'
    )
    console.log(order.status)

placeMarketOrder

  • Place a market order.

    Parameters

    • amount: CurrencyAmount
    • buyOrSell: OrderBuyOrSell
    • marketName: string
    • Optional noncesFrom: number[]
    • Optional noncesTo: number[]
    • Optional nonceOrder: number

    Returns Promise<OrderPlaced>

    Example

    import {
      createCurrencyAmount,
      OrderBuyOrSell,
    } from '@neon-exchange/api-client-typescript'
    
    const order = await nash.placeMarketOrder(
      createCurrencyAmount('1.00', CryptoCurrency.NEO),
      OrderBuyOrSell.SELL,
      'neo_gas'
    )
    console.log(order.status)

placeStopLimitOrder

  • Place a stop limit order.

    Parameters

    Returns Promise<OrderPlaced>

    Example

    import {
      createCurrencyAmount,
      createCurrencyPrice,
      OrderBuyOrSell,
      OrderCancellationPolicy
    } from '@neon-exchange/api-client-typescript'
    
    const order = await nash.placeStopLimitOrder(
      false,
      createCurrencyAmount('1', CryptoCurrency.NEO),
      OrderBuyOrSell.BUY,
      OrdeCancellationPolicy.GOOD_TILL_CANCELLED,
      createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
      'neo_gas'
      createCurrencyPrice('0.02', CryptoCurrency.GAS, CryptoCurrency.NEO)
    )
    console.log(order.status)

placeStopMarketOrder

  • Place a stop market order.

    Parameters

    Returns Promise<OrderPlaced>

    Example

    import {
      createCurrencyAmount,
      createCurrencyPrice,
      OrderBuyOrSell,
    } from '@neon-exchange/api-client-typescript'
    
    const order = await nash.placeStopLimitOrder(
      createCurrencyAmount('1', CryptoCurrency.NEO),
      OrderBuyOrSell.BUY,
      'neo_gas'
      createCurrencyPrice('0.02', CryptoCurrency.GAS, CryptoCurrency.NEO)
    )
    console.log(order.status)

signDepositRequest

Private signPayload

  • signPayload(payloadAndKind: PayloadAndKind): Promise<any>
  • helper function that returns the correct types for the needed GQL queries and mutations.

    Parameters

    • payloadAndKind: PayloadAndKind

    Returns Promise<any>

signStates

  • Submit all states and open orders to be signed for settlement

    Parameters

    Returns Promise<SignStatesData | Error>

    Example

    const signStatesResult = await nash.signStates(getStatesResult)
    console.log(signStatesResult)

signWithdrawRequest

  • Sign a withdraw request.

    Parameters

    Returns Promise<SignMovementResult>

    Example

    import { createCurrencyAmount } from '@neon-exchange/api-client-ts'
    
    const address = 'd5480a0b20e2d056720709a9538b17119fbe9fd6';
    const amount = createCurrencyAmount('1.5', CryptoCurrency.ETH);
    const signedMovement = await nash.signWithdrawRequest(address, amount);
    console.log(signedMovement)

syncStates

  • List all states and open orders to be signed for settlement

    Parameters

    Returns Promise<boolean>

    Example

    const getStatesData = await nash.getStates()
    console.log(getStatesData)

Private updateTradedAssetNonces

  • updateTradedAssetNonces(): Promise<boolean>
  • Returns Promise<boolean>

Generated using TypeDoc