Skip to main content

RateLimited

Functions

constructor

function constructor(
uint256 _maxRateLimitPerSecond,
uint256 _rateLimitPerSecond,
uint256 _bufferCap,
bool _doPartialAction
) internal

Parameters

NameTypeDescription
_maxRateLimitPerSeconduint256
_rateLimitPerSeconduint256
_bufferCapuint256
_doPartialActionbool

setRateLimitPerSecond

function setRateLimitPerSecond(
uint256 newRateLimitPerSecond
) external

set the rate limit per second

Parameters

NameTypeDescription
newRateLimitPerSeconduint256

setBufferCap

function setBufferCap(
uint256 newBufferCap
) external

set the buffer cap

Parameters

NameTypeDescription
newBufferCapuint256

buffer

function buffer() public returns (uint256)

the amount of action used before hitting limit

replenishes at rateLimitPerSecond per second up to bufferCap

_depleteBuffer

function _depleteBuffer(
uint256 amount
) internal returns (uint256)

the method that enforces the rate limit. Decreases buffer by "amount". If buffer is <= amount either

    1. Does a partial mint by the amount remaining in the buffer or
2. Reverts
Depending on whether doPartialAction is true or false

Parameters

NameTypeDescription
amountuint256

_setRateLimitPerSecond

function _setRateLimitPerSecond(
uint256 newRateLimitPerSecond
) internal

Parameters

NameTypeDescription
newRateLimitPerSeconduint256

_setBufferCap

function _setBufferCap(
uint256 newBufferCap
) internal

Parameters

NameTypeDescription
newBufferCapuint256

_resetBuffer

function _resetBuffer() internal

_updateBufferStored

function _updateBufferStored() internal

Events

BufferUsed

event BufferUsed(
uint256 amountUsed,
uint256 bufferRemaining
)

Parameters

NameTypeDescription
amountUseduint256
bufferRemaininguint256

BufferCapUpdate

event BufferCapUpdate(
uint256 oldBufferCap,
uint256 newBufferCap
)

Parameters

NameTypeDescription
oldBufferCapuint256
newBufferCapuint256

RateLimitPerSecondUpdate

event RateLimitPerSecondUpdate(
uint256 oldRateLimitPerSecond,
uint256 newRateLimitPerSecond
)

Parameters

NameTypeDescription
oldRateLimitPerSeconduint256
newRateLimitPerSeconduint256