xWin Defi (Helper)
Context
constructor
_msgSender
_msgData
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
constructor
Initializes the contract setting the deployer as the initial owner.
owner
Returns the address of the current owner.
onlyOwner
Throws if called by any account other than the owner.
renounceOwnership
_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
Transfers ownership of the contract to a new account (newOwner
). Can only be called by the current owner.
_transferOwnership
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
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
_Returns the addition of two unsigned integers, reverting on overflow.
Counterpart to Solidity's +
operator.
Requirements:
Addition cannot overflow._
sub
_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
_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
_Returns the multiplication of two unsigned integers, reverting on overflow.
Counterpart to Solidity's *
operator.
Requirements:
Multiplication cannot overflow._
div
_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
_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
_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
_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
sqrt
Address
Collection of functions related to the address type
isContract
_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
_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
_Performs a Solidity function call using a low level call
. A plaincall
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
withdata
must not revert.
Available since v3.1._
functionCall
_Same as {xref-Address-functionCall-address-bytes-}[functionCall
], but with errorMessage
as a fallback revert reason when target
reverts.
Available since v3.1._
functionCallWithValue
_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
_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
Returns the amount of tokens in existence.
decimals
Returns the token decimals.
symbol
Returns the token symbol.
name
Returns the token name.
getOwner
Returns the bep token owner.
balanceOf
Returns the amount of tokens owned by account
.
transfer
_Moves amount
tokens from the caller's account to recipient
.
Returns a boolean value indicating whether the operation succeeded.
Emits a {Transfer} event._
allowance
_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
_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
_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
_Emitted when value
tokens are moved from one account (from
) to another (to
).
Note that value
may be zero._
Approval
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
safeTransferFrom
safeApprove
_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
safeDecreaseAllowance
xWinLib
PoolInfo
UserInfo
TradeParams
transferData
xWinReward
xWinReferral
UnderWeightData
DeletedNames
PancakePriceToken
TransferHelper
safeApprove
safeTransfer
safeTransferFrom
safeTransferBNB
xWinFund
getManagerFee
getTargetWeight
getWhoIsManager
getBalance
getFundValues
getTargetWeightQty
updateManager
updateManagerFee
updateRebalancePeriod
updateProtocol
Redeem
Rebalance
Subscribe
MoveNonIndexNameToBase
CreateTargetNames
emergencyRedeem
emergencyRemoveFromFarm
getUnitPrice
getUnitPriceInUSD
getTargetNamesAddress
xWinStake
StakeReward
GetQuotes
xWinDefiProtocol
name
xWinToken
xwinBenefitPool
startblock
emergencyOn
userInfo
isxwinFund
poolInfo
xWinRewards
xWinReferral
rewardRemaining
Received
_MoveNonIndexNameToBaseEvent
_RebalanceAllInOne
_Subscribe
_Redeem
_CreateTarget
_StakeMyReward
_WithdrawReward
_DepositFarm
_WithdrawFarm
_EmergencyRedeem
onlyEmergency
onlyNonEmergency
constructor
receive
addxwinFund
poolLength
add
emergencyWithdraw
updateRewardPerBlock
reward per block by deployer
updateEmergencyState
turn on emerrgency state by deployer
updateProtocol
update xwin defi protocol
updateFarmPoolInfo
create or update farm pool fee by deployer
getAllPendingXwin
View function to see all pending xWin token earn on frontend.
pendingXwin
View function to see pending xWin on frontend.
DepositFarm
Deposit LP tokens to xWin Protocol for xWin allocation.
WithdrawFarm
Withdraw LP tokens from xWin Protocol.
Subscribe
perform subscription based on ratio setup and put into lending if available
Redeem
perform redemption based on unit redeem
emergencyRedeem
perform redemption based on unit redeem and give up all xwin rewards
emergencyRemoveFromFarm
manager perform remove from farm for emergency state
MoveNonIndexNameToBase
perform MoveNonIndexNameTo BNB for non benchmark name
CreateTarget
create target ratio by portfolio manager
RebalanceAllInOne
perform update target, move non-bm to base and finally rebalance
updatePlatformFee
update platform fee by deployer
getPlatformFee
get platform fee
getPlatformAddress
get platform wallet address
gexWinBenefitPool
get platform wallet address
updateXwinBenefitPool
update platform fee by deployer
updateRewardRemaining
update rewardRemaining by deployer
updateStakeProtocol
update platform fee by deployer
updateReferralRewardPerUnit
update referal fee by deployer
updateManagerRewardPerUnit
update manager reward by deployer
_multiplier
GetEstimateReward
get estimated reward of XWN token
GetQuotes
StakeMyReward
User to claim the reward and stake them into DEX
_updateReferralReward
WithdrawReward
withdraw reward of XWN token
_storeRewardQty
_updateRewardBal
ProtocolTransfer
emergency trf XWN token to new protocol
_sendRewards
_resetRewards
Last updated