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

Method withdraw

python/ccxt/async_support/extended.py:1713–1777  ·  view source on GitHub ↗

make a Starknet withdrawal https://api.docs.extended.exchange/#withdrawals :param str code: unified currency code :param float amount: the amount to withdraw :param str address: the Starknet address to withdraw to :param str tag: unused :par

(self, code: str, amount: float, address: str, tag: Str = None, params={})

Source from the content-addressed store, hash-verified

1711 return await self.fetch_transactions(code, since, limit, self.extend({'type': 'WITHDRAWAL'}, params))
1712
1713 async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
1714 """
1715 make a Starknet withdrawal
1716
1717 https://api.docs.extended.exchange/#withdrawals
1718
1719 :param str code: unified currency code
1720 :param float amount: the amount to withdraw
1721 :param str address: the Starknet address to withdraw to
1722 :param str tag: unused
1723 :param dict [params]: extra parameters specific to the exchange API endpoint
1724 :param str [params.chainId]: only STRK is supported
1725 :param int [params.settlementExpiration]: settlement expiration timestamp in seconds, defaults to now + 14 days + 60 seconds
1726 :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
1727 """
1728 self.check_required_credentials()
1729 await self.load_markets()
1730 currency = self.currency(code)
1731 chainId = self.safe_string_upper_2(params, 'chainId', 'network', 'STRK')
1732 if chainId != 'STRK':
1733 raise BadRequest(self.id + ' withdraw() only supports Starknet withdrawals with chainId STRK')
1734 if len(address) <= 42:
1735 raise BadRequest(self.id + ' withdraw() requires a Starknet address for STRK withdrawals, EVM withdrawals require the bridge quote flow')
1736 account = await self.fetch_extended_account()
1737 amountString = self.currency_to_precision(code, amount)
1738 accountId = self.safe_string(account, 'accountId')
1739 settlement = self.create_withdrawal_settlement_data(address, amountString, currency, account, params)
1740 request = {
1741 'accountId': accountId,
1742 'amount': amountString,
1743 'chainId': chainId,
1744 'asset': currency['id'],
1745 'settlement': settlement,
1746 }
1747 params = self.omit(params, ['chainId', 'network', 'settlementExpiration', 'nonce', 'recipient', 'positionId', 'l2Vault', 'collateralId', 'resolution'])
1748 response = await self.v1PrivatePostUserWithdrawal(self.extend(request, params))
1749 #
1750 # {
1751 # "status": "OK",
1752 # "data": 1820796462590083072
1753 # }
1754 #
1755 now = self.milliseconds()
1756 return {
1757 'info': response,
1758 'id': self.safe_string(response, 'data'),
1759 'txid': None,
1760 'timestamp': now,
1761 'datetime': self.iso8601(now),
1762 'address': address,
1763 'addressFrom': None,
1764 'addressTo': address,
1765 'tag': tag,
1766 'tagFrom': None,
1767 'tagTo': tag,
1768 'type': 'withdrawal',
1769 'amount': self.parse_number(amountString),
1770 'currency': currency['code'],

Callers

nothing calls this directly

Calls 15

load_marketsMethod · 0.95
BadRequestClass · 0.90
safe_string_upper_2Method · 0.80
currency_to_precisionMethod · 0.80
safe_stringMethod · 0.80
parse_numberMethod · 0.80
currencyMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected