From 75a0f6ba588b69d96d602ffaa548afa5840f0f9b Mon Sep 17 00:00:00 2001 From: coderipper Date: Fri, 13 Dec 2024 19:35:32 -0300 Subject: [PATCH] missing update on tests+ --- apps/contracts/factory/src/lib.rs | 13 ++++++++++++- apps/contracts/factory/src/storage.rs | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/contracts/factory/src/lib.rs b/apps/contracts/factory/src/lib.rs index cbd9a5e5..160d46bb 100644 --- a/apps/contracts/factory/src/lib.rs +++ b/apps/contracts/factory/src/lib.rs @@ -11,7 +11,7 @@ use soroban_sdk::{ }; use error::FactoryError; pub use vault::create_contract; -use storage::{ add_new_defindex, extend_instance_ttl, get_admin, get_vault_wasm_hash, get_defindex_receiver, get_deployed_defindexes, get_fee_rate, has_admin, put_admin, put_vault_wasm_hash, put_defindex_receiver, put_defindex_fee }; +use storage::{ add_new_defindex, extend_instance_ttl, get_admin, get_aggregator, get_defindex_receiver, get_deployed_defindexes, get_fee_rate, get_vault_wasm_hash, has_admin, put_admin, put_aggregator, put_defindex_fee, put_defindex_receiver, put_vault_wasm_hash }; fn check_initialized(e: &Env) -> Result<(), FactoryError> { if !has_admin(e) { @@ -37,6 +37,7 @@ pub trait FactoryTrait { admin: Address, defindex_receiver: Address, defindex_fee: u32, + soroswap_aggregator: Address, vault_wasm_hash: BytesN<32> ); @@ -166,6 +167,8 @@ pub trait FactoryTrait { /// # Returns /// * `Result` - Returns the fee rate in basis points or an error if not found. fn defindex_fee(e: Env) -> Result; + + fn aggregator(e: Env) -> Result; } #[contract] @@ -179,12 +182,14 @@ impl FactoryTrait for DeFindexFactory { admin: Address, defindex_receiver: Address, defindex_fee: u32, + soroswap_aggregator: Address, vault_wasm_hash: BytesN<32> ) { put_admin(&e, &admin); put_defindex_receiver(&e, &defindex_receiver); put_vault_wasm_hash(&e, vault_wasm_hash); put_defindex_fee(&e, &defindex_fee); + put_aggregator(&e, &soroswap_aggregator); extend_instance_ttl(&e); } @@ -458,6 +463,12 @@ impl FactoryTrait for DeFindexFactory { extend_instance_ttl(&e); Ok(get_fee_rate(&e)) } + + fn aggregator(e: Env) -> Result { + check_initialized(&e)?; + extend_instance_ttl(&e); + Ok(get_aggregator(&e)) + } } mod test; \ No newline at end of file diff --git a/apps/contracts/factory/src/storage.rs b/apps/contracts/factory/src/storage.rs index 7dca9473..0ca59a0c 100644 --- a/apps/contracts/factory/src/storage.rs +++ b/apps/contracts/factory/src/storage.rs @@ -11,6 +11,7 @@ pub enum DataKey { DeFindexReceiver, DeFindexesMap, FeeRate, + Aggregator } const DAY_IN_LEDGERS: u32 = 17280; @@ -105,4 +106,13 @@ pub fn put_defindex_fee(e: &Env, value: &u32) { pub fn get_fee_rate(e: &Env) -> u32 { e.storage().instance().get(&DataKey::FeeRate).unwrap() +} + +// Soroswap Aggregator +pub fn put_aggregator(e: &Env, address: &Address) { + e.storage().instance().set(&DataKey::Aggregator, address); +} + +pub fn get_aggregator(e: &Env) -> Address { + e.storage().instance().get(&DataKey::Aggregator).unwrap() } \ No newline at end of file