IBribe
Functions
userLatestInteraction
Returns the period when the user last interacted with a specific LockManager Bribe
function userLatestInteraction(address _user, ILockManager _lockManager) external view returns (uint256 _period);
Parameters
Name | Type | Description |
---|---|---|
_user | address | The address of the user to check |
_lockManager | ILockManager | The LockManager to check |
Returns
Name | Type | Description |
---|---|---|
_period | uint256 | The number of the period |
POOL_MANAGER_FACTORY
Returns the contract PoolManagerFactory
function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);
Returns
Name | Type | Description |
---|---|---|
_poolManagerFactory | IPoolManagerFactory | The PoolManagerFactory |
createBribe
Creates and initializes a Bribery for a given LockManager
When a bribe is created we need to check if the previous finished or not
If it didn't then we have to add the tokens and amount to nextBribe
function createBribe(ILockManager _lockManager, IERC20 _bribeToken, uint256 _bribeAmount) external;
Parameters
Name | Type | Description |
---|---|---|
_lockManager | ILockManager | The address of the LockManager token to create a Bribery for |
_bribeToken | IERC20 | The address of the Token to provide for the Bribery |
_bribeAmount | uint256 | The total amount to provide for the Bribery |
deposit
Deposits an amount of LockManager to earn bribes
function deposit(ILockManager _lockManager, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_lockManager | ILockManager | The address of the LockManager to deposit |
_amount | uint256 | The amount to deposit |
withdraw
Withdraws LockManager tokens deposited by the user
function withdraw(ILockManager _lockManager, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_lockManager | ILockManager | The address of the LockManager token to withdraw |
_amount | uint256 | The amount to withdraw |
updateUserBalanceFromLastInteractionTo
Updates the user's balance from the last time he interacted till the specified period
function updateUserBalanceFromLastInteractionTo(ILockManager _lockManager, uint256 _toPeriod) external;
Parameters
Name | Type | Description |
---|---|---|
_lockManager | ILockManager | The LockManager to target |
_toPeriod | uint256 | The period to update up to |
claimRewards
Transfers the rewards of the Bribery to the caller for the specified tokens
function claimRewards(ILockManager _lockManager, IERC20[] memory _tokens, uint256 _fromPeriod, uint256 _toPeriod)
external;
Parameters
Name | Type | Description |
---|---|---|
_lockManager | ILockManager | The address of the LockManager that the Bribery targets |
_tokens | IERC20[] | The array of tokens that the user wants to claim |
_fromPeriod | uint256 | The period to start claiming rewards from |
_toPeriod | uint256 | The period to end claiming rewards from |
Events
CreatedBribe
Emitted when someone creates a Bribery
event CreatedBribe(ILockManager _lockManager, IERC20 _bribeToken, uint256 _bribeAmount);
Deposit
Emitted when someones deposits an amount of LockManager to earn Bribery rewards
event Deposit(address _caller, ILockManager _lockManager, uint256 _amount);
Withdraw
Emitted when someones withdraws their LockManager
event Withdraw(address _caller, ILockManager _lockManager, uint256 _amount);
ClaimedRewards
Emitted when someone claims the Bribery rewards
event ClaimedRewards(address _user, IERC20 _token, uint256 _amount);
UpdatedUserBalance
Emitted when someone updates manually their balances
event UpdatedUserBalance(address _user, ILockManager _lockManager, uint256 _toPeriod);
Errors
Bribe_InvalidPoolManager
Thrown when the PoolManager is invalid
error Bribe_InvalidPoolManager();
Bribe_InvalidLockManager
Thrown when the LockManager is invalid
error Bribe_InvalidLockManager();
Bribe_TokenZeroAddress
Throws when trying to create a Bribery with bribe Token having the zero address
error Bribe_TokenZeroAddress();
Bribe_AmountZero
Throws when trying to create a Bribery with 0 bribe amount
error Bribe_AmountZero();
Bribe_NothingToWithdraw
Throws when trying to withdraw but there is nothing deposited
error Bribe_NothingToWithdraw();
Bribe_InvalidPeriod
Throws when trying to claim or update a user's balance with an invalid period
error Bribe_InvalidPeriod();
Bribe_InvalidWithdrawAmount
Throws when trying to withdraw a bigger amount than deposited
error Bribe_InvalidWithdrawAmount();
Bribe_NothingToUpdate
Throws when trying to update a user's balance but there is nothing to update
error Bribe_NothingToUpdate();
Structs
PeriodRewards
The Bribery Rewards information for a certain period
struct PeriodRewards {
uint256 start;
uint256 end;
uint256 totalDeposited;
IERC20[] bribeTokens;
mapping(IERC20 => uint256) totalBribeAmountPerToken;
mapping(address => uint256) userBalance;
mapping(address => mapping(IERC20 => bool)) userHasClaimedToken;
}