'use strict'

const runExample = require('../util/run_example')

module.exports = runExample({
  name: 'rest-wallet',
  rest: { env: true, transform: true }
}, async ({ rest, debug }) => {
  debug('Submitting new order...')

  // get new deposit address
  const address = await rest.getDepositAddress({
    wallet: 'exchange',
    method: 'bitcoin',
    opRenew: 0
  })

  debug(`new wallet address ${address}`)

  // transfer between accounts
  const transferConfirmation = await rest.transfer({
    from: 'exchange',
    to: 'margin',
    amount: 10,
    currency: 'BTC',
    currencyTo: 'BTC'
  })

  debug('transfer confirmed: %j', transferConfirmation)

  // withdraw
  const withdrawalConfirmation = await rest.withdraw({
    wallet: 'exchange',
    method: 'bitcoin',
    amount: 2,
    address: '1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL'
  })

  debug('withdraw confirmed: %j', withdrawalConfirmation)
})

@@ -17,176 +17,230 @@
 nst 
-runExample = require('../util/run_example')%0A%0Amodule.exports = runExample(%7B%0A  name: 'rest-wallet',%0A  rest: %7B env: true, transform: true %7D%0A%7D, async (%7B rest, debug %7D) =%3E %7B
+%7B RESTv2 %7D = require('bfx-api-node-rest')%0Aconst %7B args: %7B apiKey, apiSecret %7D, debug %7D = require('../util/setup')%0A%0Aasync function execute () %7B%0A  const rest = new RESTv2(%7B%0A    apiKey,%0A    apiSecret,%0A    transform: true%0A  %7D)
 %0A  d
@@ -952,10 +952,20 @@
 ation)%0A%7D
+%0A%0Aexecute(
 )%0A

update 'wallet' example