Skip to content

Commit

Permalink
SPL Stake Pool extract yield WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed Jan 18, 2024
1 parent 585947e commit 376d003
Show file tree
Hide file tree
Showing 26 changed files with 930 additions and 256 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ cargo update -p indexmap --precise 1.9.3
cargo update -p toml_edit --precise 0.19.8
cargo update -p winnow --precise 0.4.1
cargo update -p toml_datetime --precise 0.6.1
cargo update -p solana-zk-token-sdk --precise 1.14.17
cargo update -p solana-program --precise 1.14.17
cargo update -p solana-sdk --precise 1.14.17
cargo update -p solana-program-test --precise 1.14.17

```

See here for more details:

- https://solana.stackexchange.com/a/6535
- https://solana.stackexchange.com/a/6535

### How Beams Work

TODO

#### Burning gSOL

1 change: 1 addition & 0 deletions packages/sdks/common/src/BeamInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export abstract class BeamInterface<
proxyTicket: Keypair;
}>;
abstract redeemTicket(sunriseTicket: PublicKey): Promise<Transaction>;
abstract burnGSol(lamports: BN): Promise<Transaction>;

public supportsSolDeposit(): boolean {
return this.caps.find((cap) => canDepositSol(cap)) !== undefined;
Expand Down
200 changes: 166 additions & 34 deletions packages/sdks/common/src/types/marinade_beam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export type MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -281,7 +281,7 @@ export type MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -390,7 +390,7 @@ export type MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -484,7 +484,7 @@ export type MarinadeBeam = {
"isSigner": true
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -521,6 +521,75 @@ export type MarinadeBeam = {
}
]
},
{
"name": "burn",
"docs": [
"Burning is withdrawing without redeeming the pool tokens. The result is a beam that is \"worth more\"",
"than the SOL that has been staked into it, i.e. the pool tokens are more valuable than the SOL.",
"This allows yield extraction and can be seen as a form of \"donation\"."
],
"accounts": [
{
"name": "state",
"isMut": true,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": true,
"isSigner": false
},
{
"name": "burner",
"isMut": true,
"isSigner": true
},
{
"name": "gsolTokenAccount",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "gsolMint",
"isMut": true,
"isSigner": false,
"docs": [
"Verified in CPI to Sunrise program."
]
},
{
"name": "instructionsSysvar",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "lamports",
"type": "u64"
}
]
},
{
"name": "redeemTicket",
"accounts": [
Expand Down Expand Up @@ -585,6 +654,11 @@ export type MarinadeBeam = {
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
Expand Down Expand Up @@ -646,6 +720,11 @@ export type MarinadeBeam = {
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
Expand Down Expand Up @@ -775,15 +854,6 @@ export type MarinadeBeam = {
"that holds pool tokens (msol in this case)."
],
"type": "u8"
},
{
"name": "partialGsolSupply",
"docs": [
"The amount of the current gsol supply this beam is responsible for.",
"This field is also tracked in the matching beam-details struct in the",
"sunrise program's state and is expected to match that value."
],
"type": "u64"
}
]
}
Expand Down Expand Up @@ -840,10 +910,6 @@ export type MarinadeBeam = {
"name": "extractedYield",
"type": "u64"
},
{
"name": "partialGsolSupply",
"type": "u64"
},
{
"name": "bump",
"type": "u8"
Expand Down Expand Up @@ -1076,7 +1142,7 @@ export const IDL: MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -1195,7 +1261,7 @@ export const IDL: MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -1304,7 +1370,7 @@ export const IDL: MarinadeBeam = {
"isSigner": false
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -1398,7 +1464,7 @@ export const IDL: MarinadeBeam = {
"isSigner": true
},
{
"name": "beamProgram",
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
},
Expand Down Expand Up @@ -1435,6 +1501,75 @@ export const IDL: MarinadeBeam = {
}
]
},
{
"name": "burn",
"docs": [
"Burning is withdrawing without redeeming the pool tokens. The result is a beam that is \"worth more\"",
"than the SOL that has been staked into it, i.e. the pool tokens are more valuable than the SOL.",
"This allows yield extraction and can be seen as a form of \"donation\"."
],
"accounts": [
{
"name": "state",
"isMut": true,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": true,
"isSigner": false
},
{
"name": "burner",
"isMut": true,
"isSigner": true
},
{
"name": "gsolTokenAccount",
"isMut": true,
"isSigner": false
},
{
"name": "vaultAuthority",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "gsolMint",
"isMut": true,
"isSigner": false,
"docs": [
"Verified in CPI to Sunrise program."
]
},
{
"name": "instructionsSysvar",
"isMut": false,
"isSigner": false
},
{
"name": "sunriseProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "lamports",
"type": "u64"
}
]
},
{
"name": "redeemTicket",
"accounts": [
Expand Down Expand Up @@ -1499,6 +1634,11 @@ export const IDL: MarinadeBeam = {
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
Expand Down Expand Up @@ -1560,6 +1700,11 @@ export const IDL: MarinadeBeam = {
"isMut": false,
"isSigner": false
},
{
"name": "sunriseState",
"isMut": false,
"isSigner": false
},
{
"name": "marinadeState",
"isMut": false,
Expand Down Expand Up @@ -1689,15 +1834,6 @@ export const IDL: MarinadeBeam = {
"that holds pool tokens (msol in this case)."
],
"type": "u8"
},
{
"name": "partialGsolSupply",
"docs": [
"The amount of the current gsol supply this beam is responsible for.",
"This field is also tracked in the matching beam-details struct in the",
"sunrise program's state and is expected to match that value."
],
"type": "u64"
}
]
}
Expand Down Expand Up @@ -1754,10 +1890,6 @@ export const IDL: MarinadeBeam = {
"name": "extractedYield",
"type": "u64"
},
{
"name": "partialGsolSupply",
"type": "u64"
},
{
"name": "bump",
"type": "u8"
Expand Down
Loading

0 comments on commit 376d003

Please sign in to comment.