This is my route:
router.post('/withdraw', async (req, res, next) => {
const {code, address, amount, otpToken, currency } = req.body;
const exchange = await new ccxt.bitmex();
exchange.apiKey = "MY - KEY";
exchange.secret = "MY - SECRET";
await exchange.withdraw (code, amount, address, tag = undefined, params = {}, otpToken)
.then((response) => console.log(res))
.catch(ex => console.log(ex))
});
And this is what i am trying to post:
{
"address": "THE ADRESS",
"amount": 0.0022,
"code": "BTC",
"otpToken": "MY TOKEN"
}
When i execute this route, i get this error:
BadRequest: bitmex {"error":{"message":"amount is invalid","name":"HTTPError"}}
The key and the secret are OK. The otpToken too. I can fetch everything. I´m new on this, and i can´t figure it out where is the error on my code.
Thank you!!
The ccxt Team answer my question. This is the answer that works for me:
I think BitMEX requires the amount in satoshis (an integer, not a floating point decimal). So, instead of "amount": 0.0022 it should be "amount": 220000.