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