Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

Hierarchy

  • Client

Index

Constructors

constructor

  • Create a new instance of Client

    Parameters

    Returns Client

    Example

    import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
    
    const nash = new Client(EnvironmentConfiguration.sandbox)

Properties

apiKey

apiKey: APIKey
internal

assetData

assetData: {}
internal

Type declaration

  • [key: string]: AssetData

marketData

marketData: {}
internal

Type declaration

  • [key: string]: Market

nashProtocolMarketData

nashProtocolMarketData: ReturnType<typeof mapMarketsForNashProtocol>
internal

perfClient

perfClient: PerfClient
internal

Accessors

affiliateDeveloperCode

  • get affiliateDeveloperCode(): string

subscriptions

  • get subscriptions(): NashSocketEvents
  • Returns the connect socket

    Returns NashSocketEvents

    Example

    import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
    
    const nash = new Client(EnvironmentConfiguration.sandbox)
    await nash.login(...)
    
    // Getting the orderbook for the neo_eth marked
    nash.subscriptions.onUpdatedOrderbook(
     { marketName: 'neo_eth' },
     {
       onResult: ({
         data: {
           updatedOrderBook: { bids, asks }
         }
       }) => {
         console.log(`updated bids ${bids.length}`)
         console.log(`updated asks ${asks.length}`)
       }
     }
    )
    
    // Getting the user orderobok for all markets
    nash.subscriptions.onUpdatedAccountOrders(
     {},
     {
       onResult: ({
         data: {
           updatedAccountOrders
         }
       }) => {
         console.log(`Updated orders: {updatedAccountOrders.length}`)
       }
     }
    )
    

Methods

approveAndAwaitAllowance

  • approveAndAwaitAllowance(amount: CurrencyAmount, targetAddress: string, feeLevel?: "low" | "med" | "high"): Promise<boolean>
  • Parameters

    • amount: CurrencyAmount
    • targetAddress: string
    • Default value feeLevel: "low" | "med" | "high" = "med"

    Returns Promise<boolean>

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)

cancelAndPlaceOrders

  • cancelAndPlaceOrders(orderIDs: string[], marketName: string, orders: PlaceLimitOrderParams[]): Promise<OrdersCancelledAndPlaced>
  • Cancel a list of orders by ID.

    Parameters

    • orderIDs: string[]
    • marketName: string
    • orders: PlaceLimitOrderParams[]

    Returns Promise<OrdersCancelledAndPlaced>

    Example

    const cancelledOrders = await nash.cancelOrder(['11','12'])
    console.log(cancelledOrders)

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)

cancelOrders

  • cancelOrders(orderIDs: string[], marketName: string): Promise<CancelledOrder[]>
  • Cancel a list of orders by ID.

    Parameters

    • orderIDs: string[]
    • marketName: string

    Returns Promise<CancelledOrder[]>

    Example

    const cancelledOrders = await nash.cancelOrder(['11','12'])
    console.log(cancelledOrders)

createApiKey

  • createApiKey(name: string, password: string, walletIndices: any, network?: "LocalNet" | "MainNet", twoFaCode?: string): Promise<CreateApiKeyResult>
  • Parameters

    • name: string
    • password: string
    • walletIndices: any
    • Default value network: "LocalNet" | "MainNet" = "LocalNet"
    • Optional twoFaCode: string

    Returns Promise<CreateApiKeyResult>

createSocketConnection

  • createSocketConnection(): NashSocketEvents
  • Sets up a websocket and authenticates it using the current token.

    Returns NashSocketEvents

    Example

    import { Client, EnvironmentConfiguration } from '@neon-exchange/api-client-typescript'
    
    const nash = new Client(EnvironmentConfiguration.sandbox)
    await nash.login(...)
    
    const connection = nash.createSocketConnection()
    
    // Getting the orderbook for the neo_eth marked
    connection.onUpdatedOrderbook(
     { marketName: 'neo_eth' },
     {
       onResult: ({
         data: {
           updatedOrderBook: { bids, asks }
         }
       }) => {
         console.log(`updated bids ${bids.length}`)
         console.log(`updated asks ${asks.length}`)
       }
     }
    )
    
    // Getting the user orderobok for all markets
    connection.onUpdatedAccountOrders(
     {},
     {
       onResult: ({
         data: {
           updatedAccountOrders
         }
       }) => {
         console.log(`Updated orders: {updatedAccountOrders.length}`)
       }
     }
    )
    
    
    @deprecated please use subscriptions

depositToTradingContract

  • depositToTradingContract(quantity: CurrencyAmount, feeLevel?: "low" | "medium" | "high"): PromiEvent<{ movementId: string; txId: string }>
  • Parameters

    • quantity: CurrencyAmount
    • Default value feeLevel: "low" | "medium" | "high" = "medium"

    Returns PromiEvent<{ movementId: string; txId: string }>

