# xWin BBMA (BSC)

### xWinBBMA

#### TradeQueue

```solidity
struct TradeQueue {
  bool nextTrade;
  uint256 nextTradeBlock;
  uint8 tradeType;
}
```

#### targetToken

```solidity
contract IERC20Upgradeable targetToken
```

#### swapEngine

```solidity
contract IxWinSwap swapEngine
```

#### xWinPriceMaster

```solidity
contract IxWinPriceMaster xWinPriceMaster
```

#### executors

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

#### tradeQueue

```solidity
struct xWinBBMA.TradeQueue tradeQueue
```

#### maxPerSwap

```solidity
uint256 maxPerSwap
```

#### tradeCycle

```solidity
uint256 tradeCycle
```

#### stopLossPrice

```solidity
uint256 stopLossPrice
```

#### takeProfitPrice

```solidity
uint256 takeProfitPrice
```

#### stopLossPerc

```solidity
uint256 stopLossPerc
```

#### takeProfitPerc

```solidity
uint256 takeProfitPerc
```

#### initialize

```solidity
function initialize(address _baseToken, contract IERC20Upgradeable _targetToken, address _swapEngine, address _USDTokenAddr, address _xWinPriceMaster, uint256 _managerFee, uint256 _performanceFee, uint256 _collectionPeriod, address _managerAddr) external
```

#### onlyExecutor

```solidity
modifier onlyExecutor()
```

#### checkUpkeep

```solidity
function checkUpkeep(bytes) external view returns (bool upkeepNeeded, bytes performData)
```

#### performUpkeep

```solidity
function performUpkeep(bytes) external
```

#### updatexWinPriceMaster

```solidity
function updatexWinPriceMaster(address _xWinPriceMaster) external
```

*update xwin master contract*

#### deposit

```solidity
function deposit(uint256 _amount) external returns (uint256)
```

#### deposit

```solidity
function deposit(uint256 _amount, uint32 _slippage) public returns (uint256)
```

#### \_deposit

```solidity
function _deposit(uint256 _amount, uint32 _slippage) internal returns (uint256)
```

#### systemReTrade

```solidity
function systemReTrade() external
```

#### systemTrade

```solidity
function systemTrade(uint8 _tradeType) public
```

Triggered offchain when there is a signal buy or close-buy

#### \_systemTrade

```solidity
function _systemTrade(uint8 _tradeType) internal
```

#### \_setStopLossBuy

```solidity
function _setStopLossBuy(uint256 _rate) internal
```

#### \_setTakeProfitBuy

```solidity
function _setTakeProfitBuy(uint256 _rate) internal
```

#### getTriggerTakeProfit

```solidity
function getTriggerTakeProfit() public view returns (bool)
```

#### getTriggerStopLoss

```solidity
function getTriggerStopLoss() public view returns (bool)
```

#### getVaultValues

```solidity
function getVaultValues() public view returns (uint256 vaultValue)
```

Gets the total value of the tokens within the fund, value shown in baseToken

#### getVaultValuesInUSD

```solidity
function getVaultValuesInUSD() public view returns (uint256 vaultValue)
```

Gets the total value of the tokens within the fund, value shown in stablecoinUSDAddr

#### \_getVaultValues

```solidity
function _getVaultValues() internal view returns (uint256 vaultValue)
```

#### \_getVaultValuesInUSD

```solidity
function _getVaultValuesInUSD() internal view returns (uint256 vaultValue)
```

#### getStableValues

```solidity
function getStableValues() public view returns (uint256 vaultValue)
```

#### getTargetValues

```solidity
function getTargetValues() public view returns (uint256 vaultValue)
```

#### withdraw

```solidity
function withdraw(uint256 _shares) external returns (uint256)
```

Withdraws from funds from the Cake Vault

**Parameters**

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| \_shares | uint256 |             |

#### withdraw

```solidity
function withdraw(uint256 _shares, uint32 _slippage) public returns (uint256)
```

#### \_withdraw

```solidity
function _withdraw(uint256 _shares, uint32 _slippage) internal returns (uint256)
```

#### emergencyUnWindPosition

```solidity
function emergencyUnWindPosition() external
```

#### setProperties

```solidity
function setProperties(uint256 _stopLossPerc, uint256 _takeProfitPerc, uint256 _tradeCycle, uint256 _maxPerSwap) public
```

#### setExecutor

```solidity
function setExecutor(address _wallet, bool _allow) external
```

#### setSwapEngine

```solidity
function setSwapEngine(address _newSwapEngine) external
```

#### getUnitPrice

```solidity
function getUnitPrice() public view returns (uint256)
```

The unitprice of a share of this fund in baseToken

#### \_getUnitPrice

```solidity
function _getUnitPrice() internal view returns (uint256)
```

#### getUnitPriceInUSD

```solidity
function getUnitPriceInUSD() public view returns (uint256)
```

The unitprice of a share of this fund, in stablecoinUSDAddr

#### isReTrade

```solidity
function isReTrade() public view returns (bool)
```
