CorgiSwap is based on Uniswap v2. Read the Uniswap v2 documentation.
For more in-depth information on the core contract logic, read the Uniswap v2 Core whitepaper.
Contract info
Contract name: CorgiSRouter
Contract address: https://bscscan.com/address/0xd2c1177d83c04096635c090ff20e144a73c85c97#code
View CorgiSFactory.sol on GitHub.
View the CorgiSwap: Router v2 contract on BscScan.
Read functions
WETH
function WETH() external pure returns (address);
Returns the canonical address for Binance: WBNB token (WETH being a vestige from Ethereum network origins).
factory
function factory() external pure returns (address);
Returns the canonical address for CorgiFactory.
For explanations of the following, view the Uniswap v2 Internal Functions documentation.
getAmountOut
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut);
getAmountIn
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn);
getAmountsOut
function getAmountsOut(uint amountIn, address[] memory path) internal view returns (uint[] memory amounts);
getAmountsIn
function getAmountsOut(uint amountIn, address[] memory path) internal view returns (uint[] memory amounts);
quote
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB);
Write functions
addLiquidity
Copy function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
Adds liquidity to a BEP20⇄BEP20 pool.
addLiquidityETH
Copy function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
Adds liquidity to a BEP20⇄WBNB pool.
removeLiquidity
Copy function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
Removes liquidity from a BEP20⇄BEP20 pool.
removeLiquidityETH
Copy function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
Removes liquidity from a BEP20⇄WBNB pool.
removeLiquidityETHSupportingFeeOnTransferTokens
Copy function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
Removes liquidity from a BEP20⇄WBNB for tokens that take a fee on transfer.
removeLiquidityETHWithPermit
Copy function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
Removes liquidity from a BEP20⇄WBNB and receives BNB, without pre-approval, via permit.
removeLiquidityETHWithPermitSupportingFeeOnTransferTokens
Copy function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
Removes liquidity from a BEP20⇄WBNB and receives BNB via permit for tokens that take a fee on transfer.
removeLiquidityWithPermit
Copy function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
Removes liquidity from a BEP20⇄BEP20, without pre-approval, via permit.
swapETHForExactTokens
Copy function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
Receive an exact amount of output tokens for as little BNB as possible.
swapExactETHForTokens
Copy function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
Receive an as many output tokens as possible for an exact amount of BNB.
swapExactETHForTokensSupportingFeeOnTransferTokens
Copy function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
Receive an as many output tokens as possible for an exact amount of BNB. Supports tokens that take a fee on transfer.
swapExactTokensForETH
Copy function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
Receive an as much BNB as possible for an exact amount of input tokens.
swapExactTokensForETHSupportingFeeOnTransferTokens
Copy function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
Receive an as much BNB as possible for an exact amount of tokens. Supports tokens that take a fee on transfer.
swapExactTokensForTokens
Copy function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
Receive an as many output tokens as possible for an exact amount of input tokens.
swapExactTokensForTokensSupportingFeeOnTransferTokens
Copy function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
Receive an as many output tokens as possible for an exact amount of input tokens. Supports tokens that take a fee on transfer.
swapTokensForExactETH
Copy function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
Receive an exact amount of ETH for as few input tokens as possible.
swapTokensForExactTokens
Copy function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
Receive an exact amount of output tokens for as few input tokens as possible.
Interface
Copy import '@uniswap/v2-core/contracts/interfaces/ICorgiRouter.sol';
Copy pragma solidity >=0.6.2;
interface ICorgiRouter01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// File: contracts\interfaces\ICorgiRouter02.sol
pragma solidity >=0.6.2;
interface ICorgiRouter02 is ICorgiRouter01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}