Flash Arbitrage
The CORE Flash Arbitrage suite is composed of two important principles: arbitrage & flash swaps.
Flash Arbitrage
CORE’s high level arbitrage suite consists of three contracts:
Arbitrage Executor
The Arbitrage Executor is the brain of our Flash Arbitrage, it calculates scenarios and executes the trades. This contract is closed source.
Arbitrage Controller
The Arbitrage Controller is responsible for adding and storing all strategies. It calls the Arbitrage Executor and then splits the profits between the Caller and the CORE Buyer Contract. It vastly simplifies the interface to the Executor.
Core Buyer Contract
This contract turns the arbitrage profits into CORE and transfers them directly to farmers.
No input is required to run these contracts, the loan is created by using Uniswaps Flash Swaps. This means only your gas cost is at stake. While the contract isn’t guaranteeing gas returns, you can always query the amount returned.
Overview of the Arbitrage Controller functions:
The creation of a new strategy emits an event which can be listened to and queried by
The Arbitrage Controller is storing each strategy in a public array inside the smart contract. Each strategy has a name and an array of token0out — this is to support Uniswap so we know which way to conduct the trade in the Executor
This shows the array of pairs that the trade will be in
Strategies support Fee on Transfer tokens with fee on transfer array here. It allows people to input that this strategy has a fee on transfer, which signals the contract to calculate and execute the strategy correctly.
cBTC support is determined by itself. You can not input it.
This allows for a FoT Off strategy. Adding strategies involving CORE and feeOff is not permitted by anyone. To avoid atypical scenarios with feeOff.
Revenue split: The revenue split between the Caller and CORE Buyer Contract is dependant on the strategy utilizing feeOff or feeOn.
Strategies that are outside of CORE reward the Caller with the majority of the profits. The ease of use and profit split encourages usage of the service. It is easier to add strategies to this contract and share the profits than having to create your own complex suite of contracts. All strategies, including new creations, are open source and can be used by everyone.
Adding New Strategies
CORE pairs can not be added by the community. Only by CORE devs. Users can add new strategies as long as they are valid. To create a valid strategy one must input an array of pairs (comma separated list) which has a logically flow from each other.
This closes the loop by itself, no need to input CORE/wETH again since the last pair will be treated as a return pair. The controller detects if cBTC is used and sets the support automatically. It makes sure the Executor picks the correct branch to execute and save gas in case support for cBTC is not on.
addNewStrategy function is used for adding new strategies with no fee on transfers anywhere.
addNewStrategyWithFeeOnTransferTokens supports fee on transfer input, to support fee on transfer tokens all over.
numberOfStrategies function returns the number of strategies (routes of arbitrage) inside the contract which everyone can easily scan in a loop.
Querying Profits from Strategies. The executor has a view function which returns the queried profit if the strategy was executed at that exact moment. This function should be used to scan all outstanding strategies from the previous step and calling executions immediately.
Strategy Execution
There are two paths that strategy execution can take:
Skip calculating Optimal Input
Calculate Optimal Input at the time of execution
Number 1 is meant for miners, which know the optimal input without calculating it on chain.
Self calculating execution just requires strategy PID. Strategies that do not automatically calculate amount input, meant for miners.
Adding Optimal Input:
A view that returns the optimal input amount, which should be inputted in the execution function below:
Both execution strategy functions ensure you get promised profit and non-opaque split numbers.
The Flash Arbitrage executor does not hold any tokens, it only swaps them, picking the best path that will lower the gas used as much as possible as well as not writing any balances in its memory to save additional gas costs.
CORE Buyer Contract
This contract receives tokens, either from the Arbitrage Controller, or any other source in general and sells them for CORE.If a CORE pair exists for the received token, it will sell it directly to CORE. In case of not having a token pair with CORE, the contract will sell the token for Ethereum and then buy CORE in the CORE/WETH pool immediately. All CORE will be distributed to farmers.
Anyone can call this function by inserting an address for the token. This will automatically conduct a swap and distribute the token to LP stakers.
Last updated