This file contains hidden or 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
| pragma solidity >=0.6.0; | |
| interface IPancakeFactory { | |
| event PairCreated(address indexed token0, address indexed token1, address pair, uint); | |
| function feeTo() external view returns (address); | |
| function feeToSetter() external view returns (address); | |
| function getPair(address tokenA, address tokenB) external view returns (address pair); | |
| function allPairs(uint) external view returns (address pair); |
This file contains hidden or 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
| pragma solidity ^0.6.0; | |
| interface IPancakeRouter01 { | |
| function factory() external pure returns (address); | |
| function WETH() external pure returns (address); | |
| function addLiquidity( | |
| address tokenA, | |
| address tokenB, | |
| uint amountADesired, |
This file contains hidden or 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
| function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { | |
| for (uint i; i < path.length - 1; i++) { | |
| (address input, address output) = (path[i], path[i + 1]); | |
| (address token0,) = PancakeLibrary.sortTokens(input, output); | |
| uint amountOut = amounts[i + 1]; | |
| (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); | |
| address to = i < path.length - 2 ? PancakeLibrary.pairFor(factory, output, path[i + 2]) : _to; | |
| IPancakePair(PancakeLibrary.pairFor(factory, input, output)).swap( | |
| amount0Out, amount1Out, to, new bytes(0) | |
| ); |
This file contains hidden or 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
| function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { | |
| require(amount0Out > 0 || amount1Out > 0, 'Pancake: INSUFFICIENT_OUTPUT_AMOUNT'); | |
| (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings | |
| require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Pancake: INSUFFICIENT_LIQUIDITY'); | |
| uint balance0; | |
| uint balance1; | |
| { // scope for _token{0,1}, avoids stack too deep errors | |
| address _token0 = token0; | |
| address _token1 = token1; |
NewerOlder