feat: account layout
This commit is contained in:
parent
d55c9084f6
commit
0951eede43
|
@ -13,9 +13,13 @@ export const ENDPOINTS = [
|
|||
name: 'mainnet-beta' as ENV,
|
||||
endpoint: 'https://solana-api.projectserum.com/',
|
||||
},
|
||||
{
|
||||
name: 'Oyster Dev' as ENV,
|
||||
endpoint: 'http://oyster-dev.solana.com/',
|
||||
},
|
||||
{
|
||||
name: 'Lending' as ENV,
|
||||
endpoint: 'https://tln.solana.com/',
|
||||
endpoint: 'http://tln.solana.com/',
|
||||
},
|
||||
{ name: 'testnet' as ENV, endpoint: clusterApiUrl('testnet') },
|
||||
{ name: 'devnet' as ENV, endpoint: clusterApiUrl('devnet') },
|
||||
|
|
|
@ -4,20 +4,25 @@ import * as Layout from "./../../utils/layout";
|
|||
|
||||
export const LendingMarketLayout: typeof BufferLayout.Structure = BufferLayout.struct(
|
||||
[
|
||||
BufferLayout.u8("version"),
|
||||
BufferLayout.u8('version'),
|
||||
Layout.publicKey("quoteMint"),
|
||||
Layout.publicKey("tokenProgramId")
|
||||
Layout.publicKey("tokenProgramId"),
|
||||
|
||||
// extra space for future contract changes
|
||||
BufferLayout.blob(63, "padding"),
|
||||
],
|
||||
);
|
||||
|
||||
export interface LendingMarket {
|
||||
version: number;
|
||||
|
||||
isInitialized: boolean;
|
||||
quoteMint: PublicKey;
|
||||
tokenProgramId: PublicKey,
|
||||
}
|
||||
|
||||
export const isLendingMarket = (info: AccountInfo<Buffer>) => {
|
||||
return info.data.length === LendingMarketLayout.span + 63;
|
||||
return info.data.length === LendingMarketLayout.span;
|
||||
};
|
||||
|
||||
export const LendingMarketParser = (
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as Layout from "./../../utils/layout";
|
|||
|
||||
export const LendingObligationLayout: typeof BufferLayout.Structure = BufferLayout.struct(
|
||||
[
|
||||
BufferLayout.u8("version"),
|
||||
BufferLayout.u8('version'),
|
||||
/// Slot when obligation was updated. Used for calculating interest.
|
||||
Layout.uint64("lastUpdateSlot"),
|
||||
/// Amount of collateral tokens deposited for this obligation
|
||||
|
@ -20,14 +20,19 @@ export const LendingObligationLayout: typeof BufferLayout.Structure = BufferLayo
|
|||
Layout.publicKey("borrowReserve"),
|
||||
/// Mint address of the tokens for this obligation
|
||||
Layout.publicKey("tokenMint"),
|
||||
|
||||
// extra space for future contract changes
|
||||
BufferLayout.blob(128, "padding"),
|
||||
]
|
||||
);
|
||||
|
||||
export const isLendingObligation = (info: AccountInfo<Buffer>) => {
|
||||
return info.data.length === LendingObligationLayout.span + 300;
|
||||
return info.data.length === LendingObligationLayout.span;
|
||||
};
|
||||
|
||||
export interface LendingObligation {
|
||||
version: number;
|
||||
|
||||
lastUpdateSlot: BN;
|
||||
depositedCollateral: BN;
|
||||
collateralReserve: PublicKey;
|
||||
|
|
|
@ -74,13 +74,18 @@ export const LendingReserveLayout: typeof BufferLayout.Structure = BufferLayout.
|
|||
],
|
||||
'state'
|
||||
),
|
||||
|
||||
// extra space for future contract changes
|
||||
BufferLayout.blob(300, "padding"),
|
||||
]);
|
||||
|
||||
export const isLendingReserve = (info: AccountInfo<Buffer>) => {
|
||||
return info.data.length === LendingReserveLayout.span + 300;
|
||||
return info.data.length === LendingReserveLayout.span;
|
||||
};
|
||||
|
||||
export interface LendingReserve {
|
||||
version: number;
|
||||
|
||||
lastUpdateSlot: BN;
|
||||
|
||||
lendingMarket: PublicKey;
|
||||
|
|
Loading…
Reference in New Issue