transfer currency internally between wallets on the same account :param str code: unified currency code :param float amount: amount to transfer :param str fromAccount: account to transfer from(spot, perp) :param str toAccount: account to transfer to(spot, per
(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})
| 2289 | return self.safe_string(timeInForces, str(tifInteger)) |
| 2290 | |
| 2291 | def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry: |
| 2292 | """ |
| 2293 | transfer currency internally between wallets on the same account |
| 2294 | :param str code: unified currency code |
| 2295 | :param float amount: amount to transfer |
| 2296 | :param str fromAccount: account to transfer from(spot, perp) |
| 2297 | :param str toAccount: account to transfer to(spot, perp) |
| 2298 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2299 | :param str [params.accountIndex]: account index |
| 2300 | :param str [params.toAccountIndex]: to account index, defaults to fromAccountIndex |
| 2301 | :param str [params.apiKeyIndex]: api key index |
| 2302 | :param str [params.memo]: hex encoding memo |
| 2303 | :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>` |
| 2304 | """ |
| 2305 | self.load_markets() |
| 2306 | apiKeyIndex = None |
| 2307 | apiKeyIndex, params = self.handle_api_key_index(params, 'transfer', 'apiKeyIndex', 'api_key_index') |
| 2308 | accountIndex = None |
| 2309 | accountIndex, params = self.handle_account_index(params, 'transfer', 'accountIndex', 'account_index') |
| 2310 | toAccountIndex = None |
| 2311 | toAccountIndex, params = self.handle_option_and_params_2(params, 'transfer', 'toAccountIndex', 'to_account_index', accountIndex) |
| 2312 | strAccountIndex = self.number_to_string(accountIndex) |
| 2313 | strApiKeyIndex = self.number_to_string(apiKeyIndex) |
| 2314 | signer = self.load_account(self.options['chainId'], self.get_lighter_private_key(strAccountIndex, strApiKeyIndex), strApiKeyIndex, strAccountIndex, params) |
| 2315 | currency = self.currency(code) |
| 2316 | if currency['code'] == 'USDC': |
| 2317 | amount = self.parse_to_int(Precise.string_mul(self.pow('10', '6'), self.currency_to_precision(code, amount))) |
| 2318 | elif currency['code'] == 'ETH': |
| 2319 | amount = self.parse_to_int(Precise.string_mul(self.pow('10', '8'), self.currency_to_precision(code, amount))) |
| 2320 | else: |
| 2321 | raise ExchangeError(self.id + ' transfer() only supports USDC and ETH transfers') |
| 2322 | fromRouteType = 0 if (fromAccount == 'perp') else 1 # 0: perp, 1: spot |
| 2323 | toRouteType = 0 if (toAccount == 'perp') else 1 |
| 2324 | memo = self.safe_string(params, 'memo', '0x000000000000000000000000000000') |
| 2325 | params = self.omit(params, ['memo']) |
| 2326 | nonce = self.fetch_nonce(accountIndex, apiKeyIndex, params) |
| 2327 | signRaw = { |
| 2328 | 'to_account_index': toAccountIndex, |
| 2329 | 'asset_index': self.parse_to_int(currency['id']), |
| 2330 | 'from_route_type': fromRouteType, |
| 2331 | 'to_route_type': toRouteType, |
| 2332 | 'amount': amount, |
| 2333 | 'usdc_fee': 0, |
| 2334 | 'memo': memo, |
| 2335 | 'nonce': nonce, |
| 2336 | 'api_key_index': apiKeyIndex, |
| 2337 | 'account_index': accountIndex, |
| 2338 | } |
| 2339 | txType, txInfo = self.lighter_sign_transfer(signer, self.extend(signRaw, params)) |
| 2340 | request = { |
| 2341 | 'tx_type': txType, |
| 2342 | 'tx_info': txInfo, |
| 2343 | } |
| 2344 | response = self.publicPostSendTx(request) |
| 2345 | return self.parse_transfer(response) |
| 2346 | |
| 2347 | def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]: |
| 2348 | """ |
nothing calls this directly
no test coverage detected