forked from GalloDaSballo/fair-selling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOnChainPricingMainnetLenient.sol
55 lines (39 loc) · 1.96 KB
/
OnChainPricingMainnetLenient.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.10;
import {IERC20} from "@oz/token/ERC20/IERC20.sol";
import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/uniswap/IUniswapRouterV2.sol";
import "../interfaces/curve/ICurveRouter.sol";
import {OnChainPricingMainnet} from "./OnChainPricingMainnet.sol";
/// @title OnChainPricing
/// @author Alex the Entreprenerd @ BadgerDAO
/// @dev Mainnet Version of Price Quoter, hardcoded for more efficiency
/// @notice To spin a variant, just change the constants and use the Component Functions at the end of the file
/// @notice Instead of upgrading in the future, just point to a new implementation
/// @notice This version has 5% extra slippage to allow further flexibility
/// if the manager abuses the check you should consider reverting back to a more rigorous pricer
contract OnChainPricingMainnetLenient is OnChainPricingMainnet {
// === SLIPPAGE === //
// Can change slippage within rational limits
address public constant TECH_OPS = 0x86cbD0ce0c087b482782c181dA8d191De18C8275;
uint256 private constant MAX_BPS = 10_000;
uint256 private constant MAX_SLIPPAGE = 500; // 5%
uint256 public slippage = 200; // 2% Initially
constructor(
address _uniV3Simulator,
address _balancerV2Simulator
) OnChainPricingMainnet(_uniV3Simulator, _balancerV2Simulator){
// Silence is golden
}
function setSlippage(uint256 newSlippage) external {
require(msg.sender == TECH_OPS, "Only TechOps");
require(newSlippage < MAX_SLIPPAGE);
slippage = newSlippage;
}
// === PRICING === //
/// @dev View function for testing the routing of the strategy
function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view override returns (Quote memory q) {
q = _findOptimalSwap(tokenIn, tokenOut, amountIn);
q.amountOut = q.amountOut * (MAX_BPS - slippage) / MAX_BPS;
}
}