mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-24 15:53:11 +00:00
fix(stablecoin): derive controller gain scale
This commit is contained in:
parent
65de004238
commit
1679d5a4b8
@ -58,6 +58,10 @@ impl Ids {
|
|||||||
AccountId::new([8; 32])
|
AccountId::new([8; 32])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn oracle_source() -> AccountId {
|
||||||
|
AccountId::new([10; 32])
|
||||||
|
}
|
||||||
|
|
||||||
fn redemption_controller() -> AccountId {
|
fn redemption_controller() -> AccountId {
|
||||||
compute_redemption_controller_pda(
|
compute_redemption_controller_pda(
|
||||||
Self::stablecoin_program(),
|
Self::stablecoin_program(),
|
||||||
@ -189,7 +193,7 @@ impl Accounts {
|
|||||||
quote_asset: Ids::collateral_definition(),
|
quote_asset: Ids::collateral_definition(),
|
||||||
price,
|
price,
|
||||||
timestamp,
|
timestamp,
|
||||||
source_id: String::from("twap"),
|
source_id: Ids::oracle_source(),
|
||||||
confidence_interval: 0,
|
confidence_interval: 0,
|
||||||
}),
|
}),
|
||||||
nonce: Nonce(0),
|
nonce: Nonce(0),
|
||||||
|
|||||||
@ -2,11 +2,16 @@ use nssa_core::{
|
|||||||
account::{Account, AccountId, AccountWithMetadata, Data},
|
account::{Account, AccountId, AccountWithMetadata, Data},
|
||||||
program::{AccountPostState, ProgramId},
|
program::{AccountPostState, ProgramId},
|
||||||
};
|
};
|
||||||
use stablecoin_core::{verify_redemption_controller_and_get_seed, RedemptionController};
|
use stablecoin_core::{
|
||||||
|
verify_redemption_controller_and_get_seed, RedemptionController, CONTROLLER_GAIN_SCALE,
|
||||||
|
};
|
||||||
use token_core::TokenDefinition;
|
use token_core::TokenDefinition;
|
||||||
use twap_oracle_core::OraclePriceAccount;
|
use twap_oracle_core::OraclePriceAccount;
|
||||||
|
|
||||||
const CONTROLLER_GAIN_SCALE_I128: i128 = 1_000_000_000;
|
const CONTROLLER_GAIN_SCALE_I128: i128 = {
|
||||||
|
assert!(CONTROLLER_GAIN_SCALE <= i128::MAX as u128);
|
||||||
|
CONTROLLER_GAIN_SCALE as i128
|
||||||
|
};
|
||||||
|
|
||||||
/// Initialize the redemption-rate feedback controller for one stablecoin/feed pair.
|
/// Initialize the redemption-rate feedback controller for one stablecoin/feed pair.
|
||||||
///
|
///
|
||||||
@ -345,6 +350,10 @@ mod tests {
|
|||||||
AccountId::new([3; 32])
|
AccountId::new([3; 32])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn oracle_source_id() -> AccountId {
|
||||||
|
AccountId::new([15; 32])
|
||||||
|
}
|
||||||
|
|
||||||
fn controller_id() -> AccountId {
|
fn controller_id() -> AccountId {
|
||||||
compute_redemption_controller_pda(
|
compute_redemption_controller_pda(
|
||||||
STABLECOIN_PROGRAM_ID,
|
STABLECOIN_PROGRAM_ID,
|
||||||
@ -393,7 +402,7 @@ mod tests {
|
|||||||
quote_asset: collateral_definition_id(),
|
quote_asset: collateral_definition_id(),
|
||||||
price,
|
price,
|
||||||
timestamp,
|
timestamp,
|
||||||
source_id: "twap".to_owned(),
|
source_id: oracle_source_id(),
|
||||||
confidence_interval: 0,
|
confidence_interval: 0,
|
||||||
}),
|
}),
|
||||||
nonce: Nonce(0),
|
nonce: Nonce(0),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user