disconnect

  • disconnect(): void

getAccountAddress

  • getAccountAddress(currency: CryptoCurrency): Promise<GetAccountAddressResult["getAccountAddress"]>
  • Get the deposit address for the given crypto currency.

    Parameters

    • currency: CryptoCurrency

    Returns Promise<GetAccountAddressResult["getAccountAddress"]>

    Example

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

getAccountBalance

  • getAccountBalance(currency: CryptoCurrency): Promise<AccountBalance>
  • Get [[AccountBalance]] for the given crypto currency.

    Parameters

    • currency: CryptoCurrency

    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

  • getAccountPortfolio(__namedParameters?: { fiatSymbol: FiatCurrency; period: Period }): Promise<AccountPortfolio>
  • Get the [[AccountPortfolio]] for the current authenticated account.

    Parameters

    • Default value __namedParameters: { fiatSymbol: FiatCurrency; period: Period } = {}
      • fiatSymbol: FiatCurrency
      • period: Period

    Returns Promise<AccountPortfolio>

    Example

    const accountPortfolio = await nash.getAccountPortfolio({
      fiatSymbol: "USD",
    
    })
    console.log(accountPortfolio)

getAccountVolumes

  • getAccountVolumes(): Promise<AccountVolume>
  • Fetches the current account volumes for the current periods

    Returns Promise<AccountVolume>

    Example

    const volumes = await nash.getAccountVolumes()
    console.log(volumes.makerFeeRate)
    console.log(volumes.takerFeeRate)

getAssetNonces

  • getAssetNonces(assetList: string[]): Promise<AssetsNoncesData[]>
  • List all current asset nonces

    Parameters

    • assetList: string[]

    Returns Promise<AssetsNoncesData[]>

    Example

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

getBtcAddress

  • getBtcAddress(): string

getDepositAddress

  • getDepositAddress(currency: CryptoCurrency): Promise<GetAccountAddressResult["getAccountAddress"]>
  • deprecated

    will be removed in next major version use getAccountAddress

    Parameters

    • currency: CryptoCurrency

    Returns Promise<GetAccountAddressResult["getAccountAddress"]>

    [description]

getEthAddress

  • getEthAddress(): string

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: string): Promise<Movement>
  • Get a [[Movement]] by the given id.

    Parameters

    • movementID: string

    Returns Promise<Movement>

    Example

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

getNeoAddress

  • getNeoAddress(): string

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)

getSignAndSyncStates

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

    Parameters

    • Default value sync: boolean = false

      Whether to sync the state updates to the blockchain. Defaults to false

    Returns Promise<SyncStatesData | SignStatesData>

    Example

    // sign states
    const signStates = await nash.getSignAndSyncStates()
    console.log(signStates)
    
    // sign and sync states to blockchain
    const signAndSyncStates = await nash.getSignAndSyncStates(true)
    console.log(signAndSyncStates)
    

getSocket

  • getSocket(): any

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)

isMovementCompleted

  • isMovementCompleted(movementId: string): Promise<boolean>
  • Parameters

    • movementId: string

    Returns Promise<boolean>

listAccountBalances

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

    Parameters

    • ignoreLowBalance: any

    Returns Promise<AccountBalance[]>

    Example

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

listAccountOrders

  • listAccountOrders(__namedParameters?: { before: string; buyOrSell: OrderBuyOrSell; limit: number; marketName: string; rangeStart: string; rangeStop: string; shouldIncludeTrades: boolean; status: [OrderStatus]; type: [OrderType] }): Promise<AccountOrder>
  • list available orders for the current authenticated account.

    Parameters

    • Default value __namedParameters: { before: string; buyOrSell: OrderBuyOrSell; limit: number; marketName: string; rangeStart: string; rangeStop: string; shouldIncludeTrades: boolean; status: [OrderStatus]; type: [OrderType] } = {}
      • before: string
      • buyOrSell: OrderBuyOrSell
      • limit: number
      • marketName: string
      • rangeStart: string
      • rangeStop: string
      • shouldIncludeTrades: boolean
      • status: [OrderStatus]
      • type: [OrderType]

    Returns Promise<AccountOrder>

    Example

    const accountOrder = await nash.listAccountOrders({
      marketName : 'neo_eth'
    })
    console.log(accountOrder.orders)

