Skip to content

Commit

Permalink
Marinade SP: refactor calls to marinade liquid unstake - including a …
Browse files Browse the repository at this point in the history
…neater way to calculate the seeds.
  • Loading branch information
dankelleher committed Feb 5, 2024
1 parent 43822af commit df33fdb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 518 deletions.
306 changes: 0 additions & 306 deletions packages/sdks/common/src/types/marinade_beam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,123 +646,6 @@ export type MarinadeBeam = {
],
"args": []
},
{
"name": "initEpochReport",
"accounts": [
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "updateAuthority",
"isMut": false,
"isSigner": true
},
{
"name": "epochReportAccount",
"isMut": true,
"isSigner": false
},
{
"name": "msolMint",
"isMut": true,
"isSigner": false
},
{
"name": "msolVault",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "clock",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "extractedYield",
"type": "u64"
}
]
},
{
"name": "updateEpochReport",
"accounts": [
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "epochReportAccount",
"isMut": true,
"isSigner": false
},
{
"name": "msolMint",
"isMut": true,
"isSigner": false
},
{
"name": "msolVault",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "clock",
"isMut": false,
"isSigner": false
}
],
"args": []
},
{
"name": "extractYield",
"accounts": [
Expand Down Expand Up @@ -924,42 +807,6 @@ export type MarinadeBeam = {
}
]
}
},
{
"name": "epochReport",
"type": {
"kind": "struct",
"fields": [
{
"name": "state",
"type": "publicKey"
},
{
"name": "epoch",
"type": "u64"
},
{
"name": "tickets",
"type": "u64"
},
{
"name": "totalOrderedLamports",
"type": "u64"
},
{
"name": "extractableYield",
"type": "u64"
},
{
"name": "extractedYield",
"type": "u64"
},
{
"name": "bump",
"type": "u8"
}
]
}
}
],
"types": [
Expand Down Expand Up @@ -1670,123 +1517,6 @@ export const IDL: MarinadeBeam = {
],
"args": []
},
{
"name": "initEpochReport",
"accounts": [
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "updateAuthority",
"isMut": false,
"isSigner": true
},
{
"name": "epochReportAccount",
"isMut": true,
"isSigner": false
},
{
"name": "msolMint",
"isMut": true,
"isSigner": false
},
{
"name": "msolVault",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "clock",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "extractedYield",
"type": "u64"
}
]
},
{
"name": "updateEpochReport",
"accounts": [
{
"name": "state",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
"isSigner": false
},
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "epochReportAccount",
"isMut": true,
"isSigner": false
},
{
"name": "msolMint",
"isMut": true,
"isSigner": false
},
{
"name": "msolVault",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "clock",
"isMut": false,
"isSigner": false
}
],
"args": []
},
{
"name": "extractYield",
"accounts": [
Expand Down Expand Up @@ -1948,42 +1678,6 @@ export const IDL: MarinadeBeam = {
}
]
}
},
{
"name": "epochReport",
"type": {
"kind": "struct",
"fields": [
{
"name": "state",
"type": "publicKey"
},
{
"name": "epoch",
"type": "u64"
},
{
"name": "tickets",
"type": "u64"
},
{
"name": "totalOrderedLamports",
"type": "u64"
},
{
"name": "extractableYield",
"type": "u64"
},
{
"name": "extractedYield",
"type": "u64"
},
{
"name": "bump",
"type": "u8"
}
]
}
}
],
"types": [
Expand Down
38 changes: 22 additions & 16 deletions packages/sdks/marinade-sp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export class MarinadeClient extends BeamInterface<
sunriseState: this.state.sunriseState,
burner,
gsolTokenAccount: burnGsolFrom,
vaultAuthority: this.vaultAuthority[0],
systemProgram: SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
gsolMint,
Expand Down Expand Up @@ -485,24 +486,29 @@ export class MarinadeClient extends BeamInterface<
* Return a transaction to extract any yield from this beam into the yield account
*/
public async extractYield(): Promise<Transaction> {
const accounts = {
state: this.stateAddress,
marinadeState: this.state.proxyState,
sunriseState: this.state.sunriseState,
msolMint: this.marinade.state.mSolMint.address,
msolVault: this.marinade.beamMsolVault,
vaultAuthority: this.vaultAuthority[0],
liqPoolSolLegPda: await this.marinade.state.solLeg(),
liqPoolMsolLeg: this.marinade.state.mSolLeg,
treasuryMsolAccount: this.marinade.state.treasuryMsolAccount,
yieldAccount: this.sunrise.state.yieldAccount,
epochReport: this.sunrise.epochReport[0],
sysvarInstructions: SYSVAR_INSTRUCTIONS_PUBKEY,
sysvarClock: SYSVAR_CLOCK_PUBKEY,
sunriseProgram: this.sunrise.program.programId,
marinadeProgram: MARINADE_FINANCE_PROGRAM_ID,
systemProgram: SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
};
console.log(accounts);
const instruction = await this.program.methods
.extractYield()
.accounts({
state: this.stateAddress,
marinadeState: this.state.proxyState,
sunriseState: this.state.sunriseState,
msolMint: this.marinade.state.mSolMint.address,
msolVault: this.marinade.beamMsolVault,
vaultAuthority: this.vaultAuthority[0],
liqPoolSolLegPda: await this.marinade.state.solLeg(),
liqPoolMsolLeg: this.marinade.state.mSolLeg,
treasuryMsolAccount: this.marinade.state.treasuryMsolAccount,
sysvarInstructions: SYSVAR_INSTRUCTIONS_PUBKEY,
sunriseProgram: this.sunrise.program.programId,
marinadeProgram: MARINADE_FINANCE_PROGRAM_ID,
systemProgram: SystemProgram.programId,
tokenProgram: TOKEN_PROGRAM_ID,
})
.accounts(accounts)
.instruction();

return new Transaction().add(instruction);
Expand Down
Loading

0 comments on commit df33fdb

Please sign in to comment.