Skip to content

Commit 1fb15b4

Browse files
authored
added support for Universal Transfers #637 by updatesvc
2 parents 146451f + 0682e75 commit 1fb15b4

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,13 @@ binance.withdraw("XMR", address, amount, addressTag);
18361836
binance.withdraw("BTC", "1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa", 0.2);
18371837
```
18381838
1839+
### Univeral Transfer / Internal Wallet Transfer
1840+
Example Spot account transfer to USDⓈ-M Futures account , use ENUM -> "MAIN_UMFUTURE"
1841+
```js
1842+
console.info( await binance.universalTransfer("MAIN_UMFUTURE","USDT",10) );
1843+
```
1844+
for more account transfers (ENUMs) see [docs](https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer)
1845+
18391846
# Binance Margin API
18401847
18411848
#### Transfer from Main account to Margin account

node-binance-api.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,44 @@ let api = function Binance( options = {} ) {
21382138
Binance.options.log( "Unexpected userDeliveryData: " + type );
21392139
}
21402140
};
2141+
2142+
/**
2143+
* Universal Transfer requires API permissions enabled
2144+
* @param {string} type - ENUM , example MAIN_UMFUTURE for SPOT to USDT futures, see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer
2145+
* @param {string} asset - the asset - example :USDT *
2146+
* @param {number} amount - the callback function
2147+
* @param {function} callback - the callback function
2148+
* @return {promise}
2149+
*/
2150+
const universalTransfer = (type, asset, amount, callback = false) => {
2151+
let parameters = Object.assign({
2152+
asset,
2153+
amount,
2154+
type,
2155+
});
2156+
if (!callback) {
2157+
return new Promise((resolve, reject) => {
2158+
signedRequest(
2159+
sapi + "v1/asset/transfer",
2160+
parameters,
2161+
function (error, data) {
2162+
if (error) return reject(error);
2163+
return resolve(data);
2164+
},
2165+
"POST"
2166+
);
2167+
});
2168+
}
2169+
signedRequest(
2170+
sapi + "v1/asset/transfer",
2171+
parameters,
2172+
function (error, data) {
2173+
if (callback) return callback(error, data);
2174+
},
2175+
"POST"
2176+
);
2177+
2178+
}
21412179

21422180
/**
21432181
* Transfer between main account and futures/delivery accounts
@@ -4586,6 +4624,16 @@ let api = function Binance( options = {} ) {
45864624
if ( callback ) return callback( error, data );
45874625
}, 'POST' );
45884626
},
4627+
/**
4628+
* Universal Transfer requires API permissions enabled
4629+
* @param {string} type - ENUM , example MAIN_UMFUTURE for SPOT to USDT futures, see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer
4630+
* @param {string} asset - the asset - example :USDT
4631+
* @param {number} amount - the callback function
4632+
* @param {function} callback - the callback function (optionnal)
4633+
* @return {promise}
4634+
*/
4635+
universalTransfer: (type, asset, amount, callback) =>
4636+
universalTransfer(type, asset, amount, callback),
45894637

45904638
/**
45914639
* Transfer from main account to delivery account

0 commit comments

Comments
 (0)