From 0faac4ef70c5e3af6fb581fd6490fd52698ce9cf Mon Sep 17 00:00:00 2001 From: manlikeHB Date: Tue, 29 Oct 2024 00:46:38 +0100 Subject: [PATCH] WIP --- onchain/cairo/.snfoundry_cache/.prev_tests_failed | 7 ++----- onchain/cairo/src/launchpad/launchpad.cairo | 14 ++++++++------ onchain/cairo/src/tests/launchpad_tests.cairo | 12 ++++++++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/onchain/cairo/.snfoundry_cache/.prev_tests_failed b/onchain/cairo/.snfoundry_cache/.prev_tests_failed index 324599f2..d20ffd4e 100644 --- a/onchain/cairo/.snfoundry_cache/.prev_tests_failed +++ b/onchain/cairo/.snfoundry_cache/.prev_tests_failed @@ -1,11 +1,8 @@ -afk::social::deposit::tests::claim_incorrect_gas_amount -afk::social::deposit::tests::deposit_claim -afk::social::deposit::tests::deposit_claim_gas_fee afk::tests::launchpad_tests::launchpad_tests::launchpad_buy_all_few_steps -afk::tests::launchpad_tests::launchpad_tests::launchpad_buy_and_sell +afk::tests::launchpad_tests::launchpad_tests::test_launch_token_with_uncreated_token afk::tests::launchpad_tests::launchpad_tests::launchpad_end_to_end afk::tests::launchpad_tests::launchpad_tests::launchpad_buy_more_then_liquidity_threshold afk::tests::launchpad_tests::launchpad_tests::launchpad_buy_with_amount afk::tests::launchpad_tests::launchpad_tests::launchpad_integration afk::tests::launchpad_tests::launchpad_tests::test_launchpad_end_to_end -afk::tests::launchpad_tests::launchpad_tests::test_launch_token_with_uncreated_token +afk::tests::launchpad_tests::launchpad_tests::launchpad_buy_and_sell diff --git a/onchain/cairo/src/launchpad/launchpad.cairo b/onchain/cairo/src/launchpad/launchpad.cairo index 56041b3b..0d6f4f9c 100644 --- a/onchain/cairo/src/launchpad/launchpad.cairo +++ b/onchain/cairo/src/launchpad/launchpad.cairo @@ -608,8 +608,9 @@ pub mod LaunchpadMarketplace { quote_token_address: pool_coin.token_quote.token_address.clone(), } ); - // self._add_liquidity(coin_address, SupportedExchanges::Jediswap); - self._add_liquidity(coin_address, SupportedExchanges::Ekubo, ekubo_pool_params); + //TODO choose from supported exchanges + self._add_liquidity(coin_address, SupportedExchanges::Jediswap, ekubo_pool_params); + // self._add_liquidity(coin_address, SupportedExchanges::Ekubo, ekubo_pool_params); } if mc >= threshold_mc { // println!("mc >= threshold_mc"); @@ -621,8 +622,9 @@ pub mod LaunchpadMarketplace { quote_token_address: pool_coin.token_quote.token_address.clone(), } ); - // self._add_liquidity(coin_address, SupportedExchanges::Jediswap); - self._add_liquidity(coin_address, SupportedExchanges::Ekubo, ekubo_pool_params); + //TODO choose from supported exchanges + self._add_liquidity(coin_address, SupportedExchanges::Jediswap, ekubo_pool_params); + // self._add_liquidity(coin_address, SupportedExchanges::Ekubo, ekubo_pool_params); } // TODO check reetrancy guard @@ -815,7 +817,7 @@ pub mod LaunchpadMarketplace { assert(pool.liquidity_raised >= pool.threshold_liquidity, 'no threshold raised'); assert(pool.is_liquidity_launch == false, 'liquidity already launch'); - // self._add_liquidity(coin_address, SupportedExchanges::Jediswap); + // self._add_liquidity(coin_address, SupportedExchanges::Jediswap, ekubo_pool_params); // self._add_liquidity(coin_address, SupportedExchanges::Ekubo, ekubo_pool_params); } @@ -1140,7 +1142,7 @@ pub mod LaunchpadMarketplace { SupportedExchanges::Ekubo => { match ekubo_pool_params { Option::Some(params) => self._add_liquidity_ekubo(coin_address, params), - Option::None => panic!("add Ekubo Pool Parameters to launch on ekubo"), + Option::None => panic!("add Ekubo Pool Parameters to launch on ekubo"), } } } diff --git a/onchain/cairo/src/tests/launchpad_tests.cairo b/onchain/cairo/src/tests/launchpad_tests.cairo index 2bcf2f63..59673e32 100644 --- a/onchain/cairo/src/tests/launchpad_tests.cairo +++ b/onchain/cairo/src/tests/launchpad_tests.cairo @@ -50,6 +50,11 @@ mod launchpad_tests { const LIQUIDITY_RATIO: u256 = 5; + const FACTORY_ADDRESS: felt252 = 0x01a46467a9246f45c8c340f1f155266a26a71c07bd55d36e8d1c7d0d438a2dbc; + + // fn FACTORY_ADDRESS() -> ContractAddress { + // '0x01a46467a9246f45c8c340f1f155266a26a71c07bd55d36e8d1c7d0d438a2dbc'.try_into().unwrap() + // } fn SALT() -> felt252 { 'salty'.try_into().unwrap() @@ -129,7 +134,8 @@ mod launchpad_tests { STEP_LINEAR_INCREASE, erc20_class.class_hash, THRESHOLD_LIQUIDITY, - THRESHOLD_MARKET_CAP + THRESHOLD_MARKET_CAP, + FACTORY_ADDRESS.try_into().unwrap(), ); // let launchpad = deploy_launchpad( // launch_class, @@ -157,6 +163,7 @@ mod launchpad_tests { coin_class_hash: ClassHash, threshold_liquidity: u256, threshold_marketcap: u256, + factory_address: ContractAddress, ) -> ILaunchpadMarketplaceDispatcher { // println!("deploy marketplace"); let mut calldata = array![admin.into()]; @@ -166,6 +173,7 @@ mod launchpad_tests { calldata.append_serde(coin_class_hash); calldata.append_serde(threshold_liquidity); calldata.append_serde(threshold_marketcap); + calldata.append_serde(factory_address); let (contract_address, _) = class.deploy(@calldata).unwrap(); ILaunchpadMarketplaceDispatcher { contract_address } } @@ -216,7 +224,7 @@ mod launchpad_tests { start_cheat_caller_address(launchpad.contract_address, sender_address); println!("buy coin",); - launchpad.buy_coin_by_quote_amount(token_address, amount_quote); + launchpad.buy_coin_by_quote_amount(token_address, amount_quote, Option::None); }