Sparse Merkle Tree and System State
Merkle Trees
We use fixed-height Merkle trees to store the state of the system, in a similar way to how Ethereumโs state is stored. This way, we can encode the whole state of the system into a single field element. There are several tree instances used to store usersโ balances and orders respectively.
System State
Account State
A given user with ID i
will be stored at the i
-th leaf node starting from the left. The first leaf (0
-th) is reserved as the default value of the account.
Order State
A Merkle tree is used to store orders placed by lenders and borrowers in different rounds of auctions. After getting matched, fulfilled orders are removed from the tree, while partially filled orders remain in the tree, with their amount to be filled updated.
Last updated