> For the complete documentation index, see [llms.txt](https://developer.xwin.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.xwin.finance/xwin-strategies/xwin-allocation.md).

# xWin Allocation

### xWinAllocations

#### xWinSwap

```solidity
contract IxWinSwap xWinSwap
```

#### priceMaster

```solidity
contract IxWinPriceMaster priceMaster
```

#### executors

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

#### TargetWeight

```solidity
mapping(address => uint256) TargetWeight
```

#### targetAddr

```solidity
address[] targetAddr
```

#### initialize

```solidity
function initialize(string _name, string _symbol, address _baseToken, address _swapEngine, address _USDTokenAddr, address _xWinPriceMaster, uint256 _managerFee, uint256 _performanceFee, uint256 _collectionPeriod, address _managerAddr) external
```

#### onlyExecutor

```solidity
modifier onlyExecutor()
```

#### updatexWinPriceMaster

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

*update xwin master contract*

#### \_deposit

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

#### deposit

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

Deposits baseToken into the fund, and receives shares based on the fund's unitPrice

**Parameters**

| Name   | Type    | Description                    |
| ------ | ------- | ------------------------------ |
| amount | uint256 | Amount of baseToken to deposit |

**Return Values**

| Name | Type    | Description                                 |
| ---- | ------- | ------------------------------------------- |
| \[0] | uint256 | shares Amount of shares minted to depositor |

#### deposit

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

#### \_calcMintQty

```solidity
function _calcMintQty(uint256 _unitPrice) internal view returns (uint256 mintQty)
```

#### \_withdraw

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

#### withdraw

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

#### withdraw

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

#### \_getLatestPrice

```solidity
function _getLatestPrice(address _targetAdd) internal view returns (uint256)
```

#### \_getLatestPriceInUSD

```solidity
function _getLatestPriceInUSD(address _targetAdd) internal view returns (uint256)
```

#### getLatestPrice

```solidity
function getLatestPrice(address _targetAdd) external view returns (uint256)
```

#### createTargetNames

```solidity
function createTargetNames(address[] _toAddr, uint256[] _targets) public
```

Sets target token addresses and weights for the fund

#### Rebalance

```solidity
function Rebalance(address[] _toAddr, uint256[] _targets, uint32 _slippage) public
```

Performs rebalance with new weight and reset next rebalance period

#### \_moveNonIndex

```solidity
function _moveNonIndex(address _token, uint32 _slippage) internal returns (uint256 balanceToken, uint256 swapOutput)
```

#### \_getDeleteNames

```solidity
function _getDeleteNames(address[] _toAddr) internal view returns (struct xWinLib.DeletedNames[] delNames)
```

#### Rebalance

```solidity
function Rebalance(address[] _toAddr, uint256[] _targets) external
```

Performs rebalance with new weight and reset next rebalance period

#### \_rebalance

```solidity
function _rebalance(uint32 _slippage) internal
```

#### \_sellOverWeightNames

```solidity
function _sellOverWeightNames(uint32 _slippage) internal returns (struct xWinLib.UnderWeightData[] underwgts, uint256 totalunderwgt)
```

#### \_buyUnderWeightNames

```solidity
function _buyUnderWeightNames(struct xWinLib.UnderWeightData[] underweights, uint256 totalunderwgt, uint32 _slippage) internal
```

#### \_getActiveOverWeight

```solidity
function _getActiveOverWeight(address destAddr, uint256 totalvalue) internal view returns (uint256 destRebQty, uint256 destActiveWeight, bool overweight)
```

#### getTokenValues

```solidity
function getTokenValues(address tokenaddress) external view returns (uint256)
```

#### \_getTokenValues

```solidity
function _getTokenValues(address token) internal view returns (uint256)
```

#### getBalance

```solidity
function getBalance(address fromAdd) public view returns (uint256)
```

#### \_getTransferAmt

```solidity
function _getTransferAmt(address underying, uint256 redeemratio) internal view returns (struct xWinLib.transferData transData)
```

#### setExecutor

```solidity
function setExecutor(address _wallet, bool _allow) 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

#### getVaultValues

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

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

#### \_getVaultValues

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

#### getTargetWeightQty

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

#### \_getTokenValuesInUSD

```solidity
function _getTokenValuesInUSD(address token) internal view returns (uint256)
```

#### getVaultValuesInUSD

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

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

#### \_getVaultValuesInUSD

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

#### getStableValues

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

#### getTargetNamesAddress

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.xwin.finance/xwin-strategies/xwin-allocation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
