- This contract pays loan interests. (InterestUser.sol)
View Source: contracts/mixins/InterestUser.sol
↗ Extends: VaultController, FeesHelper ↘ Derived Contracts: LoanClosingsShared, LoanMaintenance, LoanOpenings
Events
event PayInterestTransfer(address indexed interestToken, address indexed lender, uint256 effectiveInterest);
- _payInterest(address lender, address interestToken)
- _payInterestTransfer(address lender, address interestToken, uint256 interestOwedNow)
Internal function to pay interest of a loan.
function _payInterest(address lender, address interestToken) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
lender | address | The account address of the lender. |
interestToken | address | The token address to pay interest with. |
Source Code
function _payInterest(address lender, address interestToken) internal {
LenderInterest storage lenderInterestLocal = lenderInterest[lender][interestToken];
uint256 interestOwedNow = 0;
if (lenderInterestLocal.owedPerDay != 0 && lenderInterestLocal.updatedTimestamp != 0) {
interestOwedNow = block
.timestamp
.sub(lenderInterestLocal.updatedTimestamp)
.mul(lenderInterestLocal.owedPerDay)
.div(1 days);
lenderInterestLocal.updatedTimestamp = block.timestamp;
if (interestOwedNow > lenderInterestLocal.owedTotal)
interestOwedNow = lenderInterestLocal.owedTotal;
if (interestOwedNow != 0) {
lenderInterestLocal.paidTotal = lenderInterestLocal.paidTotal.add(interestOwedNow);
lenderInterestLocal.owedTotal = lenderInterestLocal.owedTotal.sub(interestOwedNow);
_payInterestTransfer(lender, interestToken, interestOwedNow);
}
} else {
lenderInterestLocal.updatedTimestamp = block.timestamp;
}
}
Internal function to transfer tokens for the interest of a loan.
function _payInterestTransfer(address lender, address interestToken, uint256 interestOwedNow) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
lender | address | The account address of the lender. |
interestToken | address | The token address to pay interest with. |
interestOwedNow | uint256 | The amount of interest to pay. |
Source Code
function _payInterestTransfer(
address lender,
address interestToken,
uint256 interestOwedNow
) internal {
uint256 lendingFee = interestOwedNow.mul(lendingFeePercent).div(10**20);
/// TODO: refactor: data incapsulation violation and DRY design principles
/// uint256 lendingFee = interestOwedNow.mul(lendingFeePercent).divCeil(10**20); is better but produces errors in tests because of this
_payLendingFee(lender, interestToken, lendingFee);
/// Transfers the interest to the lender, less the interest fee.
vaultWithdraw(interestToken, lender, interestOwedNow.sub(lendingFee));
/// Event Log
emit PayInterestTransfer(interestToken, lender, interestOwedNow.sub(lendingFee));
}
- 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