Skip to content

Commit

Permalink
Update epoch report and extract yield core support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed Dec 31, 2023
1 parent 20aae83 commit ccfcf45
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ program = "packages/tests/fixtures/spl/spl_stake_pool.so"
address = "89wj5p56PTFiKQcHLTkx78jM3Cv4jVRCXgMKJvoFvvp"
filename = "packages/tests/fixtures/core/empty-state.json"
[[test.validator.account]] #gsol mint
address = "HGFi2ubkrCKdxqeAHXDTRAMzyquKqWj3xdT9kz2ux7gi"
address = "EqhYZpTHLvfKgn5oBz1jxLVB3kQH33W8eDLbBNCJqfzS"
filename = "packages/tests/fixtures/core/gsol-mint.json"

# Beam Accounts
Expand Down
48 changes: 48 additions & 0 deletions packages/sdks/common/src/types/sunrise_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@ export type SunriseCore = {
],
"type": "publicKey"
},
{
"name": "reservedSpace",
"docs": [
"Reserved space for adding future fields."
],
"type": {
"array": [
"u32",
32
]
}
},
{
"name": "allocations",
"docs": [
Expand Down Expand Up @@ -549,6 +561,18 @@ export type SunriseCore = {
"A beam in drain accepts withdrawals but not deposits."
],
"type": "bool"
},
{
"name": "reservedSpace",
"docs": [
"Reserved space for adding future fields."
],
"type": {
"array": [
"u32",
32
]
}
}
]
}
Expand Down Expand Up @@ -1182,6 +1206,18 @@ export const IDL: SunriseCore = {
],
"type": "publicKey"
},
{
"name": "reservedSpace",
"docs": [
"Reserved space for adding future fields."
],
"type": {
"array": [
"u32",
32
]
}
},
{
"name": "allocations",
"docs": [
Expand Down Expand Up @@ -1261,6 +1297,18 @@ export const IDL: SunriseCore = {
"A beam in drain accepts withdrawals but not deposits."
],
"type": "bool"
},
{
"name": "reservedSpace",
"docs": [
"Reserved space for adding future fields."
],
"type": {
"array": [
"u32",
32
]
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const SUNRISE_PROGRAM_ID = new PublicKey(
/** The constant seed of the GSOL mint authority PDA. */
export const GSOL_AUTHORITY_SEED = "gsol_mint_authority";

export const EPOCH_REPORT_SEED = "epoch_report";
export const EPOCH_REPORT_SEED = "epoch_report";
6 changes: 3 additions & 3 deletions packages/tests/fixtures/core/empty-state.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"pubkey": "89wj5p56PTFiKQcHLTkx78jM3Cv4jVRCXgMKJvoFvvp",
"account": {
"lamports": 6090000,
"lamports": 6096960,
"data": [
"2JJrXmhLtrHJi086QhFaVlGIukKID4tkZHDOjVITr4RH7vx5aT2XqfGjVS5s9M0otXTMzigTnRm3wxj5+4qWm7acOEGIRU8PAAAAAAAAAAD/DZVjk9SBDG8vBV/2PAd7V82Q8jKb95Vcw/R5gMEdinIPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"base64"
],
"owner": "suncPB4RR39bMwnRhCym6ZLKqMfnFG83vjzVVuXNhCq",
"executable": false,
"rentEpoch": 18446744073709551615,
"space": 747
"space": 748
}
}
2 changes: 1 addition & 1 deletion packages/tests/fixtures/core/gsol-mint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"pubkey": "HGFi2ubkrCKdxqeAHXDTRAMzyquKqWj3xdT9kz2ux7gi",
"pubkey": "EqhYZpTHLvfKgn5oBz1jxLVB3kQH33W8eDLbBNCJqfzS",
"account": {
"lamports": 1461600,
"data": [
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/src/functional/beams/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BN from "bn.js";
import { provider } from "../setup.js";
import { expect } from "chai";

const BEAM_DETAILS_LEN: number = 42;
const BEAM_DETAILS_LEN: number = 170;

describe("Sunrise core", () => {
let gsolMint: PublicKey;
Expand Down
11 changes: 10 additions & 1 deletion programs/sunrise-core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub struct State {
/// The Sunrise yield account.
pub yield_account: Pubkey,

/// Reserved space for adding future fields.
pub reserved_space: [u32; 32], // 128 bytes - used u32;32 over u8;128 to take advantage of rust's built-in default trait implementation for 32-sized arrays

/// Holds [BeamDetails] for all supported beams.
pub allocations: Vec<BeamDetails>,
}
Expand All @@ -42,14 +45,18 @@ pub struct BeamDetails {

/// A beam in drain accepts withdrawals but not deposits.
pub draining_mode: bool,

/// Reserved space for adding future fields.
pub reserved_space: [u32; 32], // 128 bytes - used u32;32 over u8;128 to take advantage of rust's built-in default trait implementation for 32-sized arrays
}

impl BeamDetails {
/// Size in bytes of a borsh-serialized [BeamDetails] struct.
pub const SIZE: usize = 32 + // key
1 + // allocation
8 + // minted
1; // draining_mode
1 + // draining_mode
128; // reserved_space

/// Create a new instance of Self.
pub fn new(key: Pubkey, allocation: u8) -> Self {
Expand All @@ -58,6 +65,7 @@ impl BeamDetails {
allocation,
partial_gsol_supply: 0,
draining_mode: false, // initially set draining_mode to false.
reserved_space: Default::default(),
}
}
}
Expand All @@ -71,6 +79,7 @@ impl State {
1 + // gsol_mint_authority_bump
1 + // epoch_report_bump
32 + // yield_account
128 + // reserved_space
4; // vec size

/// Calculate the borsh-serialized size of a state with `beam_count` number of beams.
Expand Down

0 comments on commit ccfcf45

Please sign in to comment.