1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Keeper operations.
use crate::decimals::PositiveDecimal;
use crate::define_enum;
use crate::time::UnixTimestampMicros;
use crate::types::{AdminType, AssetId, FeeTier, MarketId};
mod args;
pub use args::*;
define_enum! {
/// Keeper operations requiring specific admin privileges.
///
/// These operations are typically called by automated keepers/bots
/// and require specific admin types (Pricing, Funding, Credits,
/// FeeTier, Referrals). However, one can also update all admin
/// addresses with it.
#[non_exhaustive]
enum KeeperAction<Address> {
// =========================================================================
// Pricing Admin Operations (0-9)
// =========================================================================
/// Update oracle prices (PricingAdmin).
UpdateOraclePrices {
prices: Vec<OraclePriceUpdateArgs>,
publish_timestamp: UnixTimestampMicros,
} = 0,
/// Update mark prices (PricingAdmin).
UpdateMarkPrices {
prices: Vec<MarkPriceUpdateArgs>,
publish_timestamp: UnixTimestampMicros,
} = 1,
/// Update premium indexes for markets (PricingAdmin).
UpdatePremiumIndexes { market_ids: Vec<MarketId> } = 2,
/// Update oracle prices using signed Pyth payloads (PricingAdmin).
UpdateOraclePricesWithPythProofs {
prices: Vec<OraclePriceUpdateWithPythProofArgs>,
publish_timestamp: UnixTimestampMicros,
} = 3,
/// Update internal pricing for rwa perp markets (PricingAdmin).
UpdateInternalPrices {
market_ids: Vec<MarketId>,
} = 4,
// Reserved: 5-9
// =========================================================================
// Funding Admin Operations (10-19)
// =========================================================================
/// Update funding rates for markets (FundingAdmin).
UpdateFunding { market_ids: Vec<MarketId> } = 10,
// Reserved: 11-19
// =========================================================================
// Credits Admin Operations (20-29)
// =========================================================================
/// Add trading credits to a user (CreditsAdmin).
AddTradingCredits {
user_address: Address,
amount: PositiveDecimal,
} = 20,
/// Remove trading credits from a user (CreditsAdmin).
RemoveTradingCredits {
user_address: Address,
amount: PositiveDecimal,
} = 21,
// Reserved: 22-29
// =========================================================================
// FeeTier Admin Operations (30-39)
// =========================================================================
/// Update user's fee tier (FeeTierAdmin).
UpdateUserFeeTier { address: Address, fee_tier: FeeTier } = 30,
/// Update a given user's fee discount (in bps) (FeeTierAdmin).
UpdateUserFeeDiscountBps {
address: Address,
fee_discount_bps: u16,
} = 31,
// Reserved: 32-39
// =========================================================================
// Referrals Admin Operations (40-49)
// =========================================================================
/// Set a user's cumulative referral rewards to an absolute amount (ReferralsAdmin).
SetCumulativeReferralRewards {
address: Address,
asset_id: AssetId,
amount: PositiveDecimal,
} = 40,
// Reserved: 41-49
// =========================================================================
// MarketStatusAdmin Operations (50-59) (Temporarily Pricing Admin)
// =========================================================================
/// Allows for transitions between:
/// Halted -> Active / PostOnly / CancelOnly
/// Active => PostOnly / CancelOnly / Halted(Spot market only)
/// PostOnly => Active / CancelOnly / Halted(Spot market only)
/// CancelOnly => Active / PostOnly / Halted(Spot market only)
SetMarketsTradingStatus {
args: Vec<SetMarketTradingStatusArgs>,
} = 50,
/// Halt a borrow/lend pool (MarketStatusAdmin).
HaltBorrowLendPool {
asset_id: AssetId,
} = 51,
/// Unhalt a borrow/lend pool (MarketStatusAdmin).
UnhaltBorrowLendPool {
asset_id: AssetId,
} = 52,
/// Halt a perp market with settlement price (MarketStatusAdmin).
HaltPerpMarket {
market_id: MarketId,
settlement_price: PositiveDecimal,
} = 53,
}
}
impl<Address> KeeperAction<Address> {
/// Returns the specific admin type required for this keeper operation.
#[must_use]
pub fn required_admin_type(&self) -> AdminType {
#[allow(clippy::match_same_arms)]
// Temporarily allow this before I upgrade state for a MarketStateAdmin
match self {
Self::UpdateOraclePrices { .. }
| Self::UpdateMarkPrices { .. }
| Self::UpdatePremiumIndexes { .. }
| Self::UpdateOraclePricesWithPythProofs { .. }
| Self::UpdateInternalPrices { .. } => AdminType::Pricing,
Self::SetMarketsTradingStatus { .. }
| Self::HaltBorrowLendPool { .. }
| Self::UnhaltBorrowLendPool { .. }
| Self::HaltPerpMarket { .. } => AdminType::Pricing,
Self::UpdateFunding { .. } => AdminType::Funding,
Self::AddTradingCredits { .. } | Self::RemoveTradingCredits { .. } => {
AdminType::Credits
}
Self::UpdateUserFeeTier { .. } | Self::UpdateUserFeeDiscountBps { .. } => {
AdminType::FeeTier
}
Self::SetCumulativeReferralRewards { .. } => AdminType::Referrals,
}
}
}