Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
manlikeHB committed Oct 28, 2024
1 parent 0f5e2bf commit 0faac4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
7 changes: 2 additions & 5 deletions onchain/cairo/.snfoundry_cache/.prev_tests_failed
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions onchain/cairo/src/launchpad/launchpad.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions onchain/cairo/src/tests/launchpad_tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()];
Expand All @@ -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 }
}
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 0faac4e

Please sign in to comment.