listAccountTrades

  • listAccountTrades(__namedParameters?: { before: string; limit: number; marketName: string }): Promise<TradeHistory>
  • list available trades for the current authenticated account.

    Parameters

    • Default value __namedParameters: { before: string; limit: number; marketName: string } = {}
      • before: string
      • limit: number
      • marketName: string

    Returns Promise<TradeHistory>

    Example

    const tradeHistory = await nash.listAccountTrades({
      limit : 10,
      marketName : 'neo_eth'
    })
    console.log(tradeHistory.trades)

listAccountTransactions

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

    Parameters

    • Default value __namedParameters: { cursor: string; fiatSymbol: string; limit: number } = {}
      • cursor: string
      • fiatSymbol: string
      • limit: number

    Returns Promise<AccountTransaction>

    Example

    const accountTransaction = await nash.listAccountTransactions({
      limit : 150,
      ${paramName} : ${paramValue}
    })
    console.log(accountTransaction.transactions)

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

  • listCandles(__namedParameters: { before: string; interval: CandleInterval; limit: number; marketName: string }): Promise<CandleRange>
  • List a [[CandleRange]] for the given market.

    Parameters

    • __namedParameters: { before: string; interval: CandleInterval; limit: number; marketName: string }
      • before: string
      • interval: CandleInterval
      • limit: number
      • marketName: string

    Returns Promise<CandleRange>

    Example

    const candleRange = await nash.listCandles({
      marketName : 'neo_gas'
    })
    console.log(candleRange)
    ``

listMarkets

  • listMarkets(): Promise<Market[]>
  • List all available markets.

    Returns Promise<Market[]>

    Example

    const markets = await nash.listMarkets()
    console.log(markets)

listMovements

  • listMovements(__namedParameters: { currency: string | CryptoCurrency[]; status: MovementStatus; type: "DEPOSIT" | "WITHDRAWAL" | "TRANSFER" }): Promise<Movement[]>
  • List all movements for the current authenticated account.

    Parameters

    • __namedParameters: { currency: string | CryptoCurrency[]; status: MovementStatus; type: "DEPOSIT" | "WITHDRAWAL" | "TRANSFER" }
      • currency: string | CryptoCurrency[]
      • status: MovementStatus
      • type: "DEPOSIT" | "WITHDRAWAL" | "TRANSFER"

    Returns Promise<Movement[]>

    Example

    const movements = await nash.listMovements({
      currency : 'eth'
    })
    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

  • listTrades(__namedParameters: { before: string; limit: number; marketName: string }): Promise<TradeHistory>
  • Get [[TradeHistory]] for the given market name.

    Parameters

    • __namedParameters: { before: string; limit: number; marketName: string }
      • before: string
      • limit: number
      • marketName: string

    Returns Promise<TradeHistory>

    Example

    const tradeHistory = await nash.listTrades({
      marketname : 'neo_gas'
    })
    console.log(tradeHistory.trades)

login

  • login(__namedParameters: { apiKey: string; secret: string }): Promise<void>
  • Login using an API key.

    request.

    Parameters

    • __namedParameters: { apiKey: string; secret: string }
      • apiKey: string

        string

      • secret: string

        string

    Returns Promise<void>

passwordLogin

  • passwordLogin(__namedParameters: { email: string; net: string; password: string; salt: string; twoFaCode: string; walletIndices: object }): Promise<Config>
  • Legacy login against the central account service. Note: you should prefer to use an API key with the login method.

    Be careful about using this feature, private keys are derived using the password. So this technically gives full access to the account. Because of this the following features are not supported using legacy login.

    • transferToExternal
    • depositToTradingContract
    • withdrawFromTradingContract

    Parameters

    • __namedParameters: { email: string; net: string; password: string; salt: string; twoFaCode: string; walletIndices: object }
      • email: string

        string

      • net: string
      • password: string

        string

      • salt: string
      • twoFaCode: string

        string

      • walletIndices: object
        • btc: number
        • eth: number
        • neo: number

    Returns Promise<Config>

    Example

    try {
      nash.passwordLogin({
        email: "email@domain.com",
        password: "example"
      })
    } catch (e) {
      console.error(`login failed ${e}`)
    }

placeLimitOrder

  • placeLimitOrder(allowTaker: boolean, amount: CurrencyAmount, buyOrSell: OrderBuyOrSell, cancellationPolicy: OrderCancellationPolicy, limitPrice: CurrencyPrice, marketName: string, cancelAt?: DateTime): Promise<OrderPlaced>
  • Place a limit order.

    Parameters

    • allowTaker: boolean
    • amount: CurrencyAmount
    • buyOrSell: OrderBuyOrSell
    • cancellationPolicy: OrderCancellationPolicy
    • limitPrice: CurrencyPrice
    • marketName: string
    • Optional cancelAt: DateTime

    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,
      OrderCancellationPolicy.GOOD_TIL_CANCELLED,
      createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
      'neo_gas'
    )
    console.log(order.status)

