xWin Fund
FundV2
userAvgPrice
struct userAvgPrice {
uint256 shares;
uint256 avgPrice;
}validInvestors
mapping(address => bool) validInvestorsWhitelisted addresses that can use the fund if openForPublic=false
performanceMap
mapping(address => struct FundV2.userAvgPrice) performanceMapUser average price, and share amount for performace fee calculations
waivedPerformanceFees
mapping(address => bool) waivedPerformanceFeesPriviliged addresses with fees waived for this fund (e.g. manager/platform)
TargetWeight
mapping(address => uint256) TargetWeightStores the weight of the target asset
targetAddr
address[] targetAddrArray containing target asset addresses
priceMaster
contract IxWinPriceMaster priceMasterAddress of price master
xWinSwap
contract IxWinSwap xWinSwapAddress of swap engine
lockingAddress
address lockingAddressAddress of locked staking contract, for performance fee discounts
managerAddr
address managerAddrAddress of manager wallet to receive management fees
managerRebAddr
address managerRebAddrAddress of manager account, which can execute manager only functions
platformWallet
address platformWalletAddress of platform wallet to receive platform fees
lastFeeCollection
uint256 lastFeeCollectionLast block where fees were collected
nextRebalance
uint256 nextRebalanceNext available block
pendingMFee
uint256 pendingMFeePending shares to award to manager
pendingPFee
uint256 pendingPFeePending shares to award to platform
managerFee
uint256 managerFeemanager fee in 4 decimals, e.g 100% = 10000
platformFee
uint256 platformFeeplatform fee in 4 decimals, e.g 100% = 10000
smallRatio
uint256 smallRatioperformFee
uint256 performFeeplatform fee in 4 decimals, e.g 100% = 10000
UPMultiplier
uint256 UPMultiplierUnit price multiplier
openForPublic
bool openForPublicReceived
event Received(address, uint256)ManagerFeeUpdate
event ManagerFeeUpdate(uint256 fromFee, uint256 toFee, uint256 txnTime)ManagerOwnerUpdate
event ManagerOwnerUpdate(address fromAddress, address toAddress, uint256 txnTime)initialize
function initialize(string _name, string _symbol, address _baseToken, address _USDAddr, address _manageraddr, address _managerRebaddr, address _platformWallet, address _lockedStaking) externalinit
function init(uint256 _managerFee, uint256 _performFee, uint256 _platformFee, bool _openForPublic, uint256 _UPMultiplier, uint256 _rebalancePeriod, uint256 _blocksPerDay, uint256 _smallRatio) externalcollectFundFee
function collectFundFee() externalMints management fee to manager wallet, sets pendingMFee to 0
collectPlatformFee
function collectPlatformFee() externalMints platform fee to platform wallet, sets pendingPFee to 0
_calcFundFee
function _calcFundFee() internalUpdates pending management/platform fee
createTargetNames
function createTargetNames(address[] _toAddr, uint256[] _targets) publicSets target token addresses and weights for the fund
Rebalance
function Rebalance(address[] _toAddr, uint256[] _targets, uint32 _slippage) publicPerforms rebalance with new weight and reset next rebalance period
Rebalance
function Rebalance(address[] _toAddr, uint256[] _targets) externaldeposit
function deposit(uint256 amount, uint32 _slippage) public returns (uint256)deposit
function deposit(uint256 amount) external returns (uint256)Deposits baseToken into the fund, and receives shares based on the fund's unitPrice
Parameters
amount
uint256
Amount of baseToken to deposit
Return Values
[0]
uint256
shares Amount of shares minted to depositor
_deposit
function _deposit(uint256 amount, uint32 _slippage) internal returns (uint256)withdraw
function withdraw(uint256 amount, uint32 _slippage) public returns (uint256)withdraw
function withdraw(uint256 amount) external returns (uint256)Withdraws from the fund by burning shares, liquidating assets into baseToken and transfering to user
Parameters
amount
uint256
Amount of shares to withdraw
Return Values
[0]
uint256
amount Amount of baseTokens transferred to depositor
_withdraw
function _withdraw(uint256 amount, uint32 _slippage) internal returns (uint256)MoveNonIndexNameToBase
function MoveNonIndexNameToBase(address _token, uint32 _slippage) external returns (uint256 balanceToken, uint256 swapOutput)fund owner move any name back to baseToken
emergencyRedeem
function emergencyRedeem(uint256 redeemUnit) externalget the proportional token without swapping it in emergency case
_getTransferAmt
function _getTransferAmt(address underying, uint256 redeemratio) internal view returns (struct xWinLib.transferData transData)Calc return balance during redemption
_getMintQty
function _getMintQty(uint256 _unitPrice) internal view returns (uint256 mintQty)Calc qty to issue during subscription
_getActiveOverWeight
function _getActiveOverWeight(address destAddr, uint256 totalvalue) internal view returns (uint256 destRebQty, uint256 destActiveWeight, bool overweight)Calculates the weight difference between the current fund and target
Parameters
destAddr
address
token address
totalvalue
uint256
fund vault value
Return Values
destRebQty
uint256
Amount of tokens to sell if overweight
destActiveWeight
uint256
amount of weight the token is off from target
overweight
bool
bool to indicate if token is overweight
_rebalance
function _rebalance(uint32 _slippage) internal_sellOverWeightNames
function _sellOverWeightNames(uint32 _slippage) internal returns (struct xWinLib.UnderWeightData[] underwgts, uint256 totalunderwgt)Sells overweight tokens
Parameters
_slippage
uint32
Slippage used for the swaps
Return Values
underwgts
struct xWinLib.UnderWeightData[]
Returns remaining underweighted tokens, and amount
totalunderwgt
uint256
Total underweighted sum
_buyUnderWeightNames
function _buyUnderWeightNames(struct xWinLib.UnderWeightData[] underweights, uint256 totalunderwgt, uint32 _slippage) internalBuys Underweighted tokens
_moveNonIndex
function _moveNonIndex(address _token, uint32 _slippage) internal returns (uint256 balanceToken, uint256 swapOutput)_getDeleteNames
function _getDeleteNames(address[] _toAddr) internal view returns (struct xWinLib.DeletedNames[] delNames)_convertTo18
function _convertTo18(uint256 value, address token) internal view returns (uint256)getEstimateShares
function getEstimateShares(uint256 _amt) external view returns (uint256 mintQty)Display estimate shares if deposit
getUnitPrice
function getUnitPrice() external view returns (uint256)The unitprice of a share of this fund in baseToken
_getUnitPrice
function _getUnitPrice(uint256 fundvalue) internal view returns (uint256)getUnitPriceInUSD
function getUnitPriceInUSD() external view returns (uint256)The unitprice of a share of this fund, in stablecoinUSDAddr
getLatestPrice
function getLatestPrice(address _targetAdd) external view returns (uint256)getVaultValues
function getVaultValues() external view returns (uint256)Gets the total value of the tokens within the fund, value shown in baseToken
getVaultValuesInUSD
function getVaultValuesInUSD() external view returns (uint256)Gets the total value of the tokens within the fund, value shown in stablecoinUSDAddr
getTokenValues
function getTokenValues(address tokenaddress) external view returns (uint256)return token value in the vault in base currency
getFundTotalSupply
function getFundTotalSupply() public view returns (uint256)Actual total supply, taking into account for fees
_getLatestPrice
function _getLatestPrice(address _targetAdd) internal view returns (uint256)_getLatestPriceInUSD
function _getLatestPriceInUSD(address _targetAdd) internal view returns (uint256)_getVaultValues
function _getVaultValues() internal view returns (uint256)_getVaultValuesInUSD
function _getVaultValuesInUSD() internal view returns (uint256)_getUP
function _getUP() internal view returns (uint256)_getUnitPrice
function _getUnitPrice() internal view returns (uint256)_getUPInUSD
function _getUPInUSD() internal view returns (uint256)_getTokenValues
function _getTokenValues(address token) internal view returns (uint256)_getTokenValuesInUSD
function _getTokenValuesInUSD(address token) internal view returns (uint256)getBalance
function getBalance(address fromAdd) public view returns (uint256)getTargetNamesAddress
function getTargetNamesAddress() external view returns (address[] _targetNamesAddress)getTargetWeightQty
function getTargetWeightQty(address targetAdd, uint256 srcQty) internal view returns (uint256)return target amount based on weight of each token in the fund
GetFundExtra
function GetFundExtra() external view returns (uint256 managementFee, uint256 performanceFee, uint256 platFee, address mAddr, address mRebAddr, address pWallet)Get All Extra the fund data needed for client
GetFundDataAll
function GetFundDataAll() external view returns (contract IERC20Upgradeable baseCcy, address[] targetAddress, uint256 totalUnitB4, uint256 baseBalance, uint256 unitprice, uint256 fundvalue, uint256 unitpriceUSD, uint256 fundvalueUSD, string fundName, string symbolName)Get All the fund data needed for client
setValidInvestor
function setValidInvestor(address _wallet, bool _allow) externalsetOpenForPublic
function setOpenForPublic(bool _allow) externalupdateOtherProperties
function updateOtherProperties(uint256 newCycle, uint256 _ratio, uint256 _UPMultiplier) externalupdateBlockPerday
function updateBlockPerday(uint256 _blocksPerDay) externalupdate average blocks per day value
updatePlatformProperty
function updatePlatformProperty(address _newAddr, uint256 _newFee) externalupdate platform fee and wallet
setPerformanceFee
function setPerformanceFee(uint256 _performFee) externalupdateManagerProperty
function updateManagerProperty(address newRebManager, address newManager, uint256 newFeebps) externalupdate manager fee and wallet
updatexWinEngines
function updatexWinEngines(address _priceMaster, address _xwinSwap) externalupdate xwin master contract
updateLockedStakingAddress
function updateLockedStakingAddress(address _lockedStaking) externalsetPerformDeposit
function setPerformDeposit(uint256 mintShares, uint256 latestUP) internalHandles performance fee logic, keeping record of deposits
Parameters
mintShares
uint256
Shares minted
latestUP
uint256
Unit price of fund
setPerformWithdraw
function setPerformWithdraw(uint256 swapOutput, uint256 _shares, address _investorAddress, address _managerAddress) internal returns (uint256)Handles performance fee logic, calculating profit after swap
Parameters
swapOutput
uint256
Amount of tokens received
_shares
uint256
Amount of shares burned
_investorAddress
address
User address that is withdrawing
_managerAddress
address
Address to receive performance fee
getUserAveragePrice
function getUserAveragePrice(address _user) external view returns (uint256 shares, uint256 avgPrice)Returns Users average price and shares
Parameters
_user
address
Address of the user
Return Values
shares
uint256
Total shares minted by the user
avgPrice
uint256
Average mint price
getDiscountedPerformFee
function getDiscountedPerformFee(address _user) public view returns (uint256 newPerformanceFee)Returns performance fee for user after applying discount
Parameters
_user
address
Address of the user
addContractWaiveFee
function addContractWaiveFee(address _contract) externalremoveContractWaiveFee
function removeContractWaiveFee(address _contract) externalreceive
receive() external payableonlyRebManager
modifier onlyRebManager()Last updated