Skip to main content

SushiRoll

SushiRoll helps migrate your existing Uniswap LP tokens to SushiSwap LP tokens.

The full contract can be found here.

Functions

migrateWithPermit

function migrateWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public

Migrates existing Uniswap LP tokens to SushiSwap LP tokens and permits the move in the same function.

Parameters

NameTypeDescription
tokenAaddressUniswap LP token
tokenBaddressSushiSwap LP token
liquidityuint256amount of SUSHI you have staked that you wish to withdraw
amountAMinuint256minimum amount of Uniswap LP tokens to migrate
amountBMinuint256minimum amount of SushiSwap LP tokens to migrate over to
deadlineuint256current timestamp
vuint8recovery byte of the signature
rbytes32half of the ECDSA signature pair
sbytes32half of the ECDSA signature pair

migrate

 function migrate(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline
) public

Migrates approved liquidity amount of tokenA and tokenB.

Parameters

NameTypeDescription
tokenAaddressUniswap LP token
tokenBaddressSushiSwap LP token
liquidityuint256amount of approved Uniswap LP you wish to migrate
amountAMinuint256minimum amount of Uniswap LP tokens to migrate
amountBMinuint256minimum amount of SushiSwap LP tokens to migrate over to
deadlineuint256current timestamp

removeLiquidity

function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline
) internal returns (uint256 amountA, uint256 amountB)

Removes liquidity from old router. !!

Parameters

NameTypeDescription
tokenAaddressUniswap LP token
tokenBaddressSushiSwap LP token
liquidityuint256amount of approved Uniswap LP you wish to migrate
amountAMinuint256minimum amount of Uniswap LP tokens to migrate
amountBMinuint256minimum amount of SushiSwap LP tokens to migrate over to
deadlineuint256current timestamp

Returns

NameTypeDescription
amountAuint256Uniswap LP amount
amountBuint256SushiSwap LP amount

pairForOldRouter

function pairForOldRouter(address tokenA, address tokenB) internal view returns (address pair)

Calculates the CREATE2 address for a pair without making any external calls.

Parameters

NameTypeDescription
tokenAaddressUniswap LP token
tokenBaddressSushiSwap LP token

Returns

NameTypeDescription
pairaddressCREATE2 address for the pair

_addLiquidity

function _addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired
) internal returns (uint256 amountA, uint256 amountB)

Internal function that creates the token pair if it doesn't exist yet, to be added by addLiquidity.

Parameters

NameTypeDescription
tokenAaddressaddress of first token in pair
tokenBaddressaddress of second token in pair
amountADesireduint256amount of tokenA to add
amountBDesireduint256amount of tokenB to add

Returns

NameTypeDescription
amountAuint256amount of tokenA added
amountBuint256amount of tokenB added

addLiquidity

function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired
) internal returns (uint amountA, uint amountB)

Internal function that calls _addLiquidity and actually makes the safe transfers.

Parameters

NameTypeDescription
tokenAaddressaddress of first token in pair
tokenBaddressaddress of second token in pair
amountADesireduint256amount of tokenA to add
amountBDesireduint256amount of tokenB to add

Returns

NameTypeDescription
amountAuint256amount of tokenA added
amountBuint256amount of tokenB added