placeLimitOrders

  • placeLimitOrders(params: PlaceLimitOrderParams[]): Promise<OrdersPlaced>
  • Parameters

    • params: PlaceLimitOrderParams[]

    Returns Promise<OrdersPlaced>

placeMarketOrder

  • placeMarketOrder(amount: CurrencyAmount, buyOrSell: OrderBuyOrSell, marketName: string): Promise<OrderPlaced>
  • Place a market order.

    Parameters

    • amount: CurrencyAmount
    • buyOrSell: OrderBuyOrSell
    • marketName: string

    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

  • placeStopLimitOrder(allowTaker: boolean, amount: CurrencyAmount, buyOrSell: OrderBuyOrSell, cancellationPolicy: OrderCancellationPolicy, limitPrice: CurrencyPrice, marketName: string, stopPrice: CurrencyPrice, cancelAt?: DateTime): Promise<OrderPlaced>
  • Place a stop limit order.

    Parameters

    • allowTaker: boolean
    • amount: CurrencyAmount
    • buyOrSell: OrderBuyOrSell
    • cancellationPolicy: OrderCancellationPolicy
    • limitPrice: CurrencyPrice
    • marketName: string
    • stopPrice: CurrencyPrice
    • Optional cancelAt: DateTime

    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,
      OrderCancellationPolicy.GOOD_TIL_CANCELLED,
      createCurrencyPrice('0.01', CryptoCurrency.GAS, CryptoCurrency.NEO),
      'neo_gas'
      createCurrencyPrice('0.02', CryptoCurrency.GAS, CryptoCurrency.NEO)
    )
    console.log(order.status)

placeStopMarketOrder

  • placeStopMarketOrder(amount: CurrencyAmount, buyOrSell: OrderBuyOrSell, marketName: string, stopPrice: CurrencyPrice): Promise<OrderPlaced>
  • Place a stop market order.

    Parameters

    • amount: CurrencyAmount
    • buyOrSell: OrderBuyOrSell
    • marketName: string
    • stopPrice: CurrencyPrice

    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)

prefillRPoolIfNeeded

  • prefillRPoolIfNeeded(blockchain: Blockchain): Promise<void>
  • Parameters

    • blockchain: Blockchain

    Returns Promise<void>

prefillRPoolIfNeededForAssets

  • prefillRPoolIfNeededForAssets(asset1: CryptoCurrency, asset2?: CryptoCurrency): Promise<void>
  • Parameters

    • asset1: CryptoCurrency
    • Optional asset2: CryptoCurrency

    Returns Promise<void>

sendBlockchainRawTransaction

  • sendBlockchainRawTransaction(params: { blockchain: SendBlockchainRawTransactionArgs["payload"]["blockchain"]; payload: SendBlockchainRawTransactionArgs["payload"]["transactionPayload"] }): Promise<string>
  • Parameters

    • params: { blockchain: SendBlockchainRawTransactionArgs["payload"]["blockchain"]; payload: SendBlockchainRawTransactionArgs["payload"]["transactionPayload"] }
      • blockchain: SendBlockchainRawTransactionArgs["payload"]["blockchain"]
      • payload: SendBlockchainRawTransactionArgs["payload"]["transactionPayload"]

    Returns Promise<string>

signStates

  • signStates(getStatesData: GetStatesData, depth?: number): Promise<SignStatesData>
  • Submit all states and open orders to be signed for settlement

    Parameters

    • getStatesData: GetStatesData
    • Default value depth: number = 0

    Returns Promise<SignStatesData>

    Example

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

syncStates

  • syncStates(signStatesData: SignStatesData): Promise<SyncStatesData>
  • List all states and open orders to be signed for settlement

    Parameters

    • signStatesData: SignStatesData

    Returns Promise<SyncStatesData>

    Example

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

transferToExternal

  • transferToExternal(params: { address: string; quantity: CurrencyAmount }): Promise<{ gasUsed?: CurrencyAmount; txId: string }>
  • Parameters

    • params: { address: string; quantity: CurrencyAmount }
      • address: string
      • quantity: CurrencyAmount

    Returns Promise<{ gasUsed?: CurrencyAmount; txId: string }>

withdrawFromTradingContract

  • withdrawFromTradingContract(quantity: CurrencyAmount, feeLevel?: "low" | "medium" | "high"): PromiEvent<{ movementId: string; txId: string }>
  • Parameters

    • quantity: CurrencyAmount
    • Default value feeLevel: "low" | "medium" | "high" = "medium"

    Returns PromiEvent<{ movementId: string; txId: string }>

Generated using TypeDoc