Skip to content

Add slippage protection for eth_bots#740

Merged
sentilesdal merged 14 commits intomainfrom
matt-slippage
Jul 26, 2023
Merged

Add slippage protection for eth_bots#740
sentilesdal merged 14 commits intomainfrom
matt-slippage

Conversation

@sentilesdal
Copy link
Copy Markdown
Contributor

@sentilesdal sentilesdal commented Jul 25, 2023

This PR add slippage protection to the agent trades in eth_bots. This is accomplished by adding a new function smart_contract_preview_transaction that will do a dry run of a transaction and return the results. The result is then multiplied by the slippage_tolerance to get either the min_output or the max_deposit for the actual transaction. Along the way several other improvements were made:

  • made Trade generic. This allows us to specify Trade[HyperdriveMarketAction] so we now know what kind of trade is in the Trade envelope.
  • fixed a floating point error in SECONDS_IN_YEAR constant
  • lint fixes in other files, comments and ignoring type warnings for pandas.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 25, 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 Jul 26, 2023 5:54pm

@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4943 🚀

@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4943 🚀

Comment thread elfpy/agents/policies/random_agent.py
Comment thread elfpy/agents/policies/lp_and_withdraw.py
Comment thread elfpy/agents/policies/random_agent.py
Comment thread elfpy/agents/policies/single_lp.py
Comment thread elfpy/agents/policies/single_short.py
Comment thread elfpy/agents/policies/smart_long.py
Comment thread elfpy/agents/policies/smart_short.py
Comment thread elfpy/eth/transactions.py
Comment thread elfpy/eth/transactions.py
Comment thread elfpy/bots/agent_config.py
Comment thread elfpy/eth/transactions.py Outdated
Comment thread elfpy/hyperdrive_interface/hyperdrive_addresses.py Outdated
Comment thread examples/eth_bots/config.py Outdated
Comment thread examples/eth_bots/eth_bots_config.py Outdated
Comment thread examples/eth_bots/execute_agent_trades.py Outdated
@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4994 🚀

@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4987 🚀

@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4934 🚀

@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4900 🚀

improve typing and expose base_token_contract as well to make debugging
easier.  nice to be able to go up the stack trace and use the
base_token_contract to view balances
@github-actions
Copy link
Copy Markdown

Remaining rate limit: 4931 🚀

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.

3 participants