dydxprotocol / dydx-v3-python

Python client for dYdX (API v3)
Apache License 2.0
304 stars 174 forks source link

Python-only onboarding fails at source_client.eth.transfer_token with ERC20: transfer amount exceeds balance #222

Open drtruber opened 6 months ago

drtruber commented 6 months ago

I'm trying to do onboarding and initial account funding using dydx-v3-python client only, without connecting external wallet (such as Metamask) to dydx website for initial deposit.

I'm stuck with the following snippet from integration_tests/test_integration.py:

    # Fund the new user with ETH and USDC.
    fund_eth_hash = source_client.eth.transfer_eth(
        to_address=ethereum_address,
        human_amount=0.001,
    )
    fund_usdc_hash = source_client.eth.transfer_token(
        to_address=ethereum_address,
        human_amount=2,
    )
    print('Waiting for funds...')
    source_client.eth.wait_for_tx(fund_eth_hash)
    source_client.eth.wait_for_tx(fund_usdc_hash)
    print('...done.')

First transaction succeeds, and the second (transfer_token) always fails with error: Fail with error 'ERC20: transfer amount exceeds balance'

Source ethereum address definitely has enough balance, and I tried to play with both amounts, but the second transaction always fails

Please advise what I'm doing incorrectly, or maybe there is an issue with the code, since test_integration.py was last updated more than 2 years ago

Thank you