- (ProtocolSettings.sol)
View Source: contracts/modules/ProtocolSettings.sol
↗ Extends: State, ProtocolTokenUser, ProtocolSettingsEvents, ModuleCommonFunctionalities
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 contains functions to customize protocol settings.
- constructor()
- constructor()
- initialize(address target)
- setSovrynProtocolAddress(address newProtocolAddress)
- setSOVTokenAddress(address newSovTokenAddress)
- setLockedSOVAddress(address newLockedSOVAddress)
- setTradingRebateRewardsBasisPoint(uint256 newBasisPoint)
- setMinReferralsToPayoutAffiliates(uint256 newMinReferrals)
- setPriceFeedContract(address newContract)
- setSwapsImplContract(address newContract)
- setLoanPool(address[] pools, address[] assets)
- setSupportedTokens(address[] addrs, bool[] toggles)
- setLendingFeePercent(uint256 newValue)
- setTradingFeePercent(uint256 newValue)
- setBorrowingFeePercent(uint256 newValue)
- setSwapExternalFeePercent(uint256 newValue)
- setAffiliateFeePercent(uint256 newValue)
- setAffiliateTradingTokenFeePercent(uint256 newValue)
- setLiquidationIncentivePercent(uint256 newValue)
- setMaxDisagreement(uint256 newValue)
- setSourceBuffer(uint256 newValue)
- setMaxSwapSize(uint256 newValue)
- setFeesController(address newController)
- withdrawFees(address[] tokens, address receiver)
- withdrawLendingFees(address token, address receiver, uint256 amount)
- withdrawTradingFees(address token, address receiver, uint256 amount)
- withdrawBorrowingFees(address token, address receiver, uint256 amount)
- withdrawProtocolToken(address receiver, uint256 amount)
- depositProtocolToken(uint256 amount)
- getLoanPoolsList(uint256 start, uint256 count)
- isLoanPool(address loanPool)
- setSovrynSwapContractRegistryAddress(address registryAddress)
- setWrbtcToken(address wrbtcTokenAddress)
- setProtocolTokenAddress(address _protocolTokenAddress)
- setRolloverBaseReward(uint256 baseRewardValue)
- setRebatePercent(uint256 rebatePercent)
- setSpecialRebates(address sourceToken, address destToken, uint256 specialRebatesPercent)
- getSpecialRebates(address sourceTokenAddress, address destTokenAddress)
- getProtocolAddress()
- getSovTokenAddress()
- getLockedSOVAddress()
- getFeeRebatePercent()
- togglePaused(bool paused)
- isProtocolPaused()
- getSwapExternalFeePercent()
- getTradingRebateRewardsBasisPoint()
- getDedicatedSOVRebate()
- setRolloverFlexFeePercent(uint256 newRolloverFlexFeePercent)
- getDefaultPathConversion(address sourceTokenAddress, address destTokenAddress)
- setDefaultPathConversion(IERC20[] defaultPath)
- removeDefaultPathConversion(address sourceTokenAddress, address destTokenAddress)
Empty public constructor.
function () public nonpayable
Source Code
constructor() public {}
Fallback function is to react to receiving value (rBTC).
function () external nonpayable
Source Code
function() external {
revert("fallback not allowed");
}
Set function selectors on target contract. *
function initialize(address target) external nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
target | address | The address of the target contract. |
Source Code
function initialize(address target) external onlyOwner {
address prevModuleContractAddress = logicTargets[this.setPriceFeedContract.selector];
_setTarget(this.setPriceFeedContract.selector, target);
_setTarget(this.setSwapsImplContract.selector, target);
_setTarget(this.setLoanPool.selector, target);
_setTarget(this.setSupportedTokens.selector, target);
_setTarget(this.setLendingFeePercent.selector, target);
_setTarget(this.setTradingFeePercent.selector, target);
_setTarget(this.setBorrowingFeePercent.selector, target);
_setTarget(this.setSwapExternalFeePercent.selector, target);
_setTarget(this.setAffiliateFeePercent.selector, target);
_setTarget(this.setAffiliateTradingTokenFeePercent.selector, target);
_setTarget(this.setLiquidationIncentivePercent.selector, target);
_setTarget(this.setMaxDisagreement.selector, target);
_setTarget(this.setSourceBuffer.selector, target);
_setTarget(this.setMaxSwapSize.selector, target);
_setTarget(this.setFeesController.selector, target);
_setTarget(this.withdrawFees.selector, target);
_setTarget(this.withdrawLendingFees.selector, target);
_setTarget(this.withdrawTradingFees.selector, target);
_setTarget(this.withdrawBorrowingFees.selector, target);
_setTarget(this.withdrawProtocolToken.selector, target);
_setTarget(this.depositProtocolToken.selector, target);
_setTarget(this.getLoanPoolsList.selector, target);
_setTarget(this.isLoanPool.selector, target);
_setTarget(this.setSovrynSwapContractRegistryAddress.selector, target);
_setTarget(this.setWrbtcToken.selector, target);
_setTarget(this.setProtocolTokenAddress.selector, target);
_setTarget(this.setRolloverBaseReward.selector, target);
_setTarget(this.setRebatePercent.selector, target);
_setTarget(this.setSpecialRebates.selector, target);
_setTarget(this.setSovrynProtocolAddress.selector, target);
_setTarget(this.setSOVTokenAddress.selector, target);
_setTarget(this.setLockedSOVAddress.selector, target);
_setTarget(this.setMinReferralsToPayoutAffiliates.selector, target);
_setTarget(this.getSpecialRebates.selector, target);
_setTarget(this.getProtocolAddress.selector, target);
_setTarget(this.getSovTokenAddress.selector, target);
_setTarget(this.getLockedSOVAddress.selector, target);
_setTarget(this.getFeeRebatePercent.selector, target);
_setTarget(this.togglePaused.selector, target);
_setTarget(this.isProtocolPaused.selector, target);
_setTarget(this.getSwapExternalFeePercent.selector, target);
_setTarget(this.setTradingRebateRewardsBasisPoint.selector, target);
_setTarget(this.getTradingRebateRewardsBasisPoint.selector, target);
_setTarget(this.getDedicatedSOVRebate.selector, target);
_setTarget(this.setRolloverFlexFeePercent.selector, target);
_setTarget(this.getDefaultPathConversion.selector, target);
_setTarget(this.setDefaultPathConversion.selector, target);
_setTarget(this.removeDefaultPathConversion.selector, target);
emit ProtocolModuleContractReplaced(prevModuleContractAddress, target, "ProtocolSettings");
}
function setSovrynProtocolAddress(address newProtocolAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newProtocolAddress | address |
Source Code
function setSovrynProtocolAddress(address newProtocolAddress)
external
onlyOwner
whenNotPaused
{
address oldProtocolAddress = protocolAddress;
protocolAddress = newProtocolAddress;
emit SetProtocolAddress(msg.sender, oldProtocolAddress, newProtocolAddress);
}
function setSOVTokenAddress(address newSovTokenAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newSovTokenAddress | address |
Source Code
function setSOVTokenAddress(address newSovTokenAddress) external onlyOwner whenNotPaused {
require(Address.isContract(newSovTokenAddress), "newSovTokenAddress not a contract");
address oldTokenAddress = sovTokenAddress;
sovTokenAddress = newSovTokenAddress;
emit SetSOVTokenAddress(msg.sender, oldTokenAddress, newSovTokenAddress);
}
function setLockedSOVAddress(address newLockedSOVAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newLockedSOVAddress | address |
Source Code
function setLockedSOVAddress(address newLockedSOVAddress) external onlyOwner whenNotPaused {
require(Address.isContract(newLockedSOVAddress), "newLockSOVAddress not a contract");
address oldLockedSOVAddress = lockedSOVAddress;
lockedSOVAddress = newLockedSOVAddress;
emit SetLockedSOVAddress(msg.sender, oldLockedSOVAddress, newLockedSOVAddress);
}
Set the basis point of trading rebate rewards (SOV), max value is 9999 (99.99% liquid, 0.01% vested). *
function setTradingRebateRewardsBasisPoint(uint256 newBasisPoint) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newBasisPoint | uint256 | Basis point value. |
Source Code
function setTradingRebateRewardsBasisPoint(uint256 newBasisPoint)
external
onlyOwner
whenNotPaused
{
require(newBasisPoint <= 9999, "value too high");
uint256 oldBasisPoint = tradingRebateRewardsBasisPoint;
tradingRebateRewardsBasisPoint = newBasisPoint;
emit SetTradingRebateRewardsBasisPoint(msg.sender, oldBasisPoint, newBasisPoint);
}
Update the minimum number of referrals to get affiliates rewards. *
function setMinReferralsToPayoutAffiliates(uint256 newMinReferrals) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newMinReferrals | uint256 | The new minimum number of referrals. |
Source Code
function setMinReferralsToPayoutAffiliates(uint256 newMinReferrals)
external
onlyOwner
whenNotPaused
{
uint256 oldMinReferrals = minReferralsToPayout;
minReferralsToPayout = newMinReferrals;
emit SetMinReferralsToPayoutAffiliates(msg.sender, oldMinReferrals, newMinReferrals);
}
Set the address of the Price Feed instance. *
function setPriceFeedContract(address newContract) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newContract | address | The address of the Price Feed new instance. |
Source Code
function setPriceFeedContract(address newContract) external onlyOwner whenNotPaused {
address oldContract = priceFeeds;
priceFeeds = newContract;
emit SetPriceFeedContract(msg.sender, oldContract, newContract);
}
Set the address of the asset swapper instance. *
function setSwapsImplContract(address newContract) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newContract | address | The address of the asset swapper new instance. |
Source Code
function setSwapsImplContract(address newContract) external onlyOwner whenNotPaused {
address oldContract = swapsImpl;
swapsImpl = newContract;
emit SetSwapsImplContract(msg.sender, oldContract, newContract);
}
Set a list of loan pools and its tokens. *
function setLoanPool(address[] pools, address[] assets) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
pools | address[] | The array of addresses of new loan pool instances. |
assets | address[] | The array of addresses of the corresponding underlying tokens. |
Source Code
function setLoanPool(address[] calldata pools, address[] calldata assets)
external
onlyOwner
whenNotPaused
{
require(pools.length == assets.length, "count mismatch");
for (uint256 i = 0; i < pools.length; i++) {
require(pools[i] != assets[i], "pool == asset");
require(pools[i] != address(0), "pool == 0");
require(
assets[i] != address(0) || loanPoolToUnderlying[pools[i]] != address(0),
"pool not exists"
);
if (assets[i] == address(0)) {
underlyingToLoanPool[loanPoolToUnderlying[pools[i]]] = address(0);
loanPoolToUnderlying[pools[i]] = address(0);
loanPoolsSet.removeAddress(pools[i]);
} else {
loanPoolToUnderlying[pools[i]] = assets[i];
underlyingToLoanPool[assets[i]] = pools[i];
loanPoolsSet.addAddress(pools[i]);
}
emit SetLoanPool(msg.sender, pools[i], assets[i]);
}
}
Set a list of supported tokens by populating the storage supportedTokens mapping. *
function setSupportedTokens(address[] addrs, bool[] toggles) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
addrs | address[] | The array of addresses of the tokens. |
toggles | bool[] | The array of flags indicating whether the corresponding token is supported or not. |
Source Code
function setSupportedTokens(address[] calldata addrs, bool[] calldata toggles)
external
onlyOwner
whenNotPaused
{
require(addrs.length == toggles.length, "count mismatch");
for (uint256 i = 0; i < addrs.length; i++) {
supportedTokens[addrs[i]] = toggles[i];
emit SetSupportedTokens(msg.sender, addrs[i], toggles[i]);
}
}
Set the value of lendingFeePercent storage variable. *
function setLendingFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for lendingFeePercent. |
Source Code
function setLendingFeePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = lendingFeePercent;
lendingFeePercent = newValue;
emit SetLendingFeePercent(msg.sender, oldValue, newValue);
}
Set the value of tradingFeePercent storage variable. *
function setTradingFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for tradingFeePercent. |
Source Code
function setTradingFeePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = tradingFeePercent;
tradingFeePercent = newValue;
emit SetTradingFeePercent(msg.sender, oldValue, newValue);
}
Set the value of borrowingFeePercent storage variable. *
function setBorrowingFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for borrowingFeePercent. |
Source Code
function setBorrowingFeePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = borrowingFeePercent;
borrowingFeePercent = newValue;
emit SetBorrowingFeePercent(msg.sender, oldValue, newValue);
}
Set the value of swapExtrernalFeePercent storage variable *
function setSwapExternalFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | the new value for swapExternalFeePercent |
Source Code
function setSwapExternalFeePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = swapExtrernalFeePercent;
swapExtrernalFeePercent = newValue;
emit SetSwapExternalFeePercent(msg.sender, oldValue, newValue);
}
Set the value of affiliateFeePercent storage variable. *
function setAffiliateFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for affiliateFeePercent. |
Source Code
function setAffiliateFeePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = affiliateFeePercent;
affiliateFeePercent = newValue;
emit SetAffiliateFeePercent(msg.sender, oldValue, newValue);
}
Set the value of affiliateTradingTokenFeePercent storage variable. *
function setAffiliateTradingTokenFeePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for affiliateTradingTokenFeePercent. |
Source Code
function setAffiliateTradingTokenFeePercent(uint256 newValue)
external
onlyOwner
whenNotPaused
{
require(newValue <= 10**20, "value too high");
uint256 oldValue = affiliateTradingTokenFeePercent;
affiliateTradingTokenFeePercent = newValue;
emit SetAffiliateTradingTokenFeePercent(msg.sender, oldValue, newValue);
}
Set the value of liquidationIncentivePercent storage variable. *
function setLiquidationIncentivePercent(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for liquidationIncentivePercent. |
Source Code
function setLiquidationIncentivePercent(uint256 newValue) external onlyOwner whenNotPaused {
require(newValue <= 10**20, "value too high");
uint256 oldValue = liquidationIncentivePercent;
liquidationIncentivePercent = newValue;
emit SetLiquidationIncentivePercent(msg.sender, oldValue, newValue);
}
Set the value of the maximum swap spread. *
function setMaxDisagreement(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for maxDisagreement. |
Source Code
function setMaxDisagreement(uint256 newValue) external onlyOwner whenNotPaused {
maxDisagreement = newValue;
}
Set the value of the maximum source buffer. *
function setSourceBuffer(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for the maximum source buffer. |
Source Code
function setSourceBuffer(uint256 newValue) external onlyOwner whenNotPaused {
sourceBuffer = newValue;
}
Set the value of the swap size limit. *
function setMaxSwapSize(uint256 newValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newValue | uint256 | The new value for the maximum swap size. |
Source Code
function setMaxSwapSize(uint256 newValue) external onlyOwner whenNotPaused {
uint256 oldValue = maxSwapSize;
maxSwapSize = newValue;
emit SetMaxSwapSize(msg.sender, oldValue, newValue);
}
Set the address of the feesController instance. *
function setFeesController(address newController) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newController | address | The new address of the feesController. |
Source Code
function setFeesController(address newController) external onlyOwner whenNotPaused {
address oldController = feesController;
feesController = newController;
emit SetFeesController(msg.sender, oldController, newController);
}
The feesController calls this function to withdraw fees from three sources: lending, trading and borrowing. The fees (except SOV) will be converted to wRBTC. For SOV, it will be deposited directly to feeSharingCollector from the protocol. *
function withdrawFees(address[] tokens, address receiver) external nonpayable whenNotPaused
returns(totalWRBTCWithdrawn uint256)
Arguments
Name | Type | Description |
---|---|---|
tokens | address[] | The array of address of the token instance. |
receiver | address | The address of the withdrawal recipient. * |
Returns
The withdrawn total amount in wRBTC
Source Code
function withdrawFees(address[] calldata tokens, address receiver)
external
whenNotPaused
returns (uint256 totalWRBTCWithdrawn)
{
require(msg.sender == feesController, "unauthorized");
for (uint256 i = 0; i < tokens.length; i++) {
uint256 lendingBalance = lendingFeeTokensHeld[tokens[i]];
if (lendingBalance > 0) {
lendingFeeTokensHeld[tokens[i]] = 0;
lendingFeeTokensPaid[tokens[i]] = lendingFeeTokensPaid[tokens[i]].add(
lendingBalance
);
}
uint256 tradingBalance = tradingFeeTokensHeld[tokens[i]];
if (tradingBalance > 0) {
tradingFeeTokensHeld[tokens[i]] = 0;
tradingFeeTokensPaid[tokens[i]] = tradingFeeTokensPaid[tokens[i]].add(
tradingBalance
);
}
uint256 borrowingBalance = borrowingFeeTokensHeld[tokens[i]];
if (borrowingBalance > 0) {
borrowingFeeTokensHeld[tokens[i]] = 0;
borrowingFeeTokensPaid[tokens[i]] = borrowingFeeTokensPaid[tokens[i]].add(
borrowingBalance
);
}
uint256 tempAmount = lendingBalance.add(tradingBalance).add(borrowingBalance);
if (tempAmount == 0) {
continue;
}
uint256 amountConvertedToWRBTC;
if (tokens[i] == address(sovTokenAddress)) {
IERC20(tokens[i]).approve(feesController, tempAmount);
IFeeSharingCollector(feesController).transferTokens(
address(sovTokenAddress),
uint96(tempAmount)
);
amountConvertedToWRBTC = 0;
} else {
if (tokens[i] == address(wrbtcToken)) {
amountConvertedToWRBTC = tempAmount;
IERC20(address(wrbtcToken)).safeTransfer(receiver, amountConvertedToWRBTC);
} else {
IERC20(tokens[i]).approve(protocolAddress, tempAmount);
(amountConvertedToWRBTC, ) = ProtocolSwapExternalInterface(protocolAddress)
.swapExternal(
tokens[i], // source token address
address(wrbtcToken), // dest token address
feesController, // set feeSharingCollector as receiver
protocolAddress, // protocol as the sender
tempAmount, // source token amount
0, // reqDestToken
0, // minReturn
"" // loan data bytes
);
/// Will revert if disagreement found.
IPriceFeeds(priceFeeds).checkPriceDisagreement(
tokens[i],
address(wrbtcToken),
tempAmount,
amountConvertedToWRBTC,
maxDisagreement
);
}
totalWRBTCWithdrawn = totalWRBTCWithdrawn.add(amountConvertedToWRBTC);
}
emit WithdrawFees(
msg.sender,
tokens[i],
receiver,
lendingBalance,
tradingBalance,
borrowingBalance,
amountConvertedToWRBTC
);
}
return totalWRBTCWithdrawn;
}
The feesController calls this function to withdraw fees accrued from lending operations. *
function withdrawLendingFees(address token, address receiver, uint256 amount) external nonpayable whenNotPaused
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
receiver | address | The address of the withdrawal recipient. |
amount | uint256 | The amount of fees to get, ignored if greater than balance. * |
Returns
Whether withdrawal was successful.
Source Code
function withdrawLendingFees(
address token,
address receiver,
uint256 amount
) external whenNotPaused returns (bool) {
require(msg.sender == feesController, "unauthorized");
uint256 withdrawAmount = amount;
uint256 balance = lendingFeeTokensHeld[token];
if (withdrawAmount > balance) {
withdrawAmount = balance;
}
if (withdrawAmount == 0) {
return false;
}
lendingFeeTokensHeld[token] = balance.sub(withdrawAmount);
lendingFeeTokensPaid[token] = lendingFeeTokensPaid[token].add(withdrawAmount);
IERC20(token).safeTransfer(receiver, withdrawAmount);
emit WithdrawLendingFees(msg.sender, token, receiver, withdrawAmount);
return true;
}
The feesController calls this function to withdraw fees accrued from trading operations. *
function withdrawTradingFees(address token, address receiver, uint256 amount) external nonpayable whenNotPaused
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
receiver | address | The address of the withdrawal recipient. |
amount | uint256 | The amount of fees to get, ignored if greater than balance. * |
Returns
Whether withdrawal was successful.
Source Code
function withdrawTradingFees(
address token,
address receiver,
uint256 amount
) external whenNotPaused returns (bool) {
require(msg.sender == feesController, "unauthorized");
uint256 withdrawAmount = amount;
uint256 balance = tradingFeeTokensHeld[token];
if (withdrawAmount > balance) {
withdrawAmount = balance;
}
if (withdrawAmount == 0) {
return false;
}
tradingFeeTokensHeld[token] = balance.sub(withdrawAmount);
tradingFeeTokensPaid[token] = tradingFeeTokensPaid[token].add(withdrawAmount);
IERC20(token).safeTransfer(receiver, withdrawAmount);
emit WithdrawTradingFees(msg.sender, token, receiver, withdrawAmount);
return true;
}
The feesController calls this function to withdraw fees accrued from borrowing operations. *
function withdrawBorrowingFees(address token, address receiver, uint256 amount) external nonpayable whenNotPaused
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
token | address | The address of the token instance. |
receiver | address | The address of the withdrawal recipient. |
amount | uint256 | The amount of fees to get, ignored if greater than balance. * |
Returns
Whether withdrawal was successful.
Source Code
function withdrawBorrowingFees(
address token,
address receiver,
uint256 amount
) external whenNotPaused returns (bool) {
require(msg.sender == feesController, "unauthorized");
uint256 withdrawAmount = amount;
uint256 balance = borrowingFeeTokensHeld[token];
if (withdrawAmount > balance) {
withdrawAmount = balance;
}
if (withdrawAmount == 0) {
return false;
}
borrowingFeeTokensHeld[token] = balance.sub(withdrawAmount);
borrowingFeeTokensPaid[token] = borrowingFeeTokensPaid[token].add(withdrawAmount);
IERC20(token).safeTransfer(receiver, withdrawAmount);
emit WithdrawBorrowingFees(msg.sender, token, receiver, withdrawAmount);
return true;
}
The owner calls this function to withdraw protocol tokens. *
function withdrawProtocolToken(address receiver, uint256 amount) external nonpayable onlyOwner whenNotPaused
returns(address, bool)
Arguments
Name | Type | Description |
---|---|---|
receiver | address | The address of the withdrawal recipient. |
amount | uint256 | The amount of tokens to get. * |
Returns
The protocol token address.
Source Code
function withdrawProtocolToken(address receiver, uint256 amount)
external
onlyOwner
whenNotPaused
returns (address, bool)
{
return _withdrawProtocolToken(receiver, amount);
}
The owner calls this function to deposit protocol tokens. *
function depositProtocolToken(uint256 amount) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
amount | uint256 | The tokens of fees to send. |
Source Code
function depositProtocolToken(uint256 amount) external onlyOwner whenNotPaused {
/// @dev Update local balance
protocolTokenHeld = protocolTokenHeld.add(amount);
/// @dev Send the tokens
IERC20(protocolTokenAddress).safeTransferFrom(msg.sender, address(this), amount);
}
Get a list of loan pools. *
function getLoanPoolsList(uint256 start, uint256 count) external view
returns(bytes32[])
Arguments
Name | Type | Description |
---|---|---|
start | uint256 | The offset. |
count | uint256 | The limit. * |
Returns
The array of loan pools.
Source Code
function getLoanPoolsList(uint256 start, uint256 count)
external
view
returns (bytes32[] memory)
{
return loanPoolsSet.enumerate(start, count);
}
Check whether a token is a pool token. *
function isLoanPool(address loanPool) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
loanPool | address | The token address to check. |
Source Code
function isLoanPool(address loanPool) external view returns (bool) {
return loanPoolToUnderlying[loanPool] != address(0);
}
Set the contract registry address of the SovrynSwap network. *
function setSovrynSwapContractRegistryAddress(address registryAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
registryAddress | address | the address of the registry contract. |
Source Code
function setSovrynSwapContractRegistryAddress(address registryAddress)
external
onlyOwner
whenNotPaused
{
require(Address.isContract(registryAddress), "registryAddress not a contract");
address oldSovrynSwapContractRegistryAddress = sovrynSwapContractRegistryAddress;
sovrynSwapContractRegistryAddress = registryAddress;
emit SetSovrynSwapContractRegistryAddress(
msg.sender,
oldSovrynSwapContractRegistryAddress,
sovrynSwapContractRegistryAddress
);
}
Set the wrBTC contract address. *
function setWrbtcToken(address wrbtcTokenAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
wrbtcTokenAddress | address | The address of the wrBTC contract. |
Source Code
function setWrbtcToken(address wrbtcTokenAddress) external onlyOwner whenNotPaused {
require(Address.isContract(wrbtcTokenAddress), "wrbtcTokenAddress not a contract");
address oldwrbtcToken = address(wrbtcToken);
wrbtcToken = IWrbtcERC20(wrbtcTokenAddress);
emit SetWrbtcToken(msg.sender, oldwrbtcToken, wrbtcTokenAddress);
}
Set the protocol token contract address. *
function setProtocolTokenAddress(address _protocolTokenAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
_protocolTokenAddress | address | The address of the protocol token contract. |
Source Code
function setProtocolTokenAddress(address _protocolTokenAddress)
external
onlyOwner
whenNotPaused
{
require(Address.isContract(_protocolTokenAddress), "_protocolTokenAddress not a contract");
address oldProtocolTokenAddress = protocolTokenAddress;
protocolTokenAddress = _protocolTokenAddress;
emit SetProtocolTokenAddress(msg.sender, oldProtocolTokenAddress, _protocolTokenAddress);
}
Set rollover base reward. It should be denominated in wrBTC. *
function setRolloverBaseReward(uint256 baseRewardValue) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
baseRewardValue | uint256 | The base reward. |
Source Code
function setRolloverBaseReward(uint256 baseRewardValue) external onlyOwner whenNotPaused {
require(baseRewardValue > 0, "Base reward is zero");
uint256 oldValue = rolloverBaseReward;
rolloverBaseReward = baseRewardValue;
emit SetRolloverBaseReward(msg.sender, oldValue, rolloverBaseReward);
}
Set the fee rebate percent. *
function setRebatePercent(uint256 rebatePercent) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
rebatePercent | uint256 | The fee rebate percent. |
Source Code
function setRebatePercent(uint256 rebatePercent) external onlyOwner whenNotPaused {
require(rebatePercent <= 10**20, "Fee rebate is too high");
uint256 oldRebatePercent = feeRebatePercent;
feeRebatePercent = rebatePercent;
emit SetRebatePercent(msg.sender, oldRebatePercent, rebatePercent);
}
Set the special fee rebate percent for specific pair *
function setSpecialRebates(address sourceToken, address destToken, uint256 specialRebatesPercent) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
sourceToken | address | |
destToken | address | |
specialRebatesPercent | uint256 | The new special fee rebate percent. |
Source Code
function setSpecialRebates(
address sourceToken,
address destToken,
uint256 specialRebatesPercent
) external onlyOwner whenNotPaused {
// Set max special rebates to 1000%
require(specialRebatesPercent <= 1000e18, "Special fee rebate is too high");
uint256 oldSpecialRebatesPercent = specialRebates[sourceToken][destToken];
specialRebates[sourceToken][destToken] = specialRebatesPercent;
emit SetSpecialRebates(
msg.sender,
sourceToken,
destToken,
oldSpecialRebatesPercent,
specialRebatesPercent
);
}
Get a rebate percent of specific pairs. *
function getSpecialRebates(address sourceTokenAddress, address destTokenAddress) external view
returns(specialRebatesPercent uint256)
Arguments
Name | Type | Description |
---|---|---|
sourceTokenAddress | address | The source of pairs. |
destTokenAddress | address | The dest of pairs. * |
Returns
The percent rebates of the pairs.
Source Code
function getSpecialRebates(address sourceTokenAddress, address destTokenAddress)
external
view
returns (uint256 specialRebatesPercent)
{
return specialRebates[sourceTokenAddress][destTokenAddress];
}
function getProtocolAddress() external view
returns(address)
Source Code
function getProtocolAddress() external view returns (address) {
return protocolAddress;
}
function getSovTokenAddress() external view
returns(address)
Source Code
function getSovTokenAddress() external view returns (address) {
return sovTokenAddress;
}
function getLockedSOVAddress() external view
returns(address)
Source Code
function getLockedSOVAddress() external view returns (address) {
return lockedSOVAddress;
}
function getFeeRebatePercent() external view
returns(uint256)
Source Code
function getFeeRebatePercent() external view returns (uint256) {
return feeRebatePercent;
}
function togglePaused(bool paused) external nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
paused | bool |
Source Code
function togglePaused(bool paused) external onlyOwner {
require(paused != pause, "Can't toggle");
pause = paused;
emit TogglePaused(msg.sender, !paused, paused);
}
function isProtocolPaused() external view
returns(bool)
Source Code
function isProtocolPaused() external view returns (bool) {
return pause;
}
function getSwapExternalFeePercent() external view
returns(uint256)
Source Code
function getSwapExternalFeePercent() external view returns (uint256) {
return swapExtrernalFeePercent;
}
Get the basis point of trading rebate rewards. *
function getTradingRebateRewardsBasisPoint() external view
returns(uint256)
Source Code
function getTradingRebateRewardsBasisPoint() external view returns (uint256) {
return tradingRebateRewardsBasisPoint;
}
If SOV balance is less than the fees held, it will return 0. *
function getDedicatedSOVRebate() public view
returns(uint256)
Source Code
function getDedicatedSOVRebate() public view returns (uint256) {
uint256 sovProtocolBalance = IERC20(sovTokenAddress).balanceOf(address(this));
uint256 sovFees =
lendingFeeTokensHeld[sovTokenAddress].add(tradingFeeTokensHeld[sovTokenAddress]).add(
borrowingFeeTokensHeld[sovTokenAddress]
);
return sovProtocolBalance >= sovFees ? sovProtocolBalance.sub(sovFees) : 0;
}
Set rolloverFlexFeePercent (max value is 1%) *
function setRolloverFlexFeePercent(uint256 newRolloverFlexFeePercent) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
newRolloverFlexFeePercent | uint256 | uint256 value of new rollover flex fee percentage (0.1 ether = 0.1%) |
Source Code
function setRolloverFlexFeePercent(uint256 newRolloverFlexFeePercent)
external
onlyOwner
whenNotPaused
{
require(newRolloverFlexFeePercent <= 1e18, "value too high");
uint256 oldRolloverFlexFeePercent = rolloverFlexFeePercent;
rolloverFlexFeePercent = newRolloverFlexFeePercent;
emit SetRolloverFlexFeePercent(
msg.sender,
oldRolloverFlexFeePercent,
newRolloverFlexFeePercent
);
}
Get default path conversion for pairs. *
function getDefaultPathConversion(address sourceTokenAddress, address destTokenAddress) external view
returns(contract IERC20[])
Arguments
Name | Type | Description |
---|---|---|
sourceTokenAddress | address | source token address. |
destTokenAddress | address | destination token address. * |
Returns
default path of the conversion.
Source Code
function getDefaultPathConversion(address sourceTokenAddress, address destTokenAddress)
external
view
returns (IERC20[] memory)
{
return defaultPathConversion[sourceTokenAddress][destTokenAddress];
}
Set default path conversion for pairs. *
function setDefaultPathConversion(IERC20[] defaultPath) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
defaultPath | IERC20[] | array of addresses for the default path. |
Source Code
function setDefaultPathConversion(IERC20[] calldata defaultPath)
external
onlyOwner
whenNotPaused
{
address sourceTokenAddress = address(defaultPath[0]);
address destTokenAddress = address(defaultPath[defaultPath.length - 1]);
uint256 defaultPathLength = defaultPath.length;
require(defaultPathLength >= 3, "ERR_PATH_LENGTH");
for (uint256 i = 0; i < defaultPathLength; i++) {
require(Address.isContract(address(defaultPath[i])), "ERR_PATH_NON_CONTRACT_ADDR");
}
defaultPathConversion[sourceTokenAddress][destTokenAddress] = defaultPath;
emit SetDefaultPathConversion(
msg.sender,
sourceTokenAddress,
destTokenAddress,
defaultPath
);
}
Remove the default path conversion for pairs *
function removeDefaultPathConversion(address sourceTokenAddress, address destTokenAddress) external nonpayable onlyOwner whenNotPaused
Arguments
Name | Type | Description |
---|---|---|
sourceTokenAddress | address | source token address. |
destTokenAddress | address | destination token address |
Source Code
function removeDefaultPathConversion(address sourceTokenAddress, address destTokenAddress)
external
onlyOwner
whenNotPaused
{
require(
defaultPathConversion[sourceTokenAddress][destTokenAddress].length > 0,
"DEFAULT_PATH_EMPTY"
);
IERC20[] memory defaultPathValue =
defaultPathConversion[sourceTokenAddress][destTokenAddress];
delete defaultPathConversion[sourceTokenAddress][destTokenAddress];
emit RemoveDefaultPathConversion(
msg.sender,
sourceTokenAddress,
destTokenAddress,
defaultPathValue
);
}
- 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