UTxOs of Deposits in the Fund
The number and structure of UTxOs used to store all the deposits will impact the contracts' complexity and functionality. Among other things, the most critical aspect to take into account is the concurrency and the possibility of keeping centralized, updated, or calculable totals needed for the different calculations.
To validate the Re-Indexing operation, the contract must able to know how the Investment Unit and the Total Deposited IU are formed, i.e., the actual underlying token assets in the Fund. Only then will it be able to validate an update in the Investment Unit: any change in the definition of the Investment Unit must be reflected in the actual holdings of the Fund.
For the fee collection calculation, accessing the Total Fees Paid, Total Fees, and Total Fees Collected for each Group is also necessary.
If I have a single deposit UTxO, it is easy to calculate the totals, but it produces serious concurrency problems; only one User at a time could consume it when making deposits and/or withdrawals.
If I had one UTxO for each deposit, there would be no concurrency problems, but calculating totals would be very expensive. Processing a large number of UTxOs may not be possible.
Considering these points, the Funds will use the following:
Multiple Deposit UTxOs: an amount commensurate with the number of Users deemed able to make deposits and/or withdrawals simultaneously. These UTxOs will be created and administered by the Fund Managers.
Each UTxO will accumulate its own totals for each Deposit or Withdrawal operation.
Commission Collection operations will use only the totals in the Deposit UTxOs. It is not necessary to calculate the total of all UTxOs beforehand. Commissions may be collected at one time from as many UTxOs as can be aggregated in the transaction. It may take several transactions to collect all the commissions that exist on all the different Deposit UTxOs at any given time.
When the Total UI Deposited is needed, it will be calculated in a previous operation. It will be stored in the Fund Datum with a validity time.
Deposit and/or withdrawal operations will be suspended for the duration of the validity period.
The Total Re-Indexing operation will check that the total received is within its validity time.
With this approach, a malicious administrator could indefinitely block a Fund by doing back-to-back totaling operations one after the other. This solution implies that the calculation of totals is not something that is required to be done often. The re-indexing operation does not seem to be an operation that will be used very often.
Last updated