Skip to content

Latest commit

 

History

History
317 lines (296 loc) · 12.6 KB

State.md

File metadata and controls

317 lines (296 loc) · 12.6 KB

State contract. (State.sol)

View Source: contracts/core/State.sol

↗ Extends: Objects, ReentrancyGuard, SharedReentrancyGuard, Ownable ↘ Derived Contracts: Affiliates, FeesHelper, ISovryn, LiquidationHelper, LoanSettings, ModuleCommonFunctionalities, ProtocolSettings, ProtocolTokenUser, RewardHelper, sovrynProtocol, SwapsImplLocal, SwapsImplSovrynSwap, SwapsUser, VaultController

State contract

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 the storage values of the Protocol.

Contract Members

Constants & Variables

//public members
address public priceFeeds;
address public swapsImpl;
address public sovrynSwapContractRegistryAddress;
mapping(bytes4 => address) public logicTargets;
mapping(bytes32 => struct LoanStruct.Loan) public loans;
mapping(bytes32 => struct LoanParamsStruct.LoanParams) public loanParams;
mapping(address => mapping(bytes32 => struct OrderStruct.Order)) public lenderOrders;
mapping(address => mapping(bytes32 => struct OrderStruct.Order)) public borrowerOrders;
mapping(bytes32 => mapping(address => bool)) public delegatedManagers;
mapping(address => mapping(address => struct LenderInterestStruct.LenderInterest)) public lenderInterest;
mapping(bytes32 => struct LoanInterestStruct.LoanInterest) public loanInterest;
address public feesController;
uint256 public lendingFeePercent;
mapping(address => uint256) public lendingFeeTokensHeld;
mapping(address => uint256) public lendingFeeTokensPaid;
uint256 public tradingFeePercent;
mapping(address => uint256) public tradingFeeTokensHeld;
mapping(address => uint256) public tradingFeeTokensPaid;
uint256 public borrowingFeePercent;
mapping(address => uint256) public borrowingFeeTokensHeld;
mapping(address => uint256) public borrowingFeeTokensPaid;
uint256 public protocolTokenHeld;
uint256 public protocolTokenPaid;
uint256 public affiliateFeePercent;
uint256 public liquidationIncentivePercent;
mapping(address => address) public loanPoolToUnderlying;
mapping(address => address) public underlyingToLoanPool;
mapping(address => bool) public supportedTokens;
uint256 public maxDisagreement;
uint256 public sourceBuffer;
uint256 public maxSwapSize;
mapping(address => uint256) public borrowerNonce;
uint256 public rolloverBaseReward;
uint256 public rolloverFlexFeePercent;
contract IWrbtcERC20 public wrbtcToken;
address public protocolTokenAddress;
uint256 public feeRebatePercent;
address public admin;
address public protocolAddress;
mapping(address => bool) public userNotFirstTradeFlag;
mapping(address => address) public affiliatesUserReferrer;
uint256 public minReferralsToPayout;
mapping(address => uint256) public affiliateRewardsHeld;
address public sovTokenAddress;
address public lockedSOVAddress;
uint256 public affiliateTradingTokenFeePercent;
mapping(address => mapping(address => uint256)) public affiliatesReferrerBalances;
mapping(address => mapping(address => uint256)) public specialRebates;
bool public pause;

//internal members
struct EnumerableBytes32Set.Bytes32Set internal logicTargetsSet;
struct EnumerableBytes32Set.Bytes32Set internal activeLoansSet;
mapping(address => struct EnumerableBytes32Set.Bytes32Set) internal lenderLoanSets;
mapping(address => struct EnumerableBytes32Set.Bytes32Set) internal borrowerLoanSets;
mapping(address => struct EnumerableBytes32Set.Bytes32Set) internal userLoanParamSets;
struct EnumerableBytes32Set.Bytes32Set internal loanPoolsSet;
mapping(address => struct EnumerableAddressSet.AddressSet) internal referralsList;
mapping(address => struct EnumerableAddressSet.AddressSet) internal affiliatesReferrerTokensList;
uint256 internal swapExtrernalFeePercent;
uint256 internal tradingRebateRewardsBasisPoint;
mapping(address => mapping(address => contract IERC20[])) internal defaultPathConversion;

Functions


_setTarget

Add signature and target to storage.

function _setTarget(bytes4 sig, address target) internal nonpayable

Arguments

Name Type Description
sig bytes4
target address
Source Code
function _setTarget(bytes4 sig, address target) internal {
        logicTargets[sig] = target;

        if (target != address(0)) {
            logicTargetsSet.addBytes32(bytes32(sig));
        } else {
            logicTargetsSet.removeBytes32(bytes32(sig));
        }
    }

Contracts