Settling Fees

Now for quite possibly the entire reason you decided to get into Exchange operation, those juicy fees. Just as before, this really couldn't be easier.

So after a few trades have gone back and forth, you may have noticed that part of the object returned from the getUserTrades command was fees. In our example, these were teeny tiny little slivers of USDT, but as my old teacher said "Look after the pennies and the pounds will look after themselves" (replace with pounds and pennies with your regional currency).

So as trades get fulfilled on your exchange these fees will mount up and up, ready to be released (settled) to the admin account. Luckily, this could not be simpler.

settleFees requires a 48-hour period 'cooldown' between uses

Settling Fees Script

const Network = require('./index');

const network = new Network({
    apiUrl: '',
    apiKey: '<YOUR_API_KEY>',
    apiSecret: '<YOUR_API__SECRET_KEY>',
    activation_code: '<YOUR_ACTIVATION_CODE>',

//settling fees and seeing them
(async () => {
	try {
		//initialise the network
		const init = await network.init();
		//settle the accumulated fees since last settling
		await network.settleFees()
		//get a report on historical fee date 
		//we could add optional parameters to refine results
        	console.log(await network.getGeneratedFees())
	} catch (err) {

Transfer Assets Script: Output

       //generated fees for USDT
    [ { id: 70,
       transaction_id: '60014cde-aff0-455a-9068-ca0d0f5e6e6a',
       amount: 0.003312,
       currency: 'usdt',
       network_fee: 0.003312,
       trade_id: 330100,
       timestamp: '2022-06-27T17:48:17.884Z',
       exchange_id: 935,
       user_id: 2228 }, //this is where these fees have gone 
       //generated fees for XHT
     { id: 71,
       transaction_id: '78c16133-abba-4e84-a48c-afc29c3f4afc',
       amount: 0.003,
       currency: 'xht',
       network_fee: 0.003,
       trade_id: 330100,
       timestamp: '2022-06-27T17:48:17.884Z',
       exchange_id: 935,
       user_id: 2228 } ] }

Last updated