-
Notifications
You must be signed in to change notification settings - Fork 749
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
[WIP] Add a flashloan and make contract callable by anyone #14
base: master
Are you sure you want to change the base?
Conversation
Specifically adding ETHEREUM_RPC_URL and BUNDLE_EXECUTOR_ADDRESS to "usage."
…arbitrage into add-flashloan
contracts/BundleExecutor.sol
Outdated
address private immutable owner; | ||
address private immutable executor; | ||
IWETH private constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); | ||
address public WETH_address = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constant as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made WETH_address constant as well, was that your intention?
contracts/BundleExecutor.sol
Outdated
{ | ||
uint aaveDebt = amounts[0].add(premiums[0]); | ||
uniswapWethFLParams(amounts[0], params, aaveDebt); | ||
WETH.approve(address(LENDING_POOL), aaveDebt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you just approve uint(-1) in constructor and avoid this in the hot path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.
@epheph a gentle ping on this, I addressed your comments above! |
if (msg.value > 0) { | ||
WETH.deposit{value: msg.value}(); | ||
} | ||
WETH.approve(address(LENDING_POOL), uint(-1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting! you don't move them back yourself, aave takes them back from you?
override | ||
returns (bool) | ||
{ | ||
uint aaveDebt = amounts[0].add(premiums[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess since there's no assets held in the contract, you don't need to limit msg.sender to aave?
); | ||
} | ||
|
||
function uniswapWethFLParams(uint256 _amountToFirstMarket, bytes memory _params, uint256 aaveDebt) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like the first one, anyone can perform arbitrary calls, so the "owner" here isn't really that empowered. more a convenience than anything
address private immutable owner; | ||
address private immutable executor; | ||
IWETH private constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); | ||
address public constant WETH_address = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove executor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice. I look forward to people not moving weth into a contract.
@@ -2,6 +2,10 @@ simple-arbitrage | |||
================ | |||
This repository contains a simple, mechanical system for discovering, evaluating, rating, and submitting arbitrage opportunities to the Flashbots bundle endpoint. This script is very unlikely to be profitable, as many users have access to it, and it is targeting well-known Ethereum opportunities. | |||
|
|||
simple-arbitrage uses Flashloans to source liquidity to execute on arbitrage opportunities it finds. It attempts to capture them and sends any profits made, net of fees, back to the message sender. We have deployed a contract that anyone can submit trades to here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please update the link to this execution contract or send us its address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This PR does the following:
Some remaining tasks I could use help on:
tx.origin
to send profits to the caller of the contract? I thinkmsg.sender
will be Aave calling back our contract after sending the flashloan