Skip to content

Commit

Permalink
setting price
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Dec 17, 2024
1 parent 0181b46 commit b3f0d11
Show file tree
Hide file tree
Showing 33 changed files with 918 additions and 554 deletions.
3 changes: 3 additions & 0 deletions core/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use spl_math::precise_number::PreciseNumber;
use crate::error::TipRouterError;

pub const MAX_FEE_BPS: u64 = 10_000;
pub const MAX_ST_MINTS: usize = 32;
pub const MAX_VAULT_OPERATOR_DELEGATIONS: usize = 64;
pub const MAX_OPERATORS: usize = 256;
const PRECISE_CONSENSUS_NUMERATOR: u128 = 2;
Expand All @@ -20,3 +21,5 @@ pub fn precise_consensus() -> Result<PreciseNumber, TipRouterError> {

pub const DEFAULT_CONSENSUS_REACHED_SLOT: u64 = u64::MAX;
pub const MAX_REALLOC_BYTES: u64 = MAX_PERMITTED_DATA_INCREASE as u64; // TODO just use this?

pub const WEIGHT_PRECISION: u128 = 1_000_000_000;
4 changes: 2 additions & 2 deletions core/src/discriminators.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[repr(u8)]
pub enum Discriminators {
// Configs
NCNConfig = 0x01,
TrackedMints = 0x02,
NcnConfig = 0x01,
VaultRegistry = 0x02,
// Snapshots
WeightTable = 0x10,
EpochSnapshot = 0x11,
Expand Down
2 changes: 2 additions & 0 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum TipRouterError {
DuplicateMintsInTable,
#[error("There are no mints in the table")]
NoMintsInTable,
#[error("Mint is already in the table")]
MintInTable,
#[error("Too many mints for table")]
TooManyMintsForTable,
#[error("Weight table already initialized")]
Expand Down
83 changes: 40 additions & 43 deletions core/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ pub enum TipRouterInstruction {

/// Initialize the global configuration for this NCN
#[account(0, name = "restaking_config")]
#[account(1, writable, name = "ncn_config")]
#[account(1, writable, name = "config")]
#[account(2, name = "ncn")]
#[account(3, signer, name = "ncn_admin")]
#[account(4, name = "fee_wallet")]
#[account(5, name = "tie_breaker_admin")]
#[account(6, name = "restaking_program")]
#[account(7, name = "system_program")]
InitializeNCNConfig {
InitializeConfig {
block_engine_fee_bps: u16,
dao_fee_bps: u16,
default_ncn_fee_bps: u16,
},

/// Initializes the tracked mints account for an NCN
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "tracked_mints")]
#[account(2, name = "ncn")]
#[account(3, writable, signer, name = "payer")]
#[account(4, name = "system_program")]
InitializeTrackedMints,
InitializeVaultRegistry,

/// Updates the fee configuration
#[account(0, name = "restaking_config")]
Expand All @@ -57,7 +57,7 @@ pub enum TipRouterInstruction {
#[account(2, signer, name = "ncn_admin")]
#[account(3, name = "new_admin")]
#[account(4, name = "restaking_program")]
SetNewAdmin {
AdminSetNewAdmin {
role: ConfigAdminRole,
},

Expand All @@ -79,27 +79,26 @@ pub enum TipRouterInstruction {
#[account(2, signer, name = "weight_table_admin")]
#[account(3, name = "mint")]
#[account(4, name = "restaking_program")]
AdminUpdateWeightTable{
AdminSetWeight{
ncn_epoch: u64,
weight: u128,
},

/// Initializes the Epoch Snapshot
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, name = "restaking_config")]
#[account(2, name = "ncn")]
#[account(3, name = "tracked_mints")]
#[account(4, name = "weight_table")]
#[account(5, writable, name = "epoch_snapshot")]
#[account(6, writable, signer, name = "payer")]
#[account(7, name = "restaking_program")]
#[account(8, name = "system_program")]
#[account(3, name = "weight_table")]
#[account(4, writable, name = "epoch_snapshot")]
#[account(5, writable, signer, name = "payer")]
#[account(6, name = "restaking_program")]
#[account(7, name = "system_program")]
InitializeEpochSnapshot{
epoch: u64,
},

/// Initializes the Operator Snapshot
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, name = "restaking_config")]
#[account(2, name = "ncn")]
#[account(3, name = "operator")]
Expand All @@ -114,20 +113,19 @@ pub enum TipRouterInstruction {
},

/// Initializes the Vault Operator Delegation Snapshot
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, name = "restaking_config")]
#[account(2, name = "tracked_mints")]
#[account(3, name = "ncn")]
#[account(4, name = "operator")]
#[account(5, name = "vault")]
#[account(6, name = "vault_ncn_ticket")]
#[account(7, name = "ncn_vault_ticket")]
#[account(8, name = "vault_operator_delegation")]
#[account(9, name = "weight_table")]
#[account(10, writable, name = "epoch_snapshot")]
#[account(11, writable, name = "operator_snapshot")]
#[account(12, name = "vault_program")]
#[account(13, name = "restaking_program")]
#[account(2, name = "ncn")]
#[account(3, name = "operator")]
#[account(4, name = "vault")]
#[account(5, name = "vault_ncn_ticket")]
#[account(6, name = "ncn_vault_ticket")]
#[account(7, name = "vault_operator_delegation")]
#[account(8, name = "weight_table")]
#[account(9, writable, name = "epoch_snapshot")]
#[account(10, writable, name = "operator_snapshot")]
#[account(11, name = "vault_program")]
#[account(12, name = "restaking_program")]
SnapshotVaultOperatorDelegation{
epoch: u64,
},
Expand All @@ -141,8 +139,7 @@ pub enum TipRouterInstruction {
#[account(6, name = "ncn_vault_ticket")]
#[account(7, name = "restaking_program_id")]
#[account(8, name = "vault_program_id")]
RegisterMint,

RegisterVault,

/// Initializes the base reward router
#[account(0, name = "restaking_config")]
Expand Down Expand Up @@ -194,7 +191,7 @@ pub enum TipRouterInstruction {

/// Distributes base rewards
#[account(0, name = "restaking_config")]
#[account(1, name = "ncn_config")]
#[account(1, name = "config")]
#[account(2, name = "ncn")]
#[account(3, writable, name = "base_reward_router")]
#[account(4, writable, name = "base_fee_wallet")]
Expand All @@ -206,7 +203,7 @@ pub enum TipRouterInstruction {

/// Distributes base ncn reward routes
#[account(0, name = "restaking_config")]
#[account(1, name = "ncn_config")]
#[account(1, name = "config")]
#[account(2, name = "ncn")]
#[account(3, name = "operator")]
#[account(4, writable, name = "base_reward_router")]
Expand All @@ -219,7 +216,7 @@ pub enum TipRouterInstruction {

/// Distributes ncn operator rewards
#[account(0, name = "restaking_config")]
#[account(1, name = "ncn_config")]
#[account(1, name = "config")]
#[account(2, name = "ncn")]
#[account(3, writable, name = "operator")]
#[account(4, writable, name = "ncn_reward_router")]
Expand All @@ -231,7 +228,7 @@ pub enum TipRouterInstruction {

/// Distributes ncn vault rewards
#[account(0, name = "restaking_config")]
#[account(1, name = "ncn_config")]
#[account(1, name = "config")]
#[account(2, name = "ncn")]
#[account(3, name = "operator")]
#[account(4, writable, name = "vault")]
Expand All @@ -243,19 +240,19 @@ pub enum TipRouterInstruction {

/// Sets the NCN fee group for a mint
#[account(0, name = "restaking_config")]
#[account(1, name = "ncn_config")]
#[account(1, name = "config")]
#[account(2, name = "ncn")]
#[account(3, name = "weight_table")]
#[account(4, writable, name = "tracked_mints")]
#[account(5, signer, writable, name = "admin")]
#[account(6, name = "restaking_program")]
SetTrackedMintNcnFeeGroup{
AdminSetRegisteredStMint{
vault_index: u64,
ncn_fee_group: u8,
},

/// Initializes the ballot box for an NCN
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "ballot_box")]
#[account(2, name = "ncn")]
#[account(3, writable, signer, name = "payer")]
Expand All @@ -265,7 +262,7 @@ pub enum TipRouterInstruction {
},

/// Cast a vote for a merkle root
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "ballot_box")]
#[account(2, name = "ncn")]
#[account(3, name = "epoch_snapshot")]
Expand All @@ -279,7 +276,7 @@ pub enum TipRouterInstruction {
},

/// Set the merkle root after consensus is reached
#[account(0, writable, name = "ncn_config")]
#[account(0, writable, name = "config")]
#[account(1, name = "ncn")]
#[account(2, name = "ballot_box")]
#[account(3, name = "vote_account")]
Expand All @@ -296,7 +293,7 @@ pub enum TipRouterInstruction {
},

/// Set tie breaker in case of stalled voting
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "ballot_box")]
#[account(2, name = "ncn")]
#[account(3, signer, name = "tie_breaker_admin")]
Expand All @@ -307,7 +304,7 @@ pub enum TipRouterInstruction {
},

/// Resizes the ballot box account
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "ballot_box")]
#[account(2, name = "ncn")]
#[account(3, writable, signer, name = "payer")]
Expand All @@ -317,7 +314,7 @@ pub enum TipRouterInstruction {
},

