Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/marinade/ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ export const MARINADE_FINANCE_PROGRAM_ID = new PublicKey("MarBmsSgKXdrN1egZf5sqe
export const MSOL_MINT_ADDRESS = new PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So");

export const MARINADE_STATE_ADDRESS = new PublicKey("8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC");

export const MARINADE_SOL_LEG_ADDRESS = new PublicKey("UefNb6z6yvArqe4cJHTXCqStRsKmWhGxnZzuHbikP5Q");

export const MARINADE_MSOL_LEG_ADDRESS = new PublicKey("7GgPYjS5Dza89wV6FpZ23kUJRG5vbQ1GM25ezspYFSoE");

export const MARINADE_MSOL_LEG_AUTHORITY_ADDRESS = new PublicKey("EyaSjUtSgo9aRD1f8LWXwdvkpDTmXAW54yoSHZRF14WL");

export const MARINADE_RESERVE_ADDRESS = new PublicKey("Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN");

export const MARINADE_MSOL_MINT_AUTHORITY = new PublicKey("3JLPCS1qM2zRw3Dp6V4hZnYHd4toMNPkNesXdX9tg6KM");
7 changes: 6 additions & 1 deletion src/marinade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export * from "./infos";
export * from "./layouts";

import BN from "bn.js";
import { IDepositorInfo, IVaultInfo } from "../types";
import { IDepositorInfo, IVaultInfo, IWithdrawerInfo } from "../types";
import { PublicKey } from "@solana/web3.js";
import { RawAccount } from "@solana/spl-token-v2";

Expand Down Expand Up @@ -90,3 +90,8 @@ export interface VaultInfo extends IVaultInfo {
export interface DepositorInfo extends IDepositorInfo {
tokenAccount: RawAccount;
}

export interface WithdrawerInfo extends IWithdrawerInfo {
lamports: BN;
epochCreated: BN;
}
25 changes: 23 additions & 2 deletions src/marinade/infos.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Connection, PublicKey } from "@solana/web3.js";
import { Connection, PublicKey, GetProgramAccountsConfig, DataSizeFilter } from "@solana/web3.js";

import { MARINADE_FINANCE_PROGRAM_ID, MARINADE_STATE_ADDRESS, MSOL_MINT_ADDRESS } from "./ids";

import { IInstanceVault, IVaultInfoWrapper } from "../types";
import { MARINADE_FINANCE_ACCOUNT_STATE } from "./layouts";
import { MARINADE_FINANCE_ACCOUNT_STATE, MARINADE_FINANCE_ACCOUNT_TICKET_ACCOUNT_DATA } from "./layouts";

import * as types from ".";
import { AccountLayout, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token-v2";
Expand Down Expand Up @@ -135,7 +135,28 @@ infos = class InstanceMarinade {
tokenAccount: rawAccount,
};
}
static parseWithdrawer(data: Buffer, withdrawalId: PublicKey): types.WithdrawerInfo {
let rawData = MARINADE_FINANCE_ACCOUNT_TICKET_ACCOUNT_DATA.decode(data);
return {
withdrawerId: withdrawalId,
lamports: rawData.lamportsAmount,
epochCreated: rawData.createdEpoch,
userKey: rawData.beneficiary,
};
}
static async getAllWithdrawers(connection: Connection, userKey: PublicKey): Promise<types.WithdrawerInfo[]> {
let filter: GetProgramAccountsConfig = {
filters: [
{ dataSize: MARINADE_FINANCE_ACCOUNT_TICKET_ACCOUNT_DATA.span as number },
{ memcmp: { offset: 40, bytes: userKey.toBase58() } },
],
};
let withdrawerAccounts = await connection.getProgramAccounts(MARINADE_FINANCE_PROGRAM_ID, filter);

return withdrawerAccounts.map((account) => {
return this.parseWithdrawer(account.account.data, account.pubkey);
});
}
private static _isAllowed(mint: PublicKey): boolean {
return mint.equals(MSOL_MINT_ADDRESS);
}
Expand Down
8 changes: 7 additions & 1 deletion src/marinade/layouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export const MARINADE_FINANCE_ACCOUNT_STATE = struct(
);

export const MARINADE_FINANCE_ACCOUNT_TICKET_ACCOUNT_DATA = struct(
[publicKey("stateAddress"), publicKey("beneficiary"), u64("lamportsAmount"), u64("createdEpoch")],
[
blob(8, "identifier"),
publicKey("stateAddress"),
publicKey("beneficiary"),
u64("lamportsAmount"),
u64("createdEpoch"),
],
"TicketAccountData"
);