View Source: contracts/mixins/VaultController.sol
↗ Extends: State ↘ Derived Contracts: InterestUser, LoanClosingsShared, LoanMaintenance, LoanOpenings, SwapsExternal
This contract code comes from bZx. bZx is a protocol for tokenized margin trading and lending https://bzx.network similar to the dYdX protocol.
- This contract implements functionality to deposit and withdraw wrBTC and other tokens from the vault.
Events
event VaultDeposit(address indexed asset, address indexed from, uint256 amount);
event VaultWithdraw(address indexed asset, address indexed to, uint256 amount);
- vaultEtherDeposit(address from, uint256 value)
- vaultEtherWithdraw(address to, uint256 value)
- vaultDeposit(address token, address from, uint256 value)
- vaultWithdraw(address token, address to, uint256 value)
- vaultTransfer(address token, address from, address to, uint256 value)
- vaultApprove(address token, address to, uint256 value)
Deposit wrBTC into the vault. *
function vaultEtherDeposit(address from, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
from | address | The address of the account paying the deposit. |
value | uint256 | The amount of wrBTC tokens to transfer. |
Source Code
function vaultEtherDeposit(address from, uint256 value) internal {
IWrbtcERC20 _wrbtcToken = wrbtcToken;
_wrbtcToken.deposit.value(value)();
emit VaultDeposit(address(_wrbtcToken), from, value);
}
Withdraw wrBTC from the vault. *
function vaultEtherWithdraw(address to, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
to | address | The address of the recipient. |
value | uint256 | The amount of wrBTC tokens to transfer. |
Source Code
function vaultEtherWithdraw(address to, uint256 value) internal {
if (value != 0) {
IWrbtcERC20 _wrbtcToken = wrbtcToken;
uint256 balance = address(this).balance;
if (value > balance) {
_wrbtcToken.withdraw(value - balance);
}
Address.sendValue(to, value);
emit VaultWithdraw(address(_wrbtcToken), to, value);
}
}
Deposit tokens into the vault. *
function vaultDeposit(address token, address from, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
from | address | The address of the account paying the deposit. |
value | uint256 | The amount of tokens to transfer. |
Source Code
function vaultDeposit(
address token,
address from,
uint256 value
) internal {
if (value != 0) {
IERC20(token).safeTransferFrom(from, address(this), value);
emit VaultDeposit(token, from, value);
}
}
Withdraw tokens from the vault. *
function vaultWithdraw(address token, address to, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
to | address | ken The address of the token instance. |
value | uint256 | The amount of tokens to transfer. |
Source Code
function vaultWithdraw(
address token,
address to,
uint256 value
) internal {
if (value != 0) {
IERC20(token).safeTransfer(to, value);
emit VaultWithdraw(token, to, value);
}
}
Transfer tokens from an account into another one. *
function vaultTransfer(address token, address from, address to, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
from | address | The address of the account paying. |
to | address | ken The address of the token instance. |
value | uint256 | The amount of tokens to transfer. |
Source Code
function vaultTransfer(
address token,
address from,
address to,
uint256 value
) internal {
if (value != 0) {
if (from == address(this)) {
IERC20(token).safeTransfer(to, value);
} else {
IERC20(token).safeTransferFrom(from, to, value);
}
}
}
Approve an allowance of tokens to be spent by an account. *
function vaultApprove(address token, address to, uint256 value) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
to | address | ken The address of the token instance. |
value | uint256 | The amount of tokens to allow. |
Source Code
function vaultApprove(
address token,
address to,
uint256 value
) internal {
if (value != 0 && IERC20(token).allowance(address(this), to) != 0) {
IERC20(token).safeApprove(to, 0);
}
IERC20(token).safeApprove(to, value);
}
- 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