# xWin Defi (Helper)

### Context

#### constructor

```solidity
constructor() internal
```

#### \_msgSender

```solidity
function _msgSender() internal view returns (address payable)
```

#### \_msgData

```solidity
function _msgData() internal view returns (bytes)
```

### Ownable

\_Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions.

By default, the owner account will be the one that deploys the contract. This can later be changed with {transferOwnership}.

This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.\_

#### OwnershipTransferred

```solidity
event OwnershipTransferred(address previousOwner, address newOwner)
```

#### constructor

```solidity
constructor() internal
```

*Initializes the contract setting the deployer as the initial owner.*

#### owner

```solidity
function owner() public view returns (address)
```

*Returns the address of the current owner.*

#### onlyOwner

```solidity
modifier onlyOwner()
```

*Throws if called by any account other than the owner.*

#### renounceOwnership

```solidity
function renounceOwnership() public
```

\_Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner.

NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\_

#### transferOwnership

```solidity
function transferOwnership(address newOwner) public
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### \_transferOwnership

```solidity
function _transferOwnership(address newOwner) internal
```

*Transfers ownership of the contract to a new account (`newOwner`).*

### ReentrancyGuard

\_Contract module that helps prevent reentrant calls to a function.

Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier available, which can be applied to functions to make sure there are no nested (reentrant) calls to them.

Note that because there is a single `nonReentrant` guard, functions marked as `nonReentrant` may not call one another. This can be worked around by making those functions `private`, and then adding `external` `nonReentrant` entry points to them.

TIP: If you would like to learn more about reentrancy and alternative ways to protect against it, check out our blog post <https://blog.openzeppelin.com/reentrancy-after-istanbul/\\[Reentrancy> After Istanbul].\_

#### constructor

```solidity
constructor() internal
```

#### nonReentrant

```solidity
modifier nonReentrant()
```

*Prevents a contract from calling itself, directly or indirectly. Calling a `nonReentrant` function from another `nonReentrant` function is not supported. It is possible to prevent this from happening by making the `nonReentrant` function external, and make it call a `private` function that does the actual work.*

### SafeMath

\_Wrappers over Solidity's arithmetic operations with added overflow checks.

Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. `SafeMath` restores this intuition by reverting the transaction when an operation overflows.

Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.\_

#### add

```solidity
function add(uint256 a, uint256 b) internal pure returns (uint256)
```

\_Returns the addition of two unsigned integers, reverting on overflow.

Counterpart to Solidity's `+` operator.

Requirements:

* Addition cannot overflow.\_

#### sub

```solidity
function sub(uint256 a, uint256 b) internal pure returns (uint256)
```

\_Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative).

Counterpart to Solidity's `-` operator.

Requirements:

* Subtraction cannot overflow.\_

#### sub

```solidity
function sub(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)
```

\_Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative).

Counterpart to Solidity's `-` operator.

Requirements:

* Subtraction cannot overflow.\_

#### mul

```solidity
function mul(uint256 a, uint256 b) internal pure returns (uint256)
```

\_Returns the multiplication of two unsigned integers, reverting on overflow.

Counterpart to Solidity's `*` operator.

Requirements:

* Multiplication cannot overflow.\_

#### div

```solidity
function div(uint256 a, uint256 b) internal pure returns (uint256)
```

\_Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero.

Counterpart to Solidity's `/` operator. Note: this function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

* The divisor cannot be zero.\_

#### div

```solidity
function div(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)
```

\_Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero.

Counterpart to Solidity's `/` operator. Note: this function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

* The divisor cannot be zero.\_

#### mod

```solidity
function mod(uint256 a, uint256 b) internal pure returns (uint256)
```

\_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero.

Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

* The divisor cannot be zero.\_

#### mod

```solidity
function mod(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)
```

\_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero.

Counterpart to Solidity's `%` operator. This function uses a `revert` opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

* The divisor cannot be zero.\_

#### min

```solidity
function min(uint256 x, uint256 y) internal pure returns (uint256 z)
```

#### sqrt

```solidity
function sqrt(uint256 y) internal pure returns (uint256 z)
```

### Address

*Collection of functions related to the address type*

#### isContract

```solidity
function isContract(address account) internal view returns (bool)
```

\_Returns true if `account` is a contract.

## \[IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract.

Among others, `isContract` will return false for the following types of addresses:

* an externally-owned account
* a contract in construction
* an address where a contract will be created
* an address where a contract lived, but was destroyed ====\_

#### sendValue

```solidity
function sendValue(address payable recipient, uint256 amount) internal
```

\_Replacement for Solidity's `transfer`: sends `amount` wei to `recipient`, forwarding all available gas and reverting on errors.

<https://eips.ethereum.org/EIPS/eip-1884\\[EIP1884>] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by `transfer`, making them unable to receive funds via `transfer`. {sendValue} removes this limitation.

<https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/\\[Learn> more].

IMPORTANT: because control is transferred to `recipient`, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the <https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern\\[checks-effects-interactions> pattern].\_

#### functionCall

```solidity
function functionCall(address target, bytes data) internal returns (bytes)
```

\_Performs a Solidity function call using a low level `call`. A plain`call` is an unsafe replacement for a function call: use this function instead.

If `target` reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls).

Returns the raw returned data. To convert to the expected return value, use <https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions\\[`abi.decode`>].

Requirements:

* `target` must be a contract.
* calling `target` with `data` must not revert.

*Available since v3.1.*\_

#### functionCall

```solidity
function functionCall(address target, bytes data, string errorMessage) internal returns (bytes)
```

\_Same as {xref-Address-functionCall-address-bytes-}\[`functionCall`], but with `errorMessage` as a fallback revert reason when `target` reverts.

*Available since v3.1.*\_

#### functionCallWithValue

```solidity
function functionCallWithValue(address target, bytes data, uint256 value) internal returns (bytes)
```

\_Same as {xref-Address-functionCall-address-bytes-}\[`functionCall`], but also transferring `value` wei to `target`.

Requirements:

* the calling contract must have an ETH balance of at least `value`.
* the called Solidity function must be `payable`.

*Available since v3.1.*\_

#### functionCallWithValue

```solidity
function functionCallWithValue(address target, bytes data, uint256 value, string errorMessage) internal returns (bytes)
```

\_Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}\[`functionCallWithValue`], but with `errorMessage` as a fallback revert reason when `target` reverts.

*Available since v3.1.*\_

### IBEP20

#### totalSupply

```solidity
function totalSupply() external view returns (uint256)
```

*Returns the amount of tokens in existence.*

#### decimals

```solidity
function decimals() external view returns (uint8)
```

*Returns the token decimals.*

#### symbol

```solidity
function symbol() external view returns (string)
```

*Returns the token symbol.*

#### name

```solidity
function name() external view returns (string)
```

*Returns the token name.*

#### getOwner

```solidity
function getOwner() external view returns (address)
```

*Returns the bep token owner.*

#### balanceOf

```solidity
function balanceOf(address account) external view returns (uint256)
```

*Returns the amount of tokens owned by `account`.*

#### transfer

```solidity
function transfer(address recipient, uint256 amount) external returns (bool)
```

\_Moves `amount` tokens from the caller's account to `recipient`.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.\_

#### allowance

```solidity
function allowance(address _owner, address spender) external view returns (uint256)
```

\_Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default.

This value changes when {approve} or {transferFrom} are called.\_

#### approve

```solidity
function approve(address spender, uint256 amount) external returns (bool)
```

\_Sets `amount` as the allowance of `spender` over the caller's tokens.

Returns a boolean value indicating whether the operation succeeded.

IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: <https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729>

Emits an {Approval} event.\_

#### transferFrom

```solidity
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool)
```

\_Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event.\_

#### Transfer

```solidity
event Transfer(address from, address to, uint256 value)
```

\_Emitted when `value` tokens are moved from one account (`from`) to another (`to`).

Note that `value` may be zero.\_

#### Approval

```solidity
event Approval(address owner, address spender, uint256 value)
```

*Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.*

### SafeBEP20

*Wrappers around BEP20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a `using SafeBEP20 for IBEP20;` statement to your contract, which allows you to call the safe operations as `token.safeTransfer(...)`, etc.*

#### safeTransfer

```solidity
function safeTransfer(contract IBEP20 token, address to, uint256 value) internal
```

#### safeTransferFrom

```solidity
function safeTransferFrom(contract IBEP20 token, address from, address to, uint256 value) internal
```

#### safeApprove

```solidity
function safeApprove(contract IBEP20 token, address spender, uint256 value) internal
```

\_Deprecated. This function has issues similar to the ones found in {IBEP20-approve}, and its usage is discouraged.

Whenever possible, use {safeIncreaseAllowance} and {safeDecreaseAllowance} instead.\_

#### safeIncreaseAllowance

```solidity
function safeIncreaseAllowance(contract IBEP20 token, address spender, uint256 value) internal
```

#### safeDecreaseAllowance

```solidity
function safeDecreaseAllowance(contract IBEP20 token, address spender, uint256 value) internal
```

### xWinLib

#### PoolInfo

```solidity
struct PoolInfo {
  address lpToken;
  uint256 rewardperblock;
  uint256 multiplier;
}
```

#### UserInfo

```solidity
struct UserInfo {
  uint256 amount;
  uint256 blockstart;
}
```

#### TradeParams

```solidity
struct TradeParams {
  address xFundAddress;
  uint256 amount;
  uint256 priceImpactTolerance;
  uint256 deadline;
  bool returnInBase;
  address referral;
}
```

#### transferData

```solidity
struct transferData {
  address[] targetNamesAddress;
  uint256 totalTrfAmt;
  uint256 totalUnderlying;
  uint256 qtyToTrfAToken;
}
```

#### xWinReward

```solidity
struct xWinReward {
  uint256 blockstart;
  uint256 accBasetoken;
  uint256 accMinttoken;
  uint256 previousRealizedQty;
}
```

#### xWinReferral

```solidity
struct xWinReferral {
  address referral;
}
```

#### UnderWeightData

```solidity
struct UnderWeightData {
  uint256 activeWeight;
  uint256 fundWeight;
  bool overweight;
  address token;
}
```

#### DeletedNames

```solidity
struct DeletedNames {
  address token;
  uint256 targetWeight;
}
```

#### PancakePriceToken

```solidity
struct PancakePriceToken {
  string tokenname;
  address addressToken;
}
```

### TransferHelper

#### safeApprove

```solidity
function safeApprove(address token, address to, uint256 value) internal
```

#### safeTransfer

```solidity
function safeTransfer(address token, address to, uint256 value) internal
```

#### safeTransferFrom

```solidity
function safeTransferFrom(address token, address from, address to, uint256 value) internal
```

#### safeTransferBNB

```solidity
function safeTransferBNB(address to, uint256 value) internal
```

### xWinFund

#### getManagerFee

```solidity
function getManagerFee() external view returns (uint256)
```

#### getTargetWeight

```solidity
function getTargetWeight(address addr) external view returns (uint256)
```

#### getWhoIsManager

```solidity
function getWhoIsManager() external view returns (address mangerAddress)
```

#### getBalance

```solidity
function getBalance(address fromAdd) external view returns (uint256 balance)
```

#### getFundValues

```solidity
function getFundValues() external view returns (uint256)
```

#### getTargetWeightQty

```solidity
function getTargetWeightQty(address targetAdd, uint256 srcQty) external view returns (uint256)
```

#### updateManager

```solidity
function updateManager(address managerAdd) external payable
```

#### updateManagerFee

```solidity
function updateManagerFee(uint256 newFeebps) external payable
```

#### updateRebalancePeriod

```solidity
function updateRebalancePeriod(uint256 newCycle) external payable
```

#### updateProtocol

```solidity
function updateProtocol(address _newProtocol) external
```

#### Redeem

```solidity
function Redeem(struct xWinLib.TradeParams _tradeParams, address _investorAddress) external payable returns (uint256)
```

#### Rebalance

```solidity
function Rebalance(address[] _toAddresses, uint256[] _targetWeight, uint256 deadline, uint256 priceImpactTolerance) external payable returns (uint256 baseccyBal)
```

#### Subscribe

```solidity
function Subscribe(struct xWinLib.TradeParams _tradeParams, address _investorAddress) external payable returns (uint256)
```

#### MoveNonIndexNameToBase

```solidity
function MoveNonIndexNameToBase(address _tokenaddress, uint256 deadline, uint256 priceImpactTolerance) external returns (uint256 balanceToken, uint256 swapOutput)
```

#### CreateTargetNames

```solidity
function CreateTargetNames(address[] _toAddresses, uint256[] _targetWeight) external payable
```

#### emergencyRedeem

```solidity
function emergencyRedeem(uint256 redeemUnit, address _investorAddress) external payable
```

#### emergencyRemoveFromFarm

```solidity
function emergencyRemoveFromFarm() external
```

#### getUnitPrice

```solidity
function getUnitPrice() external view returns (uint256 unitprice)
```

#### getUnitPriceInUSD

```solidity
function getUnitPriceInUSD() external view returns (uint256 unitprice)
```

#### getTargetNamesAddress

```solidity
function getTargetNamesAddress() external view returns (address[] _targetNamesAddress)
```

### xWinStake

#### StakeReward

```solidity
function StakeReward(address payable _investorAddress, uint256 rewardQty, uint256 bnbQty, uint256 deadline) external payable
```

#### GetQuotes

```solidity
function GetQuotes(uint256 rewardQty, uint256 baseQty, address targetToken) external view returns (uint256 amountB, uint256 amountA, uint256 amountOut)
```

### xWinDefiProtocol

#### name

```solidity
string name
```

#### xWinToken

```solidity
address xWinToken
```

#### xwinBenefitPool

```solidity
address xwinBenefitPool
```

#### startblock

```solidity
uint256 startblock
```

#### emergencyOn

```solidity
bool emergencyOn
```

#### userInfo

```solidity
mapping(uint256 => mapping(address => struct xWinLib.UserInfo)) userInfo
```

#### isxwinFund

```solidity
mapping(address => bool) isxwinFund
```

#### poolInfo

```solidity
struct xWinLib.PoolInfo[] poolInfo
```

#### xWinRewards

```solidity
mapping(address => struct xWinLib.xWinReward) xWinRewards
```

#### xWinReferral

```solidity
mapping(address => struct xWinLib.xWinReferral) xWinReferral
```

#### rewardRemaining

```solidity
uint256 rewardRemaining
```

#### Received

```solidity
event Received(address, uint256)
```

#### \_MoveNonIndexNameToBaseEvent

```solidity
event _MoveNonIndexNameToBaseEvent(address from, address toFund, address tokenAddress, uint256 amount, uint256 swapOutput)
```

#### \_RebalanceAllInOne

```solidity
event _RebalanceAllInOne(address from, address toFund, uint256 baseBalance, uint256 txnTime)
```

#### \_Subscribe

```solidity
event _Subscribe(address from, address toFund, uint256 subsAmt, uint256 mintQty)
```

#### \_Redeem

```solidity
event _Redeem(address from, address toFund, uint256 redeemUnit, uint256 rewardQty, uint256 redeemratio)
```

#### \_CreateTarget

```solidity
event _CreateTarget(address from, address toFund, address[] newTargets, uint256[] newWeight, uint256 txnTime)
```

#### \_StakeMyReward

```solidity
event _StakeMyReward(address from, uint256 rewardQty)
```

#### \_WithdrawReward

```solidity
event _WithdrawReward(address from, uint256 rewardQty)
```

#### \_DepositFarm

```solidity
event _DepositFarm(address from, uint256 pid, uint256 amount)
```

#### \_WithdrawFarm

```solidity
event _WithdrawFarm(address from, uint256 pid, uint256 amount)
```

#### \_EmergencyRedeem

```solidity
event _EmergencyRedeem(address user, address fundaddress, uint256 amount)
```

#### onlyEmergency

```solidity
modifier onlyEmergency()
```

#### onlyNonEmergency

```solidity
modifier onlyNonEmergency()
```

#### constructor

```solidity
constructor(uint256 _platformFeeBps, address _platformWallet, address _xwinBenefitPool, address _stakeAddress, address _xWinToken) public
```

#### receive

```solidity
receive() external payable
```

#### addxwinFund

```solidity
function addxwinFund(address[] _fundaddress, bool[] _isxwinFund) public
```

#### poolLength

```solidity
function poolLength() external view returns (uint256)
```

#### add

```solidity
function add(address _lpToken, uint256 _rewardperblock, uint256 _multiplier) public
```

#### emergencyWithdraw

```solidity
function emergencyWithdraw(uint256 _pid) public
```

#### updateRewardPerBlock

```solidity
function updateRewardPerBlock(uint256 _rewardperblock) external
```

*reward per block by deployer*

#### updateEmergencyState

```solidity
function updateEmergencyState(bool _state) external
```

*turn on emerrgency state by deployer*

#### updateProtocol

```solidity
function updateProtocol(address _fundaddress, address _newProtocol) external
```

*update xwin defi protocol*

#### updateFarmPoolInfo

```solidity
function updateFarmPoolInfo(uint256 _pid, uint256 _rewardperblock, uint256 _multiplier) external
```

*create or update farm pool fee by deployer*

#### getAllPendingXwin

```solidity
function getAllPendingXwin(address _user) public view returns (uint256)
```

*View function to see all pending xWin token earn on frontend.*

#### pendingXwin

```solidity
function pendingXwin(uint256 _pid, address _user) public view returns (uint256)
```

*View function to see pending xWin on frontend.*

#### DepositFarm

```solidity
function DepositFarm(uint256 _pid, uint256 _amount) public
```

*Deposit LP tokens to xWin Protocol for xWin allocation.*

#### WithdrawFarm

```solidity
function WithdrawFarm(uint256 _pid, uint256 _amount) public
```

*Withdraw LP tokens from xWin Protocol.*

#### Subscribe

```solidity
function Subscribe(struct xWinLib.TradeParams _tradeParams) public payable
```

*perform subscription based on ratio setup and put into lending if available*

#### Redeem

```solidity
function Redeem(struct xWinLib.TradeParams _tradeParams) external payable
```

*perform redemption based on unit redeem*

#### emergencyRedeem

```solidity
function emergencyRedeem(uint256 _redeemAmount, address _fundaddress) external payable
```

*perform redemption based on unit redeem and give up all xwin rewards*

#### emergencyRemoveFromFarm

```solidity
function emergencyRemoveFromFarm(address _fundaddress) external payable
```

*manager perform remove from farm for emergency state*

#### MoveNonIndexNameToBase

```solidity
function MoveNonIndexNameToBase(address xFundAddress, address _tokenaddress, uint256 deadline, uint256 priceImpactTolerance) external payable
```

*perform MoveNonIndexNameTo BNB for non benchmark name*

#### CreateTarget

```solidity
function CreateTarget(address[] _toAddresses, uint256[] _targetWeight, address xFundAddress) external
```

*create target ratio by portfolio manager*

#### RebalanceAllInOne

```solidity
function RebalanceAllInOne(struct xWinLib.TradeParams _tradeParams, address[] _toAddresses, uint256[] _targetWeight) external payable
```

*perform update target, move non-bm to base and finally rebalance*

#### updatePlatformFee

```solidity
function updatePlatformFee(uint256 newPlatformFee) external
```

*update platform fee by deployer*

#### getPlatformFee

```solidity
function getPlatformFee() external view returns (uint256)
```

*get platform fee*

#### getPlatformAddress

```solidity
function getPlatformAddress() external view returns (address)
```

*get platform wallet address*

#### gexWinBenefitPool

```solidity
function gexWinBenefitPool() external view returns (address)
```

*get platform wallet address*

#### updateXwinBenefitPool

```solidity
function updateXwinBenefitPool(address _xwinBenefitPool) external
```

*update platform fee by deployer*

#### updateRewardRemaining

```solidity
function updateRewardRemaining(uint256 _newRemaining) external
```

*update rewardRemaining by deployer*

#### updateStakeProtocol

```solidity
function updateStakeProtocol(address newStakeProtocol) external
```

*update platform fee by deployer*

#### updateReferralRewardPerUnit

```solidity
function updateReferralRewardPerUnit(uint256 _referralperunit) external
```

*update referal fee by deployer*

#### updateManagerRewardPerUnit

```solidity
function updateManagerRewardPerUnit(uint256 _managerRewardperunit) external
```

*update manager reward by deployer*

#### \_multiplier

```solidity
function _multiplier(uint256 _blockstart) internal view returns (uint256)
```

#### GetEstimateReward

```solidity
function GetEstimateReward(address fromAddress) public view returns (uint256)
```

*get estimated reward of XWN token*

#### GetQuotes

```solidity
function GetQuotes(uint256 tokenBal, address targetToken) external view returns (uint256 amountB, uint256 amountA)
```

#### StakeMyReward

```solidity
function StakeMyReward(uint256 deadline) external payable
```

*User to claim the reward and stake them into DEX*

#### \_updateReferralReward

```solidity
function _updateReferralReward(struct xWinLib.TradeParams _tradeParams, address _managerAddress) internal
```

#### WithdrawReward

```solidity
function WithdrawReward() external payable
```

*withdraw reward of XWN token*

#### \_storeRewardQty

```solidity
function _storeRewardQty(address from, uint256 baseQty, uint256 mintQty) internal
```

#### \_updateRewardBal

```solidity
function _updateRewardBal(address from, uint256 redeemUnit) internal returns (uint256 rewardQty)
```

#### ProtocolTransfer

```solidity
function ProtocolTransfer(address _newProtocol, uint256 amount) public payable
```

*emergency trf XWN token to new protocol*

#### \_sendRewards

```solidity
function _sendRewards(address _to, uint256 amount) internal
```

#### \_resetRewards

```solidity
function _resetRewards(address _from) internal
```
