Speedbump

Overview of mechanism design of speedbump

SpeedBump

Table of Contents

  1. Specification

  2. Parameters

  3. Functions

    1. initialize

    2. batchRegisterNFTs

    3. batchWithdrawNFTs

    4. registerToken

    5. withdrawToken

    6. registerETH

    7. withdrawETH

  4. Events

Specification

The speedBump contract acts as a temporary holder of ERC-20's and ERC-721's when they are withdrawn from the pool. It forces the user to wait until the next block to remove liquidity. This is done to reduce the risk of exploits that make use of flash loans. Flash loans revert if all liquidity + fees are not returned in the same block, thus the speedBump makes a flash loan exploit less likely.

Register Withdrawal ERC-721:

  1. The positionManager sends the NFT (ERC-721) to the SpeedBump contract.

  2. The positionManager calls a function on the SpeedBump contract to register the withdrawal request, providing the user’s address and the current block number. This is protected by nonReentrant modifier

User Withdraw (ERC-721)

  1. The user sends a message to `withdrawNft`` with tokenID.

  2. If the user has a deposit on the speedBump, and the current block number is at least the block number at registration + 1, the NFT will be transfered to the user

Depositing ERC-20

  1. The positionManager sends the ERC-20 to the SpeedBump contract.

  2. The position manager call registerToken with the ERC-20 token address and an amount of the token, registering it to the user in a withdrawl struct

Withdraw ERC-20

  1. The user sends a message to withdrawToken with the associated address of the ERC-20 contract.

  2. If the block number is at least the block number registered in the withdraw struct + 1, the ERC-20 is withdrawn to the user. This is protected by the non-reentrant modifier.

Parameters

Functions

initialize

The initialize takes as an argument the associated address for the position Manager. The functions "registerXXXX" have a modifier that makes it so they can only be called by the positionManager.

batchRegisterNFTs

batchWithdrawNFTs

registerToken

withdrawToken

registerETH

withdrawETH

Events

Last updated