- (LoanTokenLogicBeacon.sol)
View Source: contracts/connectors/loantoken/LoanTokenLogicBeacon.sol
↗ Extends: PausableOz
This contract stored the target logic implementation of LoanTokens which has the same logic implementation (LoanTokenLogicLM / LoanTokenLogicWrbtc) Apart from storing the target logic implementation, this contract also has a pause functionality. By implementing pause/unpause functionality in this beacon contract, we can pause the loan token that has the same Logic (LoanTokenLogicLM / LoanTokenLogicWrbtc) at one call. Meanwhile the pause/unpause function in the LoanTokenLogicProxy is used to pause/unpause specific LoanToken
struct LoanTokenLogicModuleUpdate {
address implementation,
uint256 updateTimestamp
}
Constants & Variables
//private members
mapping(bytes4 => address) private logicTargets;
mapping(bytes32 => struct EnumerableBytes4Set.Bytes4Set) private activeFuncSignatureList;
//public members
mapping(bytes32 => struct LoanTokenLogicBeacon.LoanTokenLogicModuleUpdate[]) public moduleUpgradeLog;
mapping(bytes32 => uint256) public activeModuleIndex;
Modifier to make a function callable only when the contract is not paused. This is the overriden function from the pausable contract, so that we can use custom error message.
modifier whenNotPaused() internal
- registerLoanTokenModule(address loanTokenModuleAddress)
- _registerLoanTokenModule(address loanTokenModuleAddress)
- getActiveFuncSignatureList(bytes32 moduleName)
- getModuleUpgradeLogLength(bytes32 moduleName)
- rollback(bytes32 moduleName, uint256 index)
- getTarget(bytes4 sig)
- getListFunctionSignatures()
Register the loanTokenModule (LoanTokenSettingsLowerAdmin, LoanTokenLogicLM / LoanTokenLogicWrbtc, etc) *
function registerLoanTokenModule(address loanTokenModuleAddress) external nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
loanTokenModuleAddress | address | The module target address |
Source Code
function registerLoanTokenModule(address loanTokenModuleAddress) external onlyOwner {
bytes32 moduleName = _registerLoanTokenModule(loanTokenModuleAddress);
// Store the upgrade to the log
moduleUpgradeLog[moduleName].push(
LoanTokenLogicModuleUpdate(loanTokenModuleAddress, block.timestamp)
);
activeModuleIndex[moduleName] = moduleUpgradeLog[moduleName].length - 1;
}
Register the loanTokenModule (LoanTokenSettingsLowerAdmin, LoanTokenLogicLM / LoanTokenLogicWrbtc, etc) *
function _registerLoanTokenModule(address loanTokenModuleAddress) private nonpayable
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
loanTokenModuleAddress | address | the target logic of the loan token module * |
Returns
the module name
Source Code
function _registerLoanTokenModule(address loanTokenModuleAddress) private returns (bytes32) {
require(
Address.isContract(loanTokenModuleAddress),
"LoanTokenModuleAddress is not a contract"
);
// Get the list of function signature on this loanTokenModulesAddress
(bytes4[] memory functionSignatureList, bytes32 moduleName) =
ILoanTokenLogicModules(loanTokenModuleAddress).getListFunctionSignatures();
/// register / update the module function signature address implementation
for (uint256 i; i < functionSignatureList.length; i++) {
require(functionSignatureList[i] != bytes4(0x0), "ERR_EMPTY_FUNC_SIGNATURE");
logicTargets[functionSignatureList[i]] = loanTokenModuleAddress;
if (!activeFuncSignatureList[moduleName].contains(functionSignatureList[i]))
activeFuncSignatureList[moduleName].addBytes4(functionSignatureList[i]);
}
/// delete the "removed" module function signature in the current implementation
bytes4[] memory activeSignatureListEnum =
activeFuncSignatureList[moduleName].enumerate(
0,
activeFuncSignatureList[moduleName].length()
);
for (uint256 i; i < activeSignatureListEnum.length; i++) {
bytes4 activeSigBytes = activeSignatureListEnum[i];
if (logicTargets[activeSigBytes] != loanTokenModuleAddress) {
logicTargets[activeSigBytes] = address(0);
activeFuncSignatureList[moduleName].removeBytes4(activeSigBytes);
}
}
return moduleName;
}
get all active function signature list based on the module name. *
function getActiveFuncSignatureList(bytes32 moduleName) public view
returns(signatureList bytes4[])
Arguments
Name | Type | Description |
---|---|---|
moduleName | bytes32 | in bytes32. * |
Returns
the array of function signature.
Source Code
function getActiveFuncSignatureList(bytes32 moduleName)
public
view
returns (bytes4[] memory signatureList)
{
signatureList = activeFuncSignatureList[moduleName].enumerate(
0,
activeFuncSignatureList[moduleName].length()
);
return signatureList;
}
Get total length of the module upgrade log. *
function getModuleUpgradeLogLength(bytes32 moduleName) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
moduleName | bytes32 | in bytes32. * |
Returns
length of module upgrade log.
Source Code
function getModuleUpgradeLogLength(bytes32 moduleName) external view returns (uint256) {
return moduleUpgradeLog[moduleName].length;
}
This function will rollback particular module to the spesific index / version of deployment *
function rollback(bytes32 moduleName, uint256 index) external nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
moduleName | bytes32 | Name of module in bytes32 format |
index | uint256 | index / version of previous deployment |
Source Code
function rollback(bytes32 moduleName, uint256 index) external onlyOwner {
address loanTokenModuleAddress = moduleUpgradeLog[moduleName][index].implementation;
moduleName = _registerLoanTokenModule(loanTokenModuleAddress);
activeModuleIndex[moduleName] = index;
}
External getter for target addresses.
function getTarget(bytes4 sig) external view whenNotPaused
returns(address)
Arguments
Name | Type | Description |
---|---|---|
sig | bytes4 | The signature. |
Returns
The address for a given signature.
Source Code
function getTarget(bytes4 sig) external view whenNotPaused returns (address) {
return logicTargets[sig];
}
function getListFunctionSignatures() external pure
returns(bytes4[], moduleName bytes32)
Source Code
function getListFunctionSignatures()
external
pure
returns (bytes4[] memory, bytes32 moduleName);
- 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