View Source: contracts/connectors/loantoken/modules/beaconLogicWRBTC/LoanTokenLogicWrbtc.sol
↗ Extends: LoanTokenLogicStandard
- getListFunctionSignatures()
- mintWithBTC(address receiver, bool useLM)
- burnToBTC(address receiver, uint256 burnAmount, bool useLM)
- _verifyTransfers(address collateralTokenAddress, struct MarginTradeStructHelpers.SentAddresses sentAddresses, struct MarginTradeStructHelpers.SentAmounts sentAmounts, uint256 withdrawalAmount)
This function is MANDATORY, which will be called by LoanTokenLogicBeacon and be registered. Every new public function, the sginature needs to be included in this function. *
function getListFunctionSignatures() external pure
returns(functionSignatures bytes4[], moduleName bytes32)
Source Code
function getListFunctionSignatures()
external
pure
returns (bytes4[] memory functionSignatures, bytes32 moduleName)
{
bytes4[] memory res = new bytes4[](32);
// Loan Token Logic Standard
res[0] = this.mint.selector;
res[1] = this.burn.selector;
res[2] = this.borrow.selector;
res[3] = this.marginTrade.selector;
res[4] = this.marginTradeAffiliate.selector;
res[5] = this.transfer.selector;
res[6] = this.transferFrom.selector;
res[7] = this.profitOf.selector;
res[8] = this.tokenPrice.selector;
res[9] = this.checkpointPrice.selector;
res[10] = this.marketLiquidity.selector;
res[11] = this.avgBorrowInterestRate.selector;
res[12] = this.borrowInterestRate.selector;
res[13] = this.nextBorrowInterestRate.selector;
res[14] = this.supplyInterestRate.selector;
res[15] = this.nextSupplyInterestRate.selector;
res[16] = this.totalSupplyInterestRate.selector;
res[17] = this.totalAssetBorrow.selector;
res[18] = this.totalAssetSupply.selector;
res[19] = this.getMaxEscrowAmount.selector;
res[20] = this.assetBalanceOf.selector;
res[21] = this.getEstimatedMarginDetails.selector;
res[22] = this.getDepositAmountForBorrow.selector;
res[23] = this.getBorrowAmountForDeposit.selector;
res[24] = this.checkPriceDivergence.selector;
res[25] = this.calculateSupplyInterestRate.selector;
// Loan Token WRBTC
res[26] = this.mintWithBTC.selector;
res[27] = this.burnToBTC.selector;
// Advanced Token
res[28] = this.approve.selector;
// Advanced Token Storage
res[29] = this.totalSupply.selector;
res[30] = this.balanceOf.selector;
res[31] = this.allowance.selector;
return (res, stringToBytes32("LoanTokenLogicWrbtc"));
}
function mintWithBTC(address receiver, bool useLM) external payable nonReentrant globallyNonReentrant
returns(mintAmount uint256)
Arguments
Name | Type | Description |
---|---|---|
receiver | address | |
useLM | bool |
Source Code
function mintWithBTC(address receiver, bool useLM)
external
payable
nonReentrant
globallyNonReentrant
returns (uint256 mintAmount)
{
if (useLM) return _mintWithLM(receiver, msg.value);
else return _mintToken(receiver, msg.value);
}
function burnToBTC(address receiver, uint256 burnAmount, bool useLM) external nonpayable nonReentrant globallyNonReentrant
returns(loanAmountPaid uint256)
Arguments
Name | Type | Description |
---|---|---|
receiver | address | |
burnAmount | uint256 | |
useLM | bool |
Source Code
function burnToBTC(
address receiver,
uint256 burnAmount,
bool useLM
) external nonReentrant globallyNonReentrant returns (uint256 loanAmountPaid) {
if (useLM) loanAmountPaid = _burnFromLM(burnAmount);
else loanAmountPaid = _burnToken(burnAmount);
if (loanAmountPaid != 0) {
IWrbtcERC20(wrbtcTokenAddress).withdraw(loanAmountPaid);
Address.sendValue(receiver, loanAmountPaid);
}
}
⤾ overrides LoanTokenLogicStandard._verifyTransfers
Handle transfers prior to adding newPrincipal to loanTokenSent. *
function _verifyTransfers(address collateralTokenAddress, struct MarginTradeStructHelpers.SentAddresses sentAddresses, struct MarginTradeStructHelpers.SentAmounts sentAmounts, uint256 withdrawalAmount) internal nonpayable
returns(msgValue uint256)
Arguments
Name | Type | Description |
---|---|---|
collateralTokenAddress | address | The address of the collateral token. |
sentAddresses | struct MarginTradeStructHelpers.SentAddresses | The struct which contains addresses of - lender - borrower - receiver - manager * |
sentAmounts | struct MarginTradeStructHelpers.SentAmounts | The struct which contains uint256 of: - interestRate - newPrincipal - interestInitialAmount - loanTokenSent - collateralTokenSent * |
withdrawalAmount | uint256 | The amount to withdraw. * |
Returns
msgValue The amount of value sent.
Source Code
function _verifyTransfers(
address collateralTokenAddress,
MarginTradeStructHelpers.SentAddresses memory sentAddresses,
MarginTradeStructHelpers.SentAmounts memory sentAmounts,
uint256 withdrawalAmount
) internal returns (uint256 msgValue) {
address _wrbtcToken = wrbtcTokenAddress;
address _loanTokenAddress = _wrbtcToken;
address receiver = sentAddresses.receiver;
uint256 newPrincipal = sentAmounts.newPrincipal;
uint256 loanTokenSent = sentAmounts.loanTokenSent;
uint256 collateralTokenSent = sentAmounts.collateralTokenSent;
require(_loanTokenAddress != collateralTokenAddress, "26");
msgValue = msg.value;
if (withdrawalAmount != 0) {
/// withdrawOnOpen == true
IWrbtcERC20(_wrbtcToken).withdraw(withdrawalAmount);
Address.sendValue(receiver, withdrawalAmount);
if (newPrincipal > withdrawalAmount) {
_safeTransfer(
_loanTokenAddress,
sovrynContractAddress,
newPrincipal - withdrawalAmount,
""
);
}
} else {
_safeTransfer(_loanTokenAddress, sovrynContractAddress, newPrincipal, "27");
}
if (collateralTokenSent != 0) {
_safeTransferFrom(
collateralTokenAddress,
msg.sender,
sovrynContractAddress,
collateralTokenSent,
"28"
);
}
if (loanTokenSent != 0) {
if (msgValue != 0 && msgValue >= loanTokenSent) {
IWrbtc(_wrbtcToken).deposit.value(loanTokenSent)();
_safeTransfer(_loanTokenAddress, sovrynContractAddress, loanTokenSent, "29");
msgValue -= loanTokenSent;
} else {
_safeTransferFrom(
_loanTokenAddress,
msg.sender,
sovrynContractAddress,
loanTokenSent,
"29"
);
}
}
}
- 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