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

Method transfer

python/ccxt/extended.py:1818–1883  ·  view source on GitHub ↗

transfer collateral between sub-accounts associated with the same wallet https://api.docs.extended.exchange/#create-transfer :param str code: unified currency code :param float amount: the amount to transfer :param str fromAccount: source account id, defaul

(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})

Source from the content-addressed store, hash-verified

1816 return self.parse_transfers(result, currency, since, limit)
1817
1818 def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1819 """
1820 transfer collateral between sub-accounts associated with the same wallet
1821
1822 https://api.docs.extended.exchange/#create-transfer
1823
1824 :param str code: unified currency code
1825 :param float amount: the amount to transfer
1826 :param str fromAccount: source account id, defaults to the authenticated account id
1827 :param str toAccount: destination account id
1828 :param dict [params]: extra parameters specific to the exchange API endpoint
1829 :param str params['toVault']: destination account L2 vault
1830 :param str params['toL2Key']: destination account L2 public key
1831 :param int [params.settlementExpiration]: settlement expiration timestamp in seconds, defaults to now + 21 days
1832 :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
1833 """
1834 self.check_required_credentials()
1835 self.load_markets()
1836 currency = self.currency(code)
1837 account = self.fetch_extended_account()
1838 currentAccountId = self.safe_string(account, 'accountId')
1839 if fromAccount is None:
1840 fromAccount = currentAccountId
1841 elif fromAccount != currentAccountId:
1842 raise BadRequest(self.id + ' transfer() can only transfer from the authenticated account')
1843 toVault = self.safe_string_2(params, 'toVault', 'receiverPositionId')
1844 toL2Key = self.safe_string_2(params, 'toL2Key', 'receiverPublicKey')
1845 if (toAccount is None) or (toVault is None) or (toL2Key is None):
1846 raise ArgumentsRequired(self.id + ' transfer() requires a toAccount argument and params["toVault"] and params["toL2Key"]')
1847 amountString = self.currency_to_precision(code, amount)
1848 settlement = self.create_transfer_settlement_data(amountString, currency, account, toVault, toL2Key, params)
1849 request = {
1850 'fromAccount': fromAccount,
1851 'toAccount': toAccount,
1852 'amount': amountString,
1853 'transferredAsset': currency['id'],
1854 'settlement': settlement,
1855 }
1856 params = self.omit(params, ['fromVault', 'senderPositionId', 'fromL2Key', 'senderPublicKey', 'toVault', 'receiverPositionId', 'toL2Key', 'receiverPublicKey', 'settlementExpiration', 'nonce', 'assetId', 'collateralId', 'resolution'])
1857 response = self.v1PrivatePostUserTransfer(self.extend(request, params))
1858 #
1859 # {
1860 # "status": "OK",
1861 # "data": {
1862 # "validSignature": True,
1863 # "id": 1820778187672010752
1864 # }
1865 # }
1866 #
1867 data = self.safe_dict(response, 'data', {})
1868 validSignature = self.safe_bool(data, 'validSignature')
1869 now = self.milliseconds()
1870 status = 'pending'
1871 if validSignature is not None:
1872 status = 'ok' if validSignature else 'failed'
1873 return {
1874 'info': response,
1875 'id': self.safe_string(data, 'id'),

Callers

nothing calls this directly

Calls 15

load_marketsMethod · 0.95
BadRequestClass · 0.90
ArgumentsRequiredClass · 0.90
safe_stringMethod · 0.80
safe_string_2Method · 0.80
currency_to_precisionMethod · 0.80
safe_dictMethod · 0.80
safe_boolMethod · 0.80
parse_numberMethod · 0.80

Tested by

no test coverage detected