Assessment reports>Suilend>Threat Model>Basic function

Basic function

The lending_market does no accounting on its own but rather calls into reserve for pool-level accounting and into obligation for user-level accounting. The lending_market is meant to be the entry point to the protocol for users. All public functions are on this object. The public functions also perform checks on the arguments, such as ensuring the type arguments match the arguments. The rate limiter is also enforced here.

The lending_market object is intended to be created once and have a reserve added by the administrator for each supported coin. The lending_market creation function takes a one type witness as the type argument to ensure it is only created once per deployment of the creating contract. All functions that call into the lending_market take that type argument to ensure that the correct lending_market is called. The type argument is used to distinguish objects that belong to this particular lending_market from any others that may be created. For example, it is used to ensure the LendingMarketCap used for admin operations belongs to this LendingMarket and not one created by a potential attacker. This makes it so that the lending_market_id field no longer needs to be checked.

Zellic © 2025Back to top ↑