xWin Fund
FundV2
userAvgPrice
struct userAvgPrice {
uint256 shares;
uint256 avgPrice;
}
validInvestors
mapping(address => bool) validInvestors
Whitelisted addresses that can use the fund if openForPublic=false
performanceMap
mapping(address => struct FundV2.userAvgPrice) performanceMap
User average price, and share amount for performace fee calculations
waivedPerformanceFees
mapping(address => bool) waivedPerformanceFees
Priviliged addresses with fees waived for this fund (e.g. manager/platform)
TargetWeight
mapping(address => uint256) TargetWeight
Stores the weight of the target asset
targetAddr
address[] targetAddr
Array containing target asset addresses
priceMaster
contract IxWinPriceMaster priceMaster
Address of price master
xWinSwap
contract IxWinSwap xWinSwap
Address of swap engine
lockingAddress
address lockingAddress
Address of locked staking contract, for performance fee discounts
managerAddr
address managerAddr
Address of manager wallet to receive management fees
managerRebAddr
address managerRebAddr
Address of manager account, which can execute manager only functions
platformWallet
address platformWallet
Address of platform wallet to receive platform fees
lastFeeCollection
uint256 lastFeeCollection
Last block where fees were collected
nextRebalance
uint256 nextRebalance
Next available block
pendingMFee
uint256 pendingMFee
Pending shares to award to manager
pendingPFee
uint256 pendingPFee
Pending shares to award to platform
managerFee
uint256 managerFee
manager fee in 4 decimals, e.g 100% = 10000
platformFee
uint256 platformFee
platform fee in 4 decimals, e.g 100% = 10000
smallRatio
uint256 smallRatio
performFee
uint256 performFee
platform fee in 4 decimals, e.g 100% = 10000
UPMultiplier
uint256 UPMultiplier
Unit price multiplier
openForPublic
bool openForPublic
Received
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) external
init
function init(uint256 _managerFee, uint256 _performFee, uint256 _platformFee, bool _openForPublic, uint256 _UPMultiplier, uint256 _rebalancePeriod, uint256 _blocksPerDay, uint256 _smallRatio) external
collectFundFee
function collectFundFee() external
Mints management fee to manager wallet, sets pendingMFee to 0
collectPlatformFee
function collectPlatformFee() external
Mints platform fee to platform wallet, sets pendingPFee to 0
_calcFundFee
function _calcFundFee() internal
Updates pending management/platform fee
createTargetNames
function createTargetNames(address[] _toAddr, uint256[] _targets) public
Sets target token addresses and weights for the fund
Rebalance
function Rebalance(address[] _toAddr, uint256[] _targets, uint32 _slippage) public
Performs rebalance with new weight and reset next rebalance period
Rebalance
function Rebalance(address[] _toAddr, uint256[] _targets) external
deposit
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) external
get 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) internal
Buys 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) external
setOpenForPublic
function setOpenForPublic(bool _allow) external
updateOtherProperties
function updateOtherProperties(uint256 newCycle, uint256 _ratio, uint256 _UPMultiplier) external
updateBlockPerday
function updateBlockPerday(uint256 _blocksPerDay) external
update average blocks per day value
updatePlatformProperty
function updatePlatformProperty(address _newAddr, uint256 _newFee) external
update platform fee and wallet
setPerformanceFee
function setPerformanceFee(uint256 _performFee) external
updateManagerProperty
function updateManagerProperty(address newRebManager, address newManager, uint256 newFeebps) external
update manager fee and wallet
updatexWinEngines
function updatexWinEngines(address _priceMaster, address _xwinSwap) external
update xwin master contract
updateLockedStakingAddress
function updateLockedStakingAddress(address _lockedStaking) external
setPerformDeposit
function setPerformDeposit(uint256 mintShares, uint256 latestUP) internal
Handles 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) external
removeContractWaiveFee
function removeContractWaiveFee(address _contract) external
receive
receive() external payable
onlyRebManager
modifier onlyRebManager()
Last updated