Project Story

Inspiration

The inspiration behind the project was to create the first of its kind implementation of a blockchain index fund fully compliant with Polish law. The solution builts up on the SIRA equity token and DEX implementations.

Moreover, to showcase the possibilities of the solution I created a web app solution for Polish Football Champions SIRA Index Fund that is built on top of the index smart contracts and is an innovation in itself, as:

  • no Polish football index funds exist at the moment as far as I know
  • the blockchain solution could be easily integrated with the Fan Token that already a couple of famous Football Clubs around the world integrated into their operations, including FC Barcelona, AC Milan, PSG or Man City among others

How I Built It

  • Solidity and Hardhat - smart contract development
  • Next.js - web app

Challenges I Ran Into when building the SIRA index

Collateral reserves

This means making sure that I have the collateral that covers all the issued index tokens while minimizing the risk and exposure from having collateral that is not backed by any users holding an index token

This is an important issue because if we buy loads of collateral at a point in time when the constituents are the most expensive then our index fund contract could become very unattractive to potential investors and we could run out of money to keep the price of the index at a level that people still want to buy the token.

Buy up the equities as we go

My initial idea was to 'buy up the equities as we go' i.e. whenever a user buys a token I would buy the individual constituents proportionally to the amount of stable coin that the user is willing to pay.

Advantages of this approach:

  • collateral risk is minimized

Disadvantages of this approach:

  • because our equity DEX is buy side only it means that we have no guarantee that our orders will be filled when we request it. On usual exchanges there is no issue with executing a "market" order that would be always filled on a market that is liquid enough. However, in our case we can't really make the user wait for all the orders to be filled, which means that we would need to accept the risk of not being covered by enough collateral, which obviously is not desirable (e.g. when a lot of users want to get out of their index position)
  • as our orders are not guaranteed to be filled then we should minimize the amount of orders that we create to minimize the arising complexity
  • biggest problem of them all, however, is that Solidity doesn't allow fractional numbers. It means that we can't really buy fractional shares of companies and we need to buy the index token in bulk

Let the owner decide when is safe to add reserves of collateral in bulk

This is the approach that I went for. It has all the advantages that the above solution doesn't have and additionally it has the advantage of being quite simple to manage. Moreover, we know that most of the market goes up eventually. That means that statistically when buying reserves we will actually save money compared to buying it later.

The disadvantage of this approach is that the owner of the index fund needs to monitor the market and the index contract themselves or implement their own processes to do so.

Dynamically determine when to add reserves of collateral in bulk

Another valid approach. Didn't implement it for the sake of simplicity and versatility of the previous solution.

Add a check so that both parties need to approve an order once it's matched and approved

Currently, SIRA requires somebody to call the transact function in order to actually execute a transaction. We could extend this to add an order reservation mechanism, in which any party can get out of the reservation any time before the transact function is called. This could allow us to reserve orders and execute them only when we actually get a request to buy an index token from someone.

This is an interesting approach worth exploring in the long term.

How should constituents be weighted?

Percentage

This is difficult to do when you don't have a good source of data about the constituents pricing e.g. an oracle or mid-market price.

Amount of individual equities that together form 10_000 (or an arbitrary number) of index tokens

I went for this approach as it's simpler and doesn't require pricing information.

No easily available oracle for the prices of Polish companies

I solved this issue by taking the price of the last transaction executed for a given token. It's quite a good marker of a mid-market price provided that we don't include the fees in our calculation.

Modifications of the initial SIRA implementation

I had to make a couple of modifications to the initial SIRA implementation, including:

  • adding order owner to the order creation event for ease of reconciliation and gas efficiency
  • expose the best buy order so that the index fund contract can fetch it directly for a given issuer
  • expose the last transaction price for a given issuer

The last two modifications could really happen with a dedicated backend off-chain and could potentially save some gas. However, the current approach has the advantage that except error handling all the functionality is stored in the smart contract, which makes the smart contract more easily reusable.

What's Next for SIRA Index

The goal is to certify SIRA index as compliant with Polish law and provide SIRA to people as a cheaper and more reliable alternative of traditional ETFs like WIG20 etc. To achieve this goal further analysis needs to be done into SIRA to uncover all the potential flaws, make sure that SIRA is as gas optimised and as risk-free as possible.

Potential easy extensions to do:

  • implement a comprehensive error handling with a dedicated backend that ensures that index fund runs correctly
  • add the index to individual equities and individual equities to index functions that allow users to go in and out of index position in a more direct way
  • _sellToken from IndexFund and filterAndFindBestOffer should be replaced with a backend as they are very gas inefficient

Different architectures and blockchains could be considered for the SIRA index e.g. Internet Protocol with its low operational costs, reverse gas model and ease of integration with web apps.

In terms of the sports index, I think the sports world is a perfect place to start the roll out of the SIRA index. There is no alternative at the moment and with the rising popularity of "fan tokens" not only for sports clubs but also for individual players, we could e.g. allow people to buy index tokens on players of a specific football team etc.

We can't forget about another feature of indices, which is data aggregation. There could be created services that would integrate with the SIRA index to provide interesting aggregated analyses/benefits for specific index token holders.

Sponsors I am applying for

  • PKO BP
  • WhiteBit and Whitechain.io

Built With

Share this project:

Updates