View Source: contracts/escrow/Escrow.sol
↘ Derived Contracts: EscrowReward
You can use this contract for deposit of SOV tokens for some time and withdraw later.
Enums
enum Status {
Deployed,
Deposit,
Holding,
Withdraw,
Expired
}
Constants & Variables
//public members
uint256 public totalDeposit;
uint256 public releaseTime;
uint256 public depositLimit;
contract IERC20 public SOV;
address public multisig;
enum Escrow.Status public status;
//internal members
mapping(address => uint256) internal userBalances;
Events
event EscrowActivated();
event EscrowInHoldingState();
event EscrowInWithdrawState();
event EscrowFundExpired();
event NewMultisig(address indexed _initiator, address indexed _newMultisig);
event TokenReleaseUpdated(address indexed _initiator, uint256 _releaseTimestamp);
event TokenDepositLimitUpdated(address indexed _initiator, uint256 _depositLimit);
event TokenDeposit(address indexed _initiator, uint256 _amount);
event DepositLimitReached();
event TokenWithdrawByMultisig(address indexed _initiator, uint256 _amount);
event TokenDepositByMultisig(address indexed _initiator, uint256 _amount);
event TokenWithdraw(address indexed _initiator, uint256 _amount);
modifier onlyMultisig() internal
modifier checkStatus(enum Escrow.Status s) internal
Arguments
Name | Type | Description |
---|---|---|
s | enum Escrow.Status |
modifier checkRelease() internal
- constructor(address _SOV, address _multisig, uint256 _releaseTime, uint256 _depositLimit)
- init()
- updateMultisig(address _newMultisig)
- updateReleaseTimestamp(uint256 _newReleaseTime)
- updateDepositLimit(uint256 _newDepositLimit)
- depositTokens(uint256 _amount)
- changeStateToHolding()
- withdrawTokensByMultisig(address _receiverAddress)
- depositTokensByMultisig(uint256 _amount)
- withdrawTokens()
- getUserBalance(address _addr)
Setup the required parameters.
function (address _SOV, address _multisig, uint256 _releaseTime, uint256 _depositLimit) public nonpayable
Arguments
Name | Type | Description |
---|---|---|
_SOV | address | The SOV token address. |
_multisig | address | The owner of the tokens & contract. |
_releaseTime | uint256 | The token release time, zero if undecided. |
_depositLimit | uint256 | The amount of tokens we will be accepting. |
Source Code
constructor(
address _SOV,
address _multisig,
uint256 _releaseTime,
uint256 _depositLimit
) public {
require(_SOV != address(0), "Invalid SOV Address.");
require(_multisig != address(0), "Invalid Multisig Address.");
SOV = IERC20(_SOV);
multisig = _multisig;
emit NewMultisig(msg.sender, _multisig);
releaseTime = _releaseTime;
depositLimit = _depositLimit;
status = Status.Deployed;
}
This function is called once after deployment for starting the deposit action.
function init() external nonpayable onlyMultisig checkStatus
Source Code
function init() external onlyMultisig checkStatus(Status.Deployed) {
status = Status.Deposit;
emit EscrowActivated();
}
Update Multisig.
function updateMultisig(address _newMultisig) external nonpayable onlyMultisig
Arguments
Name | Type | Description |
---|---|---|
_newMultisig | address | The new owner of the tokens & contract. |
Source Code
function updateMultisig(address _newMultisig) external onlyMultisig {
require(_newMultisig != address(0), "New Multisig address invalid.");
multisig = _newMultisig;
emit NewMultisig(msg.sender, _newMultisig);
}
Update Release Timestamp.
function updateReleaseTimestamp(uint256 _newReleaseTime) external nonpayable onlyMultisig
Arguments
Name | Type | Description |
---|---|---|
_newReleaseTime | uint256 | The new release timestamp for token release. |
Source Code
function updateReleaseTimestamp(uint256 _newReleaseTime) external onlyMultisig {
releaseTime = _newReleaseTime;
emit TokenReleaseUpdated(msg.sender, _newReleaseTime);
}
Update Deposit Limit.
function updateDepositLimit(uint256 _newDepositLimit) external nonpayable onlyMultisig
Arguments
Name | Type | Description |
---|---|---|
_newDepositLimit | uint256 | The new deposit limit. |
Source Code
function updateDepositLimit(uint256 _newDepositLimit) external onlyMultisig {
require(
_newDepositLimit >= totalDeposit,
"Deposit already higher than the limit trying to be set."
);
depositLimit = _newDepositLimit;
emit TokenDepositLimitUpdated(msg.sender, _newDepositLimit);
}
Deposit tokens to this contract by User.
function depositTokens(uint256 _amount) external nonpayable checkStatus
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 | the amount of tokens deposited. |
Source Code
function depositTokens(uint256 _amount) external checkStatus(Status.Deposit) {
require(_amount > 0, "Amount needs to be bigger than zero.");
uint256 amount = _amount;
if (totalDeposit.add(_amount) >= depositLimit) {
amount = depositLimit.sub(totalDeposit);
emit DepositLimitReached();
}
bool txStatus = SOV.transferFrom(msg.sender, address(this), amount);
require(txStatus, "Token transfer was not successful.");
userBalances[msg.sender] = userBalances[msg.sender].add(amount);
totalDeposit = totalDeposit.add(amount);
emit TokenDeposit(msg.sender, amount);
}
Update contract state to Holding.
function changeStateToHolding() external nonpayable onlyMultisig checkStatus
Source Code
function changeStateToHolding() external onlyMultisig checkStatus(Status.Deposit) {
status = Status.Holding;
emit EscrowInHoldingState();
}
Withdraws all token from the contract by Multisig.
function withdrawTokensByMultisig(address _receiverAddress) external nonpayable onlyMultisig checkStatus
Arguments
Name | Type | Description |
---|---|---|
_receiverAddress | address | The address where the tokens has to be transferred. Zero address if the withdraw is to be done in Multisig. |
Source Code
function withdrawTokensByMultisig(address _receiverAddress)
external
onlyMultisig
checkStatus(Status.Holding)
{
address receiverAddress = msg.sender;
if (_receiverAddress != address(0)) {
receiverAddress = _receiverAddress;
}
uint256 value = SOV.balanceOf(address(this));
/// Sending the amount to multisig.
bool txStatus = SOV.transfer(receiverAddress, value);
require(txStatus, "Token transfer was not successful. Check receiver address.");
emit TokenWithdrawByMultisig(msg.sender, value);
}
Deposit tokens to this contract by the Multisig.
function depositTokensByMultisig(uint256 _amount) external nonpayable onlyMultisig checkStatus
Arguments
Name | Type | Description |
---|---|---|
_amount | uint256 | the amount of tokens deposited. |
Source Code
function depositTokensByMultisig(uint256 _amount)
external
onlyMultisig
checkStatus(Status.Holding)
{
require(_amount > 0, "Amount needs to be bigger than zero.");
bool txStatus = SOV.transferFrom(msg.sender, address(this), _amount);
require(txStatus, "Token transfer was not successful.");
emit TokenDepositByMultisig(msg.sender, _amount);
if (SOV.balanceOf(address(this)) >= totalDeposit) {
status = Status.Withdraw;
emit EscrowInWithdrawState();
}
}
Withdraws token from the contract by User.
function withdrawTokens() public nonpayable checkRelease checkStatus
Source Code
function withdrawTokens() public checkRelease checkStatus(Status.Withdraw) {
uint256 amount = userBalances[msg.sender];
userBalances[msg.sender] = 0;
bool txStatus = SOV.transfer(msg.sender, amount);
require(txStatus, "Token transfer was not successful. Check receiver address.");
emit TokenWithdraw(msg.sender, amount);
}
Function to read the current token balance of a particular user.
function getUserBalance(address _addr) external view
returns(balance uint256)
Arguments
Name | Type | Description |
---|---|---|
_addr | address |
Returns
_addr The user address whose balance has to be checked.
Source Code
function getUserBalance(address _addr) external view returns (uint256 balance) {
return userBalances[_addr];
}
- Address
- Administered
- AdminRole
- AdvancedToken
- AdvancedTokenStorage
- Affiliates
- AffiliatesEvents
- ApprovalReceiver
- BProPriceFeed
- CheckpointsShared
- Constants
- Context
- DevelopmentFund
- DummyContract
- EnumerableAddressSet
- EnumerableBytes32Set
- EnumerableBytes4Set
- ERC20
- ERC20Detailed
- ErrorDecoder
- Escrow
- EscrowReward
- FeedsLike
- FeesEvents
- FeeSharingCollector
- FeeSharingCollectorProxy
- FeeSharingCollectorStorage
- FeesHelper
- FourYearVesting
- FourYearVestingFactory
- FourYearVestingLogic
- FourYearVestingStorage
- GenericTokenSender
- GovernorAlpha
- GovernorVault
- IApproveAndCall
- IChai
- IContractRegistry
- IConverterAMM
- IERC1820Registry
- IERC20_
- IERC20
- IERC777
- IERC777Recipient
- IERC777Sender
- IFeeSharingCollector
- IFourYearVesting
- IFourYearVestingFactory
- IFunctionsList
- ILiquidityMining
- ILiquidityPoolV1Converter
- ILoanPool
- ILoanToken
- ILoanTokenLogicBeacon
- ILoanTokenLogicModules
- ILoanTokenLogicProxy
- ILoanTokenModules
- ILoanTokenWRBTC
- ILockedSOV
- IMoCState
- IModulesProxyRegistry
- Initializable
- InterestUser
- IPot
- IPriceFeeds
- IPriceFeedsExt
- IProtocol
- IRSKOracle
- ISovryn
- ISovrynSwapNetwork
- IStaking
- ISwapsImpl
- ITeamVesting
- ITimelock
- IV1PoolOracle
- IVesting
- IVestingFactory
- IVestingRegistry
- IWrbtc
- IWrbtcERC20
- LenderInterestStruct
- LiquidationHelper
- LiquidityMining
- LiquidityMiningConfigToken
- LiquidityMiningProxy
- LiquidityMiningStorage
- LoanClosingsEvents
- LoanClosingsLiquidation
- LoanClosingsRollover
- LoanClosingsShared
- LoanClosingsWith
- LoanClosingsWithoutInvariantCheck
- LoanInterestStruct
- LoanMaintenance
- LoanMaintenanceEvents
- LoanOpenings
- LoanOpeningsEvents
- LoanParamsStruct
- LoanSettings
- LoanSettingsEvents
- LoanStruct
- LoanToken
- LoanTokenBase
- LoanTokenLogicBeacon
- LoanTokenLogicLM
- LoanTokenLogicProxy
- LoanTokenLogicStandard
- LoanTokenLogicStorage
- LoanTokenLogicWrbtc
- LoanTokenSettingsLowerAdmin
- LockedSOV
- MarginTradeStructHelpers
- Medianizer
- ModuleCommonFunctionalities
- ModulesCommonEvents
- ModulesProxy
- ModulesProxyRegistry
- MultiSigKeyHolders
- MultiSigWallet
- Mutex
- Objects
- OrderStruct
- OrigingVestingCreator
- OriginInvestorsClaim
- Ownable
- Pausable
- PausableOz
- PreviousLoanToken
- PreviousLoanTokenSettingsLowerAdmin
- PriceFeedRSKOracle
- PriceFeeds
- PriceFeedsLocal
- PriceFeedsMoC
- PriceFeedV1PoolOracle
- ProtocolAffiliatesInterface
- ProtocolLike
- ProtocolSettings
- ProtocolSettingsEvents
- ProtocolSettingsLike
- ProtocolSwapExternalInterface
- ProtocolTokenUser
- Proxy
- ProxyOwnable
- ReentrancyGuard
- RewardHelper
- RSKAddrValidator
- SafeERC20
- SafeMath
- SafeMath96
- setGet
- SharedReentrancyGuard
- SignedSafeMath
- SOV
- sovrynProtocol
- StakingAdminModule
- StakingGovernanceModule
- StakingInterface
- StakingProxy
- StakingRewards
- StakingRewardsProxy
- StakingRewardsStorage
- StakingShared
- StakingStakeModule
- StakingStorageModule
- StakingStorageShared
- StakingVestingModule
- StakingWithdrawModule
- State
- SwapsEvents
- SwapsExternal
- SwapsImplLocal
- SwapsImplSovrynSwap
- SwapsUser
- TeamVesting
- Timelock
- TimelockHarness
- TimelockInterface
- TokenSender
- UpgradableProxy
- USDTPriceFeed
- Utils
- VaultController
- Vesting
- VestingCreator
- VestingFactory
- VestingLogic
- VestingRegistry
- VestingRegistry2
- VestingRegistry3
- VestingRegistryLogic
- VestingRegistryProxy
- VestingRegistryStorage
- VestingStorage
- WeightedStakingModule
- WRBTC