Lossless
Search…
LiquidityProtectionSingleLimitStrategy
Contract that implements protection strategy using a single limit. Inherits from StrategyBase.
Contract can be found here:
lossless-v2/LiquidityProtectionSingleLimitStrategy.sol at master · Lossless-Cash/lossless-v2
GitHub

Variables

  • protection

protection

A mapping of addresses and their protection rules.

Functions

  • getLimit
  • setLimitBatched
  • setLimit
  • removeLimits
  • pause
  • isTransferAllowed

getLimit

1
function getLimit(address token, address protectedAddress) external view returns(Limit memory)
Copied!
Returns limit info for particular protected address.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being checked.
protectedAddress
address
Address for which the limit should be returned.

setLimitBatched

1
function setLimitBatched(
2
address token,
3
address[] calldata protectedAddresses,
4
uint256 periodInSeconds,
5
uint256 amountPerPeriod,
6
uint256 startTimestamp
7
) external onlyProtectionAdmin(token)
Copied!
Sets limits for a list of addresses. Can be called only by token protection admin.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being applied.
protectedAddresses
address[]
A list of addresses that should get the limit applied.
periodInSeconds
uint256
Limit period.
amountPerPeriod
uint256
Limit amount per period.
startTimestamp
uint256
Limit start time.

setLimit

1
function setLimit(
2
address token,
3
address protectedAddress,
4
uint256 periodInSeconds,
5
uint256 amountPerPeriod,
6
uint256 startTimestamp
7
) external onlyProtectionAdmin(token)
Copied!
Sets limit for a single address. Can be called only by token protection admin.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being applied.
protectedAddress
address
Address that should get the limit applied.
periodInSeconds
uint256
Limit period.
amountPerPeriod
uint256
Limit amount per period.
startTimestamp
uint256
Limit start time.

removeLimits

1
function removeLimits(address token, address[] calldata protectedAddresses) external onlyProtectionAdmin(token)
Copied!
Removes limits for addresses in the list. Can be called only by token protection admin.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being applied.
protectedAddresses
address[]
Addresses that should get limits removed.

pause

1
function pause(address token, address protectedAddress) external onlyProtectionAdmin(token)
Copied!
Change limit to 0, ie, pause transfers from this address. Can be called only by token protection admin.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being applied.
protectedAddress
address
Address that should get it's limit paused.

isTransferAllowed

1
function isTransferAllowed(address token, address sender, address recipient, uint256 amount) external
Copied!
Checks if transfer from the sender is allowed. Internally it validates if limit is not reached and updates limit info after transfer is allowed to go through.
Parameters:
Name
Type
Description
token
address
Token for which the protection rules are being checked.
sender
address
Sender's address.
recipient
address
Recipient's address.
amount
uint256
Amount of tokens being transferred.
Copy link