Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refac felt to bytearray #448

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions onchain/cairo/launchpad/.snfoundry_cache/.prev_tests_failed
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_get_coin_amount_by_quote_amount_for_buy_steps
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_get_coin_amount_by_quote_amount_for_buy_steps_exp
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_launch_token
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_set_protocol_fee_percent_non_admin
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_get_all_launch_tokens_and_coins
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_get_coin_amount_by_quote_amount_for_buy_steps_exp
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_launchpad_end_to_end_exponential
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_buy_and_sell
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_buy_all_and_claim
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_buy_all
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_end_to_end
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_launchpad_end_to_end_linear
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_buy_coin_exp_with_different_supply
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_buy_coin_with_different_supply
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_buy_and_sell_exp
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_integration_exp
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_integration_linear
afk_launchpad::tests::liquidity_tests::liquidity_tests::test_add_liquidity_ekubo
afk_launchpad::tests::unrug_tests::unrug_tests::test_add_liquidity_ekubo
afk_launchpad::tests::unrug_tests::unrug_tests::test_launch_on_jediswap
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_get_coin_amount_by_quote_amount_for_buy_steps
afk_launchpad::tests::launchpad_tests::launchpad_tests::launchpad_buy_all_exp_curve
8 changes: 4 additions & 4 deletions onchain/cairo/launchpad/src/interfaces/launchpad.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ pub trait ILaunchpadMarketplace<TContractState> {
fn create_token(
ref self: TContractState,
recipient: ContractAddress,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool
) -> ContractAddress;

fn create_and_launch_token(
ref self: TContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool,
Expand Down
8 changes: 5 additions & 3 deletions onchain/cairo/launchpad/src/interfaces/unrug.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub trait IUnrugLiquidity<TContractState> {
// User call
fn create_token(
ref self: TContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252
) -> ContractAddress;
Expand Down Expand Up @@ -86,7 +86,9 @@ pub trait IUnrugLiquidity<TContractState> {
);
fn set_address_ekubo_factory(ref self: TContractState, address_ekubo_factory: ContractAddress);
fn set_address_ekubo_router(ref self: TContractState, address_ekubo_router: ContractAddress);
fn set_address_ekubo_registry(ref self: TContractState, new_ekubo_registry_address: ContractAddress);
fn set_address_ekubo_registry(
ref self: TContractState, new_ekubo_registry_address: ContractAddress
);
fn set_exchanges_address(
ref self: TContractState, exchanges: Span<(SupportedExchanges, ContractAddress)>
);
Expand Down
30 changes: 16 additions & 14 deletions onchain/cairo/launchpad/src/launchpad/launchpad.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ pub mod LaunchpadMarketplace {
fn create_token(
ref self: ContractState,
recipient: ContractAddress,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool
Expand All @@ -580,8 +580,8 @@ pub mod LaunchpadMarketplace {
// Create coin and launch in bonding curve
fn create_and_launch_token(
ref self: ContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool,
Expand Down Expand Up @@ -903,7 +903,7 @@ pub mod LaunchpadMarketplace {
// creator_fee: 0,
last_price: old_price,
timestamp: get_block_timestamp(),
quote_amount:remain_quote_to_liquidity
quote_amount: remain_quote_to_liquidity
// quote_amount: quote_amount
}
);
Expand Down Expand Up @@ -1368,13 +1368,13 @@ pub mod LaunchpadMarketplace {
}
}

// // Internal functions for create token, launch, add liquidity in DEX
// // Internal functions for create token, launch, add liquidity in DEX
#[generate_trait]
impl InternalFunctions of InternalFunctionsTrait {
fn _create_token(
ref self: ContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool,
Expand All @@ -1400,7 +1400,9 @@ pub mod LaunchpadMarketplace {
);
}

let mut calldata = array![name.into(), symbol.into()];
let mut calldata = array![];
Serde::serialize(@name.clone(), ref calldata);
Serde::serialize(@symbol.clone(), ref calldata);
Serde::serialize(@initial_supply, ref calldata);
Serde::serialize(@18, ref calldata);
Serde::serialize(@recipient, ref calldata);
Expand All @@ -1418,24 +1420,24 @@ pub mod LaunchpadMarketplace {
token_address: token_address,
owner: recipient,
creator: owner,
name,
symbol,
name: name.clone(),
symbol: symbol.clone(),
total_supply: initial_supply,
initial_supply: initial_supply,
created_at: get_block_timestamp(),
token_type: Option::None,
is_unruggable: is_unruggable
};

self.token_created.entry(token_address).write(token);
self.token_created.entry(token_address).write(token.clone());

let total_token = self.total_token.read();
if total_token == 0 {
self.total_token.write(1);
self.array_coins.entry(0).write(token);
self.array_coins.entry(0).write(token.clone());
} else {
self.total_token.write(total_token + 1);
self.array_coins.entry(total_token).write(token);
self.array_coins.entry(total_token).write(token.clone());
}

self
Expand Down
26 changes: 14 additions & 12 deletions onchain/cairo/launchpad/src/launchpad/launchpad_old.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ pub mod LaunchpadMarketplace {
fn create_token(
ref self: ContractState,
recipient: ContractAddress,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool
Expand All @@ -580,8 +580,8 @@ pub mod LaunchpadMarketplace {
// Create coin and launch in bonding curve
fn create_and_launch_token(
ref self: ContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool,
Expand Down Expand Up @@ -899,7 +899,7 @@ pub mod LaunchpadMarketplace {
// creator_fee: 0,
last_price: old_price,
timestamp: get_block_timestamp(),
quote_amount:remain_quote_to_liquidity
quote_amount: remain_quote_to_liquidity
// quote_amount: quote_amount
}
);
Expand Down Expand Up @@ -1364,13 +1364,13 @@ pub mod LaunchpadMarketplace {
}
}

// // Internal functions for create token, launch, add liquidity in DEX
// // Internal functions for create token, launch, add liquidity in DEX
#[generate_trait]
impl InternalFunctions of InternalFunctionsTrait {
fn _create_token(
ref self: ContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
is_unruggable: bool,
Expand All @@ -1396,7 +1396,9 @@ pub mod LaunchpadMarketplace {
);
}

let mut calldata = array![name.into(), symbol.into()];
let mut calldata = array![];
Serde::serialize(@name, ref calldata);
Serde::serialize(@symbol, ref calldata);
Serde::serialize(@initial_supply, ref calldata);
Serde::serialize(@18, ref calldata);
Serde::serialize(@recipient, ref calldata);
Expand All @@ -1423,15 +1425,15 @@ pub mod LaunchpadMarketplace {
is_unruggable: is_unruggable
};

self.token_created.entry(token_address).write(token);
self.token_created.entry(token_address).write(token.clone());

let total_token = self.total_token.read();
if total_token == 0 {
self.total_token.write(1);
self.array_coins.entry(0).write(token);
self.array_coins.entry(0).write(token.clone());
} else {
self.total_token.write(total_token + 1);
self.array_coins.entry(total_token).write(token);
self.array_coins.entry(total_token).write(token.clone());
}

self
Expand Down
6 changes: 3 additions & 3 deletions onchain/cairo/launchpad/src/launchpad/pump_wtf.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1269,15 +1269,15 @@ pub mod PumpWtf {
is_unruggable: is_unruggable
};

self.token_created.entry(token_address).write(token);
self.token_created.entry(token_address).write(token.clone());

let total_token = self.total_token.read();
if total_token == 0 {
self.total_token.write(1);
self.array_coins.entry(0).write(token);
self.array_coins.entry(0).write(token.clone());
} else {
self.total_token.write(total_token + 1);
self.array_coins.entry(total_token).write(token);
self.array_coins.entry(total_token).write(token.clone());
}

self
Expand Down
30 changes: 14 additions & 16 deletions onchain/cairo/launchpad/src/launchpad/unrug.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use starknet::ClassHash;
use starknet::ContractAddress;


#[starknet::contract]
pub mod UnrugLiquidity {
use afk_launchpad::interfaces::jediswap::{
Expand Down Expand Up @@ -431,8 +427,8 @@ pub mod UnrugLiquidity {
fn create_token(
ref self: ContractState,
// recipient: ContractAddress,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252
) -> ContractAddress {
Expand Down Expand Up @@ -666,15 +662,17 @@ pub mod UnrugLiquidity {
impl InternalFunctions of InternalFunctionsTrait {
fn _create_token(
ref self: ContractState,
symbol: felt252,
name: felt252,
symbol: ByteArray,
name: ByteArray,
initial_supply: u256,
contract_address_salt: felt252,
recipient: ContractAddress,
owner: ContractAddress,
factory: ContractAddress,
) -> ContractAddress {
let mut calldata = array![name.into(), symbol.into()];
let mut calldata = array![];
Serde::serialize(@name.clone(), ref calldata);
Serde::serialize(@symbol.clone(), ref calldata);
Serde::serialize(@initial_supply, ref calldata);
Serde::serialize(@18, ref calldata);
Serde::serialize(@recipient, ref calldata);
Expand All @@ -692,24 +690,24 @@ pub mod UnrugLiquidity {
token_address: token_address,
owner: recipient,
creator: owner,
name,
symbol,
name: name.clone(),
symbol: symbol.clone(),
total_supply: initial_supply,
initial_supply: initial_supply,
created_at: get_block_timestamp(),
token_type: Option::None,
is_unruggable: true
};

self.token_created.entry(token_address).write(token);
self.token_created.entry(token_address).write(token.clone());

let total_token = self.total_token.read();
if total_token == 0 {
self.total_token.write(1);
self.array_coins.entry(0).write(token);
self.array_coins.entry(0).write(token.clone());
} else {
self.total_token.write(total_token + 1);
self.array_coins.entry(total_token).write(token);
self.array_coins.entry(total_token).write(token.clone());
}

self
Expand Down Expand Up @@ -777,7 +775,7 @@ pub mod UnrugLiquidity {
.register_token(
EKIERC20Dispatcher { contract_address: unrug_params.token_address.clone() }
);

unrug_params.lp_supply -= amount_register;
// println!("register ok add liquidity");

Expand Down Expand Up @@ -1028,7 +1026,7 @@ pub mod UnrugLiquidity {
// quote_address: quote_address.clone(),
// created_at: get_block_timestamp(),
// exchange: SupportedExchanges::Jediswap,
// owner: owner.clone(), // TODO
// owner: owner.clone(), // TODO
// caller: owner.clone(), // TODO change caller
// unlock_time: unlock_time,
// };
Expand Down
Loading
Loading