This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
146 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pragma solidity 0.8.10; | ||
pragma experimental ABIEncoderV2; | ||
|
||
enum SwapType { | ||
CURVE, //0 | ||
UNIV2, //1 | ||
SUSHI, //2 | ||
UNIV3, //3 | ||
UNIV3WITHWETH, //4 | ||
BALANCER, //5 | ||
BALANCERWITHWETH //6 | ||
} | ||
|
||
// Onchain Pricing Interface | ||
struct Quote { | ||
SwapType name; | ||
uint256 amountOut; | ||
bytes32[] pools; // specific pools involved in the optimal swap path | ||
uint256[] poolFees; // specific pool fees involved in the optimal swap path, typically in Uniswap V3 | ||
} | ||
interface OnChainPricing { | ||
function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external view returns (bool); | ||
function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (Quote memory); | ||
} | ||
// END OnchainPricing | ||
|
||
contract PricerWrapper { | ||
address public pricer; | ||
constructor(address _pricer) { | ||
pricer = _pricer; | ||
} | ||
|
||
function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external view returns (bool) { | ||
return OnChainPricing(pricer).isPairSupported(tokenIn, tokenOut, amountIn); | ||
} | ||
|
||
function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (uint256, Quote memory) { | ||
uint256 _gasBefore = gasleft(); | ||
Quote memory q = OnChainPricing(pricer).findOptimalSwap(tokenIn, tokenOut, amountIn); | ||
return (_gasBefore - gasleft(), q); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.