UNPKG

@ohgeez/fsushi

Version:

fSUSHI is a protocol built on top of [FlashStake](http://flashstake.io/) and [SushiSwap](https://sushi.com) that enables stakers to get instant, upfront yield without waiting for it to accrue.

880 lines (478 loc) 13.9 kB
# VotingEscrowMock *LevX (team@levx.io)* > Voting Escrow Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for) *Vote weight decays linearly over time. Lock time cannot be more than `MAXTIME`.Ported from vyper (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy)* ## Methods ### CRETE_LOCK_TYPE ```solidity function CRETE_LOCK_TYPE() external view returns (int128) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | undefined | ### DEPOSIT_FOR_TYPE ```solidity function DEPOSIT_FOR_TYPE() external view returns (int128) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | undefined | ### INCREASE_LOCK_AMOUNT ```solidity function INCREASE_LOCK_AMOUNT() external view returns (int128) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | undefined | ### INCREASE_UNLOCK_TIME ```solidity function INCREASE_UNLOCK_TIME() external view returns (int128) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | undefined | ### balanceOf ```solidity function balanceOf(address addr, uint256 _t) external view returns (uint256) ``` Get the current voting power for `msg.sender` *Adheres to the ERC20 `balanceOf` interface for Aragon compatibility* #### Parameters | Name | Type | Description | |---|---|---| | addr | address | User wallet address | | _t | uint256 | Epoch time to return voting power at | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | User voting power | ### balanceOf ```solidity function balanceOf(address addr) external view returns (uint256) ``` #### Parameters | Name | Type | Description | |---|---|---| | addr | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### balanceOfAt ```solidity function balanceOfAt(address addr, uint256 _block) external view returns (uint256) ``` Measure voting power of `addr` at block height `_block` *Adheres to MiniMe `balanceOfAt` interface: https://github.com/Giveth/minime* #### Parameters | Name | Type | Description | |---|---|---| | addr | address | User's wallet address | | _block | uint256 | Block to calculate the voting power at | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | Voting power | ### checkpoint ```solidity function checkpoint() external nonpayable ``` Record global data to checkpoint ### createLock ```solidity function createLock(uint256 _value, uint256 _duration) external nonpayable ``` Deposit `_value` tokens for `msg.sender` and lock for `_duration` #### Parameters | Name | Type | Description | |---|---|---| | _value | uint256 | Amount to deposit | | _duration | uint256 | Epoch time until tokens unlock from now | ### createLockFor ```solidity function createLockFor(address _addr, uint256 _value, uint256 _discount, uint256 _duration) external nonpayable ``` Deposit `_value` tokens with `_discount` for `_addr` and lock for `_duration` #### Parameters | Name | Type | Description | |---|---|---| | _addr | address | User's wallet address | | _value | uint256 | Amount to add to user's lock | | _discount | uint256 | Amount to get discounted out of _value | | _duration | uint256 | Epoch time until tokens unlock from now | ### decimals ```solidity function decimals() external view returns (uint8) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint8 | undefined | ### delegateAt ```solidity function delegateAt(address, uint256) external view returns (address) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | address | undefined | | _1 | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | address | undefined | ### delegateLength ```solidity function delegateLength(address addr) external view returns (uint256) ``` #### Parameters | Name | Type | Description | |---|---|---| | addr | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### depositFor ```solidity function depositFor(address _addr, uint256 _value) external nonpayable ``` Deposit `_value` tokens for `_addr` and add to the lock *Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user* #### Parameters | Name | Type | Description | |---|---|---| | _addr | address | User's wallet address | | _value | uint256 | Amount to add to user's lock | ### epoch ```solidity function epoch() external view returns (uint256) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### getCheckpointTime ```solidity function getCheckpointTime(address _addr, uint256 _idx) external view returns (uint256) ``` Get the timestamp for checkpoint `_idx` for `_addr` #### Parameters | Name | Type | Description | |---|---|---| | _addr | address | User wallet address | | _idx | uint256 | User epoch number | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | Epoch time of the checkpoint | ### getLastUserSlope ```solidity function getLastUserSlope(address addr) external view returns (int128) ``` Get the most recently recorded rate of voting power decrease for `addr` #### Parameters | Name | Type | Description | |---|---|---| | addr | address | Address of the user wallet | #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | Value of the slope | ### increaseAmount ```solidity function increaseAmount(uint256 _value) external nonpayable ``` Deposit `_value` additional tokens for `msg.sender` without modifying the unlock time #### Parameters | Name | Type | Description | |---|---|---| | _value | uint256 | Amount of tokens to deposit and add to the lock | ### increaseAmountFor ```solidity function increaseAmountFor(address _addr, uint256 _value, uint256 _discount) external nonpayable ``` Deposit `_value` additional tokens for `msg.sender` without modifying the unlock time #### Parameters | Name | Type | Description | |---|---|---| | _addr | address | User's wallet address | | _value | uint256 | Amount of tokens to deposit and add to the lock | | _discount | uint256 | Amount to get discounted out of _value | ### increaseUnlockTime ```solidity function increaseUnlockTime(uint256 _duration) external nonpayable ``` Extend the unlock time for `msg.sender` to `_duration` #### Parameters | Name | Type | Description | |---|---|---| | _duration | uint256 | Increased epoch time for unlocking | ### interval ```solidity function interval() external view returns (uint256) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### locked ```solidity function locked(address) external view returns (int128 amount, int128 discount, uint256 start, uint256 end) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | amount | int128 | undefined | | discount | int128 | undefined | | start | uint256 | undefined | | end | uint256 | undefined | ### maxDuration ```solidity function maxDuration() external view returns (uint256) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### migrated ```solidity function migrated(address) external view returns (bool) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | bool | undefined | ### migrator ```solidity function migrator() external view returns (address) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | address | undefined | ### name ```solidity function name() external view returns (string) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | string | undefined | ### owner ```solidity function owner() external view returns (address) ``` *Returns the address of the current owner.* #### Returns | Name | Type | Description | |---|---|---| | _0 | address | undefined | ### pointHistory ```solidity function pointHistory(uint256) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | bias | int128 | undefined | | slope | int128 | undefined | | ts | uint256 | undefined | | blk | uint256 | undefined | ### renounceOwnership ```solidity function renounceOwnership() external nonpayable ``` *Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.* ### slopeChanges ```solidity function slopeChanges(uint256) external view returns (int128) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | int128 | undefined | ### supply ```solidity function supply() external view returns (uint256) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### symbol ```solidity function symbol() external view returns (string) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | string | undefined | ### token ```solidity function token() external view returns (address) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | address | undefined | ### totalSupply ```solidity function totalSupply() external view returns (uint256) ``` #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### totalSupply ```solidity function totalSupply(uint256 t) external view returns (uint256) ``` Calculate total voting power *Adheres to the ERC20 `totalSupply` interface for Aragon compatibility* #### Parameters | Name | Type | Description | |---|---|---| | t | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | Total voting power | ### totalSupplyAt ```solidity function totalSupplyAt(uint256 _block) external view returns (uint256) ``` Calculate total voting power at some point in the past #### Parameters | Name | Type | Description | |---|---|---| | _block | uint256 | Block to calculate the total voting power at | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | Total voting power at `_block` | ### transferOwnership ```solidity function transferOwnership(address newOwner) external nonpayable ``` *Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.* #### Parameters | Name | Type | Description | |---|---|---| | newOwner | address | undefined | ### unlockTime ```solidity function unlockTime(address _addr) external view returns (uint256) ``` Get timestamp when `_addr`'s lock finishes #### Parameters | Name | Type | Description | |---|---|---| | _addr | address | User wallet | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | Epoch time of the lock end | ### userPointEpoch ```solidity function userPointEpoch(address) external view returns (uint256) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | address | undefined | #### Returns | Name | Type | Description | |---|---|---| | _0 | uint256 | undefined | ### userPointHistory ```solidity function userPointHistory(address, uint256) external view returns (int128 bias, int128 slope, uint256 ts, uint256 blk) ``` #### Parameters | Name | Type | Description | |---|---|---| | _0 | address | undefined | | _1 | uint256 | undefined | #### Returns | Name | Type | Description | |---|---|---| | bias | int128 | undefined | | slope | int128 | undefined | | ts | uint256 | undefined | | blk | uint256 | undefined | ### withdraw ```solidity function withdraw() external nonpayable ``` Withdraw all tokens for `msg.sender` *Only possible if the lock has expired* ## Events ### Deposit ```solidity event Deposit(address indexed provider, uint256 value, uint256 discount, uint256 indexed unlockTime, int128 indexed _type, uint256 ts) ``` #### Parameters | Name | Type | Description | |---|---|---| | provider `indexed` | address | undefined | | value | uint256 | undefined | | discount | uint256 | undefined | | unlockTime `indexed` | uint256 | undefined | | _type `indexed` | int128 | undefined | | ts | uint256 | undefined | ### OwnershipTransferred ```solidity event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) ``` #### Parameters | Name | Type | Description | |---|---|---| | previousOwner `indexed` | address | undefined | | newOwner `indexed` | address | undefined | ### Supply ```solidity event Supply(uint256 prevSupply, uint256 supply) ``` #### Parameters | Name | Type | Description | |---|---|---| | prevSupply | uint256 | undefined | | supply | uint256 | undefined | ### Withdraw ```solidity event Withdraw(address indexed provider, uint256 value, uint256 discount, uint256 ts) ``` #### Parameters | Name | Type | Description | |---|---|---| | provider `indexed` | address | undefined | | value | uint256 | undefined | | discount | uint256 | undefined | | ts | uint256 | undefined | ## Errors ### OutOfRange ```solidity error OutOfRange() ```