MCPcopy Create free account
hub / github.com/ccxt/ccxt / transferBetweenMainAndSubAccount

Method transferBetweenMainAndSubAccount

js/src/cex.js:1584–1618  ·  view source on GitHub ↗
(code, amount, fromAccount, toAccount, params = {})

Source from the content-addressed store, hash-verified

1582 return transfer;
1583 }
1584 async transferBetweenMainAndSubAccount(code, amount, fromAccount, toAccount, params = {}) {
1585 await this.loadMarkets();
1586 const currency = this.currency(code);
1587 const fromMain = (fromAccount === '');
1588 const targetAccount = fromMain ? toAccount : fromAccount;
1589 const guid = this.safeString(params, 'guid', this.uuid());
1590 const request = {
1591 'currency': currency['id'],
1592 'amount': this.currencyToPrecision(code, amount),
1593 'accountId': targetAccount,
1594 'clientTxId': guid,
1595 };
1596 let response = undefined;
1597 if (fromMain) {
1598 response = await this.privatePostDoDepositFundsFromWallet(this.extend(request, params));
1599 }
1600 else {
1601 response = await this.privatePostDoWithdrawalFundsToWallet(this.extend(request, params));
1602 }
1603 // both endpoints return the same structure, the only difference is that
1604 // the "accountId" is filled with the "subAccount"
1605 //
1606 // {
1607 // "ok": "ok",
1608 // "data": {
1609 // "accountId": "sub1",
1610 // "clientTxId": "27ba8284-67cf-4386-9ec7-80b3871abd45",
1611 // "currency": "USDT",
1612 // "status": "approved"
1613 // }
1614 // }
1615 //
1616 const data = this.safeDict(response, 'data', {});
1617 return this.parseTransfer(data, currency);
1618 }
1619 async transferBetweenSubAccounts(code, amount, fromAccount, toAccount, params = {}) {
1620 await this.loadMarkets();
1621 const currency = this.currency(code);

Callers 1

transferMethod · 0.95

Calls 10

parseTransferMethod · 0.95
loadMarketsMethod · 0.45
currencyMethod · 0.45
safeStringMethod · 0.45
uuidMethod · 0.45
currencyToPrecisionMethod · 0.45
extendMethod · 0.45
safeDictMethod · 0.45

Tested by

no test coverage detected