/// Resizes the operator snapshot account
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, name = "restaking_config")]
#[account(2, name = "ncn")]
#[account(3, name = "operator")]
Expand All @@ -332,7 +329,7 @@ pub enum TipRouterInstruction {
},

/// Resizes the base reward router account
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "base_reward_router")]
#[account(2, name = "ncn")]
#[account(3, writable, signer, name = "payer")]
Expand All @@ -342,7 +339,7 @@ pub enum TipRouterInstruction {
},

/// Resizes the weight table account
#[account(0, name = "ncn_config")]
#[account(0, name = "config")]
#[account(1, writable, name = "weight_table")]
#[account(2, name = "ncn")]
#[account(3, name = "tracked_mints")]
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod ncn_config;
pub mod ncn_fee_group;
pub mod ncn_reward_router;
pub mod stake_weight;
pub mod tracked_mints;
pub mod utils;
pub mod vault_registry;
pub mod weight_entry;
pub mod weight_table;
2 changes: 1 addition & 1 deletion core/src/ncn_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct NcnConfig {
}

impl Discriminator for NcnConfig {
const DISCRIMINATOR: u8 = Discriminators::NCNConfig as u8;
const DISCRIMINATOR: u8 = Discriminators::NcnConfig as u8;
}

impl NcnConfig {
Expand Down
Loading

0 comments on commit b3f0d11

Please sign in to comment.