- mrgn lend
- ...
Margin group is a parent component that configures, manages and determines rules for access to resources for its own margin accounts.
The lending pool is a sub components of the margin group. The lending pool and the margin group have a one-to-one relationship, and its managed by the margin group admin. The risk of the lending pool is managed by the margin group.
- Sum component of the margin group.
- Has one-to-one relationship with the margin group.
- Same admin authorization with the margin group.
- Risk is managed by the margin group.
Each lending pool controls one or more Banks
struct Banks {
}
Represents a single asset in the pool. Records data to calculate the interest rate.
struct Banks {
asset_mint: Pubkey,
vault_token_account: Pubkey,
total_deposits: u64,
total_borrows: u64,
...
}
┌────────────┐ ┌────────────┐ ┌───────────┐ ┌──────────┐
│ Margin/Risk│ │ Lending │ │ │ │ Price │
│ Group │1─────1│ Pool │1─────n│ Banks │m─────n│ Oracle │
│ │ │ │ │ │ │ │
└────────────┘ └────────────┘ └───────────┘ └──────────┘
1 1
│ │
│ │
n 1
┌───────────┐ ┌────────────┐ ┌────────────┐
│ │ │ Margin │ │ Lending │
│ Signer │1──────n│ Account │1─────1│ Account │
│ │ │ │ │ │
└───────────┘ └────────────┘ └────────────┘
Q: Should Lending Pool be and independent account, that is connected to the Margin Group?
Including the Lending Pool in the Margin Group account would reduce the tx size, however moving it out allows us to potentially reuse the Lending Reserve down the line.