Exploring the Marginfi Program: A Deep Dive with SolanaFM
This week, we uncover the actions taking place on-chain when interacting with the marginfi program.
Contents
Introduction
What is Marginfi?
Marginfi Program
Marginfi Pool Accounts
Exploring Marginfi Transactions
Conclusion
Introduction
Solana’s DeFi landscape has seen a remarkable surge over the last few weeks with protocols like Marginfi at the forefront of the sector.
When lending/borrowing assets on marginfi, it is important to understand the actions taking place in the protocol and how to verify the details on-chain to transact efficiently.
This deep dive will cover the basic details of the Marginfi Program and how to verify your lending and borrowing transactions on SolanaFM Explorer.
What is Marginfi?
Marginfi is an over-collateralized* lending and borrowing platform on Solana which allows users to deposit various assets and borrow other assets against their deposited collateral.
*over-collateralized: A loan that is backed by more collateral than it is worth.
With a current TVL of over $18 million, marginfi offers lending and borrowing across 12 assets:
wSOL (So11111111111111111111111111111111111111112)
mSOL (mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So)
UXD (7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT), including UXP (UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M) rewards
JitoSOL (J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn)
USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)
stSOL (7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj)
USDT (Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB)
ETH (7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs)
wBTC (3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh)
BONK (DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263)
bSOL (bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1)
HNT (hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux)
Let’s dive deeper into how their users interact with the platform on-chain.
Marginfi Program
On solana.fm, you can see an overview of marginfi’s latest activity under “Transactions”. This allows you to explore how other users interact with the program, and what strategies they deploy to earn a profit.
Link to Program: https://solana.fm/address/MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA?cluster=mainnet-solanafmbeta
Marginfi Pool Accounts
The assets deposited and borrowed on marginfi are stored in their own on-chain account, which can be accessible via SolanaFM Explorer:
wSOL Pool (DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD)
mSOL Pool (6YxGd65JbXzgFGWjE44jsyVeCnZp7Bb1wfL9jDia1n8w)
UXD Pool (6uQDwA2MAxCPNGho6yxPGbtPDky3mn8dfZ3atb1aB6SG)
UXP Pool (2GkR378mk9LKZFkE5LtDewiUvzRLiZMhUYSFS6gKd4xE)
JitoSOL Pool (7Ng54qf7BrCcZLqXmKA9WSR7SVRn4q6RX1YpLksBQ21A)
USDC Pool (3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG)
stSOL Pool (7VDS9KHnHuebmN8maraoiDAomdf4xdJ8tNF8KLJCKHin)
USDT Pool (9r6z6KgkEytHCdQWNxvDQH98PsfU98f1m5PCg47mY2XE)
ETH Pool (ELXogWuyXrFyUG1vevffVbEhVxdFrHf2GCJTtRGKBWdM)
BTC Pool (7P2TQHYgVJkXv1VPaREsL5Pi1gnNjVif5aF3pJewZ9kj)
BONK Pool (26kcZkdjJc94PdhqiLiEaGiLCYgAVVUfpDaZyK4cqih3)
bSOL Pool (8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo)
HNT Pool (AjsyrYpgaH275DBSnvNWdGK33hVycSFuXN87FKnX6fVY)
Need more information on how these accounts work? Check out our guide on how to use SolanaFM Explorer.
Exploring Marginfi Transactions
Users typically interact with marginfi by:
Depositing Assets
Borrowing Assets
Repaying borrowed Assets
Withdrawing deposited Assets
Retrieving UXP rewards
Depositing Assets
Link to Transaction: https://solana.fm/tx/4L66u2CwPviP3RVF9knwKfN85tnmyNYUsdhJZPccjc9ET2H34zx4UDTmihpL4CfkBfAR4QqrwJCKdyvPgLbM1HY9?cluster=mainnet-qn1&lineNum=6
When a user deposits assets, the marginfi Program calls the ‘LendingAccountDeposit’ instruction. In this transaction, the user deposits 60 USDT into marginfi’s USDT Pool account.
Borrowing Assets
Link to Transaction: https://solana.fm/tx/DkkEQycGBRNE77AejwEM1B5oJVrAxhVtH2gUxVHzZNNmpSoVJVD6PDHGmgy8SBhtPT6MGYXiwr4Z6nDtyTetkqT?cluster=mainnet-qn1&lineNum=27
When a user borrows assets against their collateral, the marginfi program calls the ‘LendingAccountBorrow’ instruction.
In this transaction, the user borrows 30 Wrapped SOL from marginfi’s wSOL Pool account.
Repaying Borrowed Assets
Link to Transaction: https://solana.fm/tx/2Bxh4aaBVH5966oussybMxmB4Auot2Yh9DPaPcuS9LeBTYbP8abYduc9c3u7LwETgew62ZmDWeZfkyWRJb3D97qH&lineNum=6
When a user repays any borrowed asset, the marginfi program calls the ‘LendingAccountRepay’ instruction.
In this transaction, the user returns 1.5 UXD back into marginfi’s UXD Pool account.
Withdrawing Deposited Assets
Link to Transaction: https://solana.fm/tx/2aModCbmhYKUTRmjGxW3ZckXBuEvnJ4oUbUAdxrNqxGDRDg6oCvqAs5RKFb5LJqMHV1kgHXAQWVD6nMBjGMzbC2d?cluster=mainnet-qn1&lineNum=10
When a user withdraws their deposited assets, the marginfi program calls the ‘LendingAccountWithdraw’ instruction.
In this transaction, the user withdraws 1000 USDC from marginfi’s USDC Pool account.
Retrieving UXP Rewards
Link to Transaction Log: https://solana.fm/tx/2agsKSh3Go6AXoxubM7AP9ZKPnXFpsmmBdRGyAuH49rKMszjK4AC35WS1Z2dFBYPHZzv5AdWqEcx9CiCzUdNQv9R?cluster=mainnet-qn1&lineNum=6
On marginfi, you can lend the UXD stablecoin to earn UXP tokens in return. When a user withdraws their UXP rewards, the program calls the ‘LendingAccountWithdrawEmissions’ instruction.
In this transaction, the user is transferred a reward of 13,020 UXP from the Marginfi UXP Pool.
Conclusion
Now that we’ve covered the basic details of the marginfi program, you’ll be able to navigate around on-chain data and explore different yield strategies within the platform!
Here’s an example of a lending strategy identified by 0xFA2: https://twitter.com/0xFA2/status/1680782887317307392