Get Deposit Details of a Wallet
Fetch details of all deposits by a wallet.
There are two Kamino account types that we are interested in. They are
Obligation, which stores details about a wallet's borrows and deposits.
Reserve, which stores detail about the actual asset that is being borrowed or deposited.
We can get all deposit details for a particular wallet, by querying the Obligation account from the Kamino Lending program.
You can directly copy paste this code on replit and see it in action. The owner
field refers to the wallet which is being queried, and we can filter this field to get the required deposit details.
To query reserves data, please check Get Reserve Details.
The response returned contains a deposits
field, which is an array of deposit details for that particular user (owner) . Each item in that array contains
depositReserve
: The address of the reserve to which collaterals are deposited to. The reserve details can be retrieved by querying the Reserve account, here Get Reserve Details. The mintPubkey of liquidty field is available here.depositedAmount
: The amount of the collaterals deposited in the reserve.marketValueSf
: The collateral market value in quote currency.
An Example to get Deposit details for a wallet
You can try out a sample project that gets all deposits and borrows of a wallet, here.
Consider the example, if we are trying to get all deposits for the wallet HNqJtqudHDWiWHWg3RH7FPamf8dyXjFwJVPmfRDMDyjE
. The steps are as follows:
We query the Kamino_Lending Obligation account using the where filter on the
owner
field, as illustrated in the above example. The query looks somewhat like this:
Once successful, we get all the Obligation details for the wallet, which contains the deposit details. Each Item in the
deposit
array contains thedepositedAmount
, which is the amount deposited anddepositReserve
, which is the address of the reserve (pubkey) contains the liquidity details.
The
depositReserve
returned in the previous step is the pubkey of areserve
account, which keeps track of the liquidity. We query the reserve details from the Kamino Lending Reserve account.
Once successfully executed, this returns the
mintPubkey
which is the token address of the liquidity in this reserve. We can further user SHYFT’s SDK to get the token name, symbol and decimals.
Last updated