Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for invalid balance in crash reporting, and add message to exception if detected #964

Merged
merged 8 commits into from
Oct 10, 2023

Conversation

slundqui
Copy link
Contributor

@slundqui slundqui commented Oct 10, 2023

Example crash report with invalid balance:

23-10-10 13:55:46: CRITICAL: crash_report.log_hyperdrive_crash_report:
Exception: ContractLogicError('Invalid balance: ADD_LIQUIDITY for 100.0 BASE, balance of 2.0 BASE.', 'execution reverted: ERC20: transfer amount exceeds balance', "ContractLogicError raised.\nfunction name: addLiquidity\nfunction args: (100000000000000000000, 1, 1000000000000000000, '0x67A482359272F82eeC03f22d57159153b0393654', True)")
Trade: {
    "market_type": "HYPERDRIVE",
    "action_type": "ADD_LIQUIDITY",
    "trade_amount": "100.0",
    "slippage_tolerance": null,
    "maturity_time": 604800
}
Wallet: {
    "base": "2.0",
    "longs": [],
    "shorts": [],
    "lp_tokens": "0.0",
    "withdraw_shares": "0.0"
}
PoolInfo: {
    "shareReserves": "100000708.097555106279179522",
    "shareAdjustment": "0.0",
    "bondReserves": "102179718.722304771550574976",
    "lpTotalSupply": "100000698.097555106279179522",
    "sharePrice": "1.000160239304484342",
    "longsOutstanding": "0.0",
    "longAverageMaturityTime": "0.0",
    "shortsOutstanding": "0.0",
    "shortAverageMaturityTime": "0.0",
    "withdrawalSharesReadyToWithdraw": "0.0",
    "withdrawalSharesProceeds": "0.0",
    "lpSharePrice": "1.000160239304484341",
    "longExposure": "0.0",
    "timestamp": "2023-10-10 20:55:47",
    "blockNumber": 59,
    "totalSupplyWithdrawalShares": 0
}
PoolConfig: {
    "baseToken": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
    "initialSharePrice": "1.0",
    "minimumShareReserves": "10.0",
    "minimumTransactionAmount": "0.001",
    "positionDuration": 604800,
    "checkpointDuration": 3600,
    "timeStretch": "0.044463125629060298",
    "governance": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
    "feeCollector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
    "fees": [
        "0.1",
        "0.0005",
        "0.15"
    ],
    "oracleSize": 10,
    "updateGap": 3600,
    "contractAddress": "0xd8058efe0198ae9dD7D563e1b4938Dcbc86A1F81",
    "curveFee": "0.1",
    "flatFee": "0.0005",
    "governanceFee": "0.15",
    "invTimeStretch": "22.490546623794212364"
}
Traceback:   File "/Users/slundquist/workspace/elf-simulations/lib/agent0/agent0/hyperdrive/exec/execute_agent_trades.py", line 220, in async_match_contract_call_to_trade
    trade_result = await hyperdrive.async_add_liquidity(agent, trade.trade_amount, min_apr, max_apr)
  File "/Users/slundquist/workspace/elf-simulations/lib/ethpy/ethpy/hyperdrive/api.py", line 538, in async_add_liquidity
    tx_receipt = await async_smart_contract_transact(
  File "/Users/slundquist/workspace/elf-simulations/lib/ethpy/ethpy/base/transactions.py", line 251, in async_smart_contract_transact
    raise err
  File "/Users/slundquist/workspace/elf-simulations/lib/ethpy/ethpy/base/transactions.py", line 214, in async_smart_contract_transact
    unsent_txn = func_handle.build_transaction(
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/contract/contract.py", line 354, in build_transaction
    return build_transaction_for_function(
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/contract/utils.py", line 232, in build_transaction_for_function
    prepared_transaction = fill_transaction_defaults(w3, prepared_transaction)
  File "cytoolz/functoolz.pyx", line 263, in cytoolz.functoolz.curry.__call__
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/_utils/transactions.py", line 132, in fill_transaction_defaults
    default_val = default_getter(w3, transaction)
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/_utils/transactions.py", line 72, in <lambda>
    "gas": lambda w3, tx: w3.eth.estimate_gas(tx),
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/eth/eth.py", line 293, in estimate_gas
    return self._estimate_gas(transaction, block_identifier)
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/module.py", line 75, in caller
    result = w3.manager.request_blocking(
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/manager.py", line 321, in request_blocking
    return self.formatted_response(
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/manager.py", line 282, in formatted_response
    apply_error_formatters(error_formatters, response)
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/manager.py", line 99, in apply_error_formatters
    formatted_resp = pipe(response, error_formatters)
  File "cytoolz/functoolz.pyx", line 680, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 655, in cytoolz.functoolz.c_pipe
  File "/Users/slundquist/workspace/elf-simulations/.venv/lib/python3.10/site-packages/web3/_utils/contract_error_handling.py", line 161, in raise_contract_logic_error_on_revert
    raise ContractLogicError(message, data=data)

@vercel
Copy link

vercel bot commented Oct 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elf-simulations ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2023 11:32pm

@slundqui slundqui merged commit eecc9f7 into delvtech:main Oct 10, 2023
6 checks passed
@slundqui slundqui deleted the no_money_warning branch October 10, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants