Skip to content

Commit

Permalink
Merge branch 'main' into feat/lfg
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Oct 7, 2024
2 parents f6c3d6e + 8d6b5ef commit d5d74fb
Show file tree
Hide file tree
Showing 3 changed files with 834 additions and 373 deletions.
188 changes: 91 additions & 97 deletions onchain/cairo/src/launchpad/launchpad.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -309,23 +309,23 @@ pub mod LaunchpadMarketplace {
self.accesscontrol.assert_only_role(ADMIN_ROLE);
// self.ownable.assert_only_owner();
self.address_jediswap_factory_v2.write(address_jediswap_factory_v2);
self
.emit(
SetJediwapV2Factory { address_jediswap_factory_v2: address_jediswap_factory_v2 }
);
// self
// .emit(
// SetJediwapV2Factory { address_jediswap_factory_v2: address_jediswap_factory_v2 }
// );
}

fn set_address_jediswap_nft_router_v2(
ref self: ContractState, address_jediswap_nft_router_v2: ContractAddress
) {
self.accesscontrol.assert_only_role(ADMIN_ROLE);
self.address_jediswap_nft_router_v2.write(address_jediswap_nft_router_v2);
self
.emit(
SetJediwapNFTRouterV2 {
address_jediswap_nft_router_v2: address_jediswap_nft_router_v2
}
);
// self
// .emit(
// SetJediwapNFTRouterV2 {
// address_jediswap_nft_router_v2: address_jediswap_nft_router_v2
// }
// );
}

fn set_exchanges_address(
Expand Down Expand Up @@ -573,50 +573,47 @@ pub mod LaunchpadMarketplace {
// 80% bought by others

// TODO finish test and fix
if pool_coin.liquidity_raised >= threshold {
self
.emit(
LiquidityCanBeAdded {
pool: pool_coin.token_address.clone(),
asset: pool_coin.token_address.clone(),
quote_token_address: pool_coin.token_quote.token_address.clone(),
}
);
if pool_coin.liquidity_raised >= threshold {// self
// .emit(
// LiquidityCanBeAdded {
// pool: pool_coin.token_address.clone(),
// asset: pool_coin.token_address.clone(),
// quote_token_address: pool_coin.token_quote.token_address.clone(),
// }
// );
// self._add_liquidity(coin_address, SupportedExchanges::Jediswap);
}

if mc >= threshold_mc {
// println!("mc >= threshold_mc");
self
.emit(
LiquidityCanBeAdded {
pool: pool_coin.token_address.clone(),
asset: pool_coin.token_address.clone(),
quote_token_address: pool_coin.token_quote.token_address.clone(),
}
);
if mc >= threshold_mc {// println!("mc >= threshold_mc");
// self
// .emit(
// LiquidityCanBeAdded {
// pool: pool_coin.token_address.clone(),
// asset: pool_coin.token_address.clone(),
// quote_token_address: pool_coin.token_quote.token_address.clone(),
// }
// );
// self._add_liquidity(coin_address, SupportedExchanges::Jediswap);
}

// TODO check reetrancy guard
// Update state
self.shares_by_users.write((get_caller_address(), coin_address), share_user.clone());
self.launched_coins.write(coin_address, pool_coin.clone());

self
.emit(
BuyToken {
caller: get_caller_address(),
token_address: coin_address,
amount: amount,
price: total_price,
protocol_fee: amount_protocol_fee,
// creator_fee: 0,
last_price: old_price,
timestamp: get_block_timestamp(),
quote_amount: quote_amount
}
);
// self
// .emit(
// BuyToken {
// caller: get_caller_address(),
// token_address: coin_address,
// amount: amount,
// price: total_price,
// protocol_fee: amount_protocol_fee,
// // creator_fee: 0,
// last_price: old_price,
// timestamp: get_block_timestamp(),
// quote_amount: quote_amount
// }
// );
}


Expand Down Expand Up @@ -706,20 +703,19 @@ pub mod LaunchpadMarketplace {
.shares_by_users
.write((get_caller_address(), coin_address.clone()), share_user.clone());
self.launched_coins.write(coin_address.clone(), pool_update.clone());

self
.emit(
SellToken {
caller: get_caller_address(),
key_user: coin_address,
amount: quote_amount,
price: total_price,
protocol_fee: amount_protocol_fee,
creator_fee: amount_creator_fee,
timestamp: get_block_timestamp(),
last_price: old_price,
}
);
// self
// .emit(
// SellToken {
// caller: get_caller_address(),
// key_user: coin_address,
// amount: quote_amount,
// price: total_price,
// protocol_fee: amount_protocol_fee,
// creator_fee: amount_creator_fee,
// timestamp: get_block_timestamp(),
// last_price: old_price,
// }
// );
}


Expand Down Expand Up @@ -868,17 +864,17 @@ pub mod LaunchpadMarketplace {
self.array_coins.write(total_token, token);
}

self
.emit(
CreateToken {
caller: get_caller_address(),
token_address: token_address,
symbol: symbol,
name: name,
initial_supply,
total_supply: initial_supply.clone(),
}
);
// self
// .emit(
// CreateToken {
// caller: get_caller_address(),
// token_address: token_address,
// symbol: symbol,
// name: name,
// initial_supply,
// total_supply: initial_supply.clone(),
// }
// );
token_address
}

Expand Down Expand Up @@ -976,20 +972,19 @@ pub mod LaunchpadMarketplace {
self.total_launch.write(total_launch + 1);
self.array_launched_coins.write(total_launch, launch_token_pump);
}

self
.emit(
CreateLaunch {
caller: get_caller_address(),
token_address: coin_address,
amount: 0,
price: initial_key_price,
total_supply: total_supply,
slope: slope,
threshold_liquidity: threshold,
quote_token_address: quote_token_address,
}
);
// self
// .emit(
// CreateLaunch {
// caller: get_caller_address(),
// token_address: coin_address,
// amount: 0,
// price: initial_key_price,
// total_supply: total_supply,
// slope: slope,
// threshold_liquidity: threshold,
// quote_token_address: quote_token_address,
// }
// );
}

// TODO add liquidity to Ekubo, Jediswap and others exchanges enabled
Expand Down Expand Up @@ -1089,20 +1084,19 @@ pub mod LaunchpadMarketplace {
};

let (token_id, _, _, _) = nft_router.mint(mint_params);

// TODO Locked LP token

self
.emit(
LiquidityCreated {
id: token_id,
pool: pool,
quote_token_address: quote_token_address,
// token_id:token_id,
owner: launch.owner,
asset: asset_token_address,
}
);
// TODO Locked LP token

// self
// .emit(
// LiquidityCreated {
// id: token_id,
// pool: pool,
// quote_token_address: quote_token_address,
// // token_id:token_id,
// owner: launch.owner,
// asset: asset_token_address,
// }
// );
} else { // TODO
// Increase liquidity of this pool.
}
Expand Down
Loading

0 comments on commit d5d74fb

Please sign in to comment.