optimistic swaps (#53)
* alternative flash lending (renting) design
* add rent interface
* fix stack too deep error
rearrange order of k condition math
ignore erroneous out of gas errors in tests
* try removing rent in favor of monolithic swap
IUniswapV2Borrower -> IUniswapV2Callee
update tests
* fix implementation
* clean up math a bit
* amount{0,1}In -> amount{0,1}InNet
* charge on all inputs, not just net
* removed unnecessary safemath
* add to != token check
don't indent in scope
rename reserve{0,1}Next -> reserve{0,1}Adjusted
* > instead of >=
simplify algebra
reserve{0,1}Adjusted -> balance{0,1}Adjusted
add comments
* add some optimistic swap test cases
This commit is contained in:
5
contracts/interfaces/IUniswapV2Callee.sol
Normal file
5
contracts/interfaces/IUniswapV2Callee.sol
Normal file
@ -0,0 +1,5 @@
|
||||
pragma solidity =0.5.16;
|
||||
|
||||
interface IUniswapV2Callee {
|
||||
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
|
||||
}
|
||||
@ -23,7 +23,14 @@ interface IUniswapV2Exchange {
|
||||
|
||||
event Mint(address indexed sender, uint amount0, uint amount1);
|
||||
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
|
||||
event Swap(address indexed sender, address indexed tokenIn, uint amountIn, uint amountOut, address indexed to);
|
||||
event Swap(
|
||||
address indexed sender,
|
||||
uint amount0In,
|
||||
uint amount1In,
|
||||
uint amount0Out,
|
||||
uint amount1Out,
|
||||
address indexed to
|
||||
);
|
||||
event Sync(uint112 reserve0, uint112 reserve1);
|
||||
|
||||
function MINIMUM_LIQUIDITY() external pure returns (uint);
|
||||
@ -37,7 +44,7 @@ interface IUniswapV2Exchange {
|
||||
|
||||
function mint(address to) external returns (uint liquidity);
|
||||
function burn(address to) external returns (uint amount0, uint amount1);
|
||||
function swap(address tokenIn, uint amountOut, address to) external;
|
||||
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
|
||||
function skim(address to) external;
|
||||
function sync() external;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user