xWinDefi

xWinDefi Protocol served the main connector with off-chain UI and each vault generated in xWinFund or xWinFarm protocol. It provides main interface for:

Struct TradeParam is used to pass in the parameter needed into the method from front end UI

struct TradeParams {
address xFundAddress;
uint256 amount;
uint256 priceImpactTolerance;
uint256 deadline;
bool returnInBase;
address referral;
}
  • Subscription

function Subscribe(xWinLib.TradeParams memory _tradeParams) public nonReentrant onlyNonEmergency payable
  • Redemption

function Redeem(xWinLib.TradeParams memory _tradeParams) external nonReentrant onlyNonEmergency payable
  • Rebalance

function RebalanceAllInOne(
xWinLib.TradeParams memory _tradeParams,
address[] calldata _toAddresses,
uint256[] calldata _targetWeight
) external nonReentrant onlyNonEmergency payable
  • CreateTarget

function CreateTarget(
address[] calldata _toAddresses,
uint256[] calldata _targetWeight,
address xFundAddress
) external nonReentrant onlyNonEmergency
  1. DepositFarm

function DepositFarm(uint256 _pid, uint256 _amount) public nonReentrant onlyNonEmergency
  1. WithdrawFarm

function WithdrawFarm(uint256 _pid, uint256 _amount) public nonReentrant onlyNonEmergency
  1. AddPool (Only setup by owner)

function add(address _lpToken, uint256 _rewardperblock, uint256 _multiplier) public onlyOwner onlyNonEmergency

xWinDefi protocol handle the rewards calculation for the users that use the platform. This includes the farming rewards, referral rewards and basic rewards of using xwin platform

Initial 60,000,000 XWIN token are minted to this contract. This is being used for rewards purpose until the balance is zero.

All the xWinFund has to be registered in xWinDefi to ensure the fund are belongs to XWIN platform. This is to avoid any unauthorized fund deployed to misuse the reward system in XWIN eco-system.

xWinDefi protocol is designed to be flexible for upgrade in the future. During the upgrade process, admin of the contract can set the emergency state to true. Admin can migrate the existing xWinFund into the newly deployed xWinDefi by calling updateProtocol

function updateProtocol(address _fundaddress, address _newProtocol) external onlyOwner {
xWinFund _xWinFund = xWinFund(_fundaddress);
_xWinFund.updateProtocol(_newProtocol);
}

ProtocolTransfer is provided in the contract to move the XWIN balance into new protocol by admin in case of xWinDefi protocol has to be upgraded.