# Index

### General Checks

All MTK´s validations include basic checks that don't depend on the redeemer

* Credential token is present in the outputs
* Correct amount of script inputs
* Index UTxO preserves address
* Correct amount of script outputs

### Process User Order Redeemer:

1. **For deposit orders:**

* Slippage success:
  * Balance approximates target balance
  * Order token is burnt and the number of minted MTK corresponds to the value added to the instrument
  * Portfolio output datum is correctly updated
  * Portfolio Manager fees are accumulated in the portfolio output value
  * User is paid the minted MTK (minus fees)
* Slippage failure:
  * No MTK tokens are minted and order token is burnt
  * Portfolio input values equal output values
  * Portfolio input datum equal output datum
  * Assets in the order are paid back to the user (minus the order token)

2. **For withdraw orders:**

* Slippage success:
  * Balance approximates target balance
  * Order token is burnt and the number of minted MTK corresponds to the value removed to the instrument
  * Portfolio output datum is correctly updated
  * Portfolio Manager fees are accumulated in the portfolio output value
  * User is paid the withdrawn assets (minus fees)
* Slippage failure:
  * No MTK tokens are minted and order token is burnt
  * Portfolio input values equal output values
  * Portfolio input datum equal output datum
  * Assets in the order are paid back to the user (minus the order token)

### Process Manager Order Redeemer:&#x20;

**When processing either Update or Collect orders**

* Collect Order:
  * No minting nor burning in the transaction besides the burning of the order token.
  * Portfolio value is only substracting the accumulated fees.&#x20;
  * Manager is paid the accumulated fees.&#x20;
  * Portfolio output datum updated accordignly.&#x20;
* Update Order:
  * No minting nor burning in the transaction besides the burning of the order token.
  * Portfolio value only changes accordingly
  * New weights are well-formed (sum equals to 1).
  * Portfolio output datum updated accordingly

### Index NFT Minting Policy:&#x20;

* Only one script output
* Valid index datum
* Weights sum equals to 1
* w asset minted: the index NFT and initial MTK mint
* Positive amount of MTK minted
* Index assets paid to correct address

### MTK Minting Policy

* Index NFT is present in the outputs
