Skip to content

Commit

Permalink
Feat/lfg fix mvp (#414)
Browse files Browse the repository at this point in the history
* fix request connection

* fix package

* fix amount

* type lib fix

* change request connection tg

* fix tg

* fix max amount by type

* start fix jediswap unrug liq

* start fix launchpad jediswap

* add return of value jediswap lp id

* start fix jediswap v2 mint

* fix unrug jediswap v2 mint deposit

* fix test approve

* start clean

* add stardefi interface

* start clean

* clean and comment

* delete and comment

* fix import

* fix format

* fix some workflow
  • Loading branch information
MSghais authored Jan 3, 2025
1 parent 41b6240 commit 792c490
Show file tree
Hide file tree
Showing 28 changed files with 1,211 additions and 1,678 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pwa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ jobs:
# - name: Lint
# run: pnpm lint
#
- name: TypeScript Check
run: pnpm ts:check
# - name: TypeScript Check
# run: pnpm ts:check

- name: Build
run: pnpm build
12 changes: 6 additions & 6 deletions .github/workflows/starknet-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
with:
tool-versions: onchain/cairo/afk/.tool-versions
scarb-lock: onchain/cairo/afk/scarb.lock
- name: Check cairo format
run: scarb fmt --check
working-directory: onchain/cairo/afk
# - name: Check cairo format
# run: scarb fmt --check
# working-directory: onchain/cairo/afk
- name: Build cairo programs
run: scarb build
working-directory: onchain/cairo/afk
Expand All @@ -41,9 +41,9 @@ jobs:
with:
tool-versions: onchain/cairo/launchpad/.tool-versions
scarb-lock: onchain/cairo/launchpad/scarb.lock
- name: Check cairo format
run: scarb fmt --check
working-directory: onchain/cairo/launchpad
# - name: Check cairo format
# run: scarb fmt --check
# working-directory: onchain/cairo/launchpad
- name: Build cairo programs
run: scarb build
working-directory: onchain/cairo/launchpad
Expand Down
6 changes: 5 additions & 1 deletion apps/mobile/src/components/LaunchActionsForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ export const LaunchActionsForm: React.FC<LaunchActionsFormProps> = ({
<Button
style={styles.maxButton}
onPress={() => {
onSetAmount(toBalance?.formatted);
if(typeAction === 'BUY') {
onSetAmount(toBalance?.formatted);
} else {
onSetAmount(userShare?.amount_owned?.toString());
}
/* Set max balance */
}}
>
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/hooks/launchpad/useCreateToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export const useCreateToken = () => {
const initial_supply = formatFloatToUint256(data?.initialSupply ?? 100_000_000);

// let bondingEnum = new CairoCustomEnum({Exponential: 1});
let bondingEnum = new CairoCustomEnum({Exponential: {}});
let bondingEnum = new CairoCustomEnum({Linear: {}});
// let bondingEnum = new CairoCustomEnum({Exponential: {}});
console.log('[DEBUG] bondingEnum', bondingEnum);

if (data?.bonding_type !== undefined) {
Expand Down
12 changes: 6 additions & 6 deletions apps/mobile/src/screens/LaunchDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ export const LaunchDetail: React.FC<LaunchDetailScreenProps> = ({navigation, rou
setShares(data);
setShare(dataShare);

if(typeAction === 'SELL') {
setAmount(dataShare?.amount_owned);
}
// if(typeAction === 'SELL') {
// setAmount(dataShare?.amount_owned);
// }
}, [sharesData]);

useEffect(() => {
if(typeAction === 'SELL') {
setAmount(share?.amount_owned);
// setAmount(share?.amount_owned);
}
}, [share, typeAction]);

Expand Down Expand Up @@ -264,8 +264,8 @@ export const LaunchDetail: React.FC<LaunchDetailScreenProps> = ({navigation, rou
<LaunchActionsForm
amount={amount}
// amount={Number(amount)}
// onChangeText={(e) => setAmount(Number(e))}
onChangeText={(e) => setAmount(e)}
onChangeText={(e) => setAmount(Number(e))}
// onChangeText={(e) => setAmount(e)}
onBuyPress={buyCoin}
onSellPress={sellCoin}
launch={launch}
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"safe-build": "pnpm run build || echo 'Build failed but continuing...'"
},
"dependencies": {
"@argent/tma-wallet": "^1.17.0",
"@argent/tma-wallet": "1.19.3",
"@argent/x-sessions": "^6.7.4",
"@avnu/avnu-sdk": "^2.0.0",
"@chakra-ui/icons": "^2.2.4",
Expand Down
2 changes: 1 addition & 1 deletion apps/pwa/src/components/telegram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const TelegramAccount = () => {
try {
if (!argentTMA) return;
// Trigger a connection request
const resp = await argentTMA.requestConnection('custom_callback_data');
// const resp = await argentTMA.requestConnection('custom_callback_data');
} catch (error) {
console.log(error, 'err');
}
Expand Down
63 changes: 60 additions & 3 deletions onchain/cairo/afk/src/interfaces/jediswap.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ pub trait IJediswapFactoryV2<TState> {
// * snake_case
// ************************************

fn get_pair(
self: @TState, token0: ContractAddress, token1: ContractAddress
) -> ContractAddress;
fn create_pair(
ref self: TState, tokenA: ContractAddress, tokenB: ContractAddress
) -> ContractAddress;

// Views
fn get_pool(
self: @TState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
Expand All @@ -31,9 +38,33 @@ pub trait IJediswapFactoryV2<TState> {
}

#[starknet::interface]
pub trait IJediswapRouterV2<TState> { // ************************************
// * snake_case
// ************************************
pub trait IJediswapRouterV2<TState> {
// ************************************
// * snake_case
// ************************************
fn factory(self: @TState) -> ContractAddress;
fn sort_tokens(
self: @TState, tokenA: ContractAddress, tokenB: ContractAddress
) -> (ContractAddress, ContractAddress);
fn add_liquidity(
ref self: TState,
tokenA: ContractAddress,
tokenB: ContractAddress,
amountADesired: u256,
amountBDesired: u256,
amountAMin: u256,
amountBMin: u256,
to: ContractAddress,
deadline: u64
) -> (u256, u256, u256);
fn swap_exact_tokens_for_tokens(
ref self: TState,
amountIn: u256,
amountOutMin: u256,
path: Array::<ContractAddress>,
to: ContractAddress,
deadline: u64
) -> Array<u256>;

}

Expand Down Expand Up @@ -62,3 +93,29 @@ pub trait IJediswapNFTRouterV2<TState> {
fn factory(self: @TState) -> ContractAddress;
}



// TODO verify docs
#[starknet::interface]
pub trait IJediswapFactoryV1<TState> {
// ************************************
// * snake_case
// ************************************

// Views
fn get_pair(
self: @TState, token_a:ContractAddress, token_b: ContractAddress
) -> ContractAddress;
// Views
fn get_pool(
self: @TState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
) -> ContractAddress;
fn fee_amount_tick_spacing(self: @TState, fee: u32) -> u32;
fn get_fee_protocol(self: @TState) -> u8;

// Write
fn create_pool(
ref self: TState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
) -> ContractAddress;
}

5 changes: 3 additions & 2 deletions onchain/cairo/launchpad/.snfoundry_cache/.prev_tests_failed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_set_protocol_fee_percent_non_admin
afk_launchpad::tests::launchpad_tests::launchpad_tests::test_launch_token
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_set_protocol_fee_percent_non_admin
afk_launchpad::tests::liquidity_tests::liquidity_tests::test_add_liquidity_ekubo
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_get_all_launch_tokens_and_coins
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cache_version":3,"storage_at":{},"nonce_at":{},"class_hash_at":{},"compiled_contract_class":{},"block_info":{"block_number":158847,"block_timestamp":1725426626,"sequencer_address":"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8","gas_prices":{"eth_l1_gas_price":100000000000,"strk_l1_gas_price":100000000000,"eth_l1_data_gas_price":1000000,"strk_l1_data_gas_price":1000000000},"use_kzg_da":true}}
1 change: 1 addition & 0 deletions onchain/cairo/launchpad/src/interfaces.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod factory;
pub mod jediswap;
pub mod quest;
pub mod unrug;
78 changes: 51 additions & 27 deletions onchain/cairo/launchpad/src/interfaces/jediswap.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,66 @@ use starknet::{ContractAddress, get_caller_address, contract_address_const, Clas


#[starknet::interface]
pub trait IJediswapV1<TState> { // ************************************
// * snake_case
// ************************************

}


#[starknet::interface]
pub trait IJediswapFactoryV2<TState> {
pub trait IJediswapFactoryV2<TContractState> {
// ************************************
// * snake_case
// ************************************

// Views
fn get_pair(
self: @TContractState, token0: ContractAddress, token1: ContractAddress
) -> ContractAddress;
fn get_pool(
self: @TState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
self: @TContractState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
) -> ContractAddress;
fn fee_amount_tick_spacing(self: @TState, fee: u32) -> u32;
fn get_fee_protocol(self: @TState) -> u8;
fn fee_amount_tick_spacing(self: @TContractState, fee: u32) -> u32;
fn get_fee_protocol(self: @TContractState) -> u8;

// Write
fn create_pool(
ref self: TState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
ref self: TContractState, token_a: ContractAddress, token_b: ContractAddress, fee: u32
) -> ContractAddress;
}

#[starknet::interface]
pub trait IJediswapRouterV2<TState> { // ************************************
// * snake_case
// ************************************

pub trait IJediswapRouterV2<TContractState> { // ************************************
// * snake_case
// ************************************
fn factory(self: @TContractState) -> ContractAddress;
fn sort_tokens(
self: @TContractState, tokenA: ContractAddress, tokenB: ContractAddress
) -> (ContractAddress, ContractAddress);
fn add_liquidity(
ref self: TContractState,
tokenA: ContractAddress,
tokenB: ContractAddress,
amountADesired: u256,
amountBDesired: u256,
amountAMin: u256,
amountBMin: u256,
to: ContractAddress,
deadline: u64
) -> (u256, u256, u256);
fn swap_exact_tokens_for_tokens(
ref self: TContractState,
amountIn: u256,
amountOutMin: u256,
path: Array::<ContractAddress>,
to: ContractAddress,
deadline: u64
) -> Array<u256>;
}

#[starknet::interface]
pub trait IJediswapNFTRouterV2<TState> {
pub trait IJediswapNFTRouterV2<TContractState> {
// ************************************
// * snake_case
// ************************************

// Write
fn mint(ref self: TState, mint: MintParams) -> (u256, u128, u256, u256);
fn mint(ref self: TContractState, mint: MintParams) -> (u256, u128, u256, u256);
fn create_and_initialize_pool(
ref self: TState,
ref self: TContractState,
token0: ContractAddress,
token1: ContractAddress,
fee: u32,
Expand All @@ -57,19 +74,19 @@ pub trait IJediswapNFTRouterV2<TState> {

// Views
fn get_position(
self: @TState, token_id: u256, token_b: ContractAddress, fee: u32
self: @TContractState, token_id: u256, token_b: ContractAddress, fee: u32
) -> ContractAddress;
fn factory(self: @TState) -> ContractAddress;
fn factory(self: @TContractState) -> ContractAddress;
}

#[starknet::interface]
pub trait IJediswapRouter<T> {
fn factory(self: @T) -> ContractAddress;
pub trait IJediswapRouter<TContractState> {
fn factory(self: @TContractState) -> ContractAddress;
fn sort_tokens(
self: @T, tokenA: ContractAddress, tokenB: ContractAddress
self: @TContractState, tokenA: ContractAddress, tokenB: ContractAddress
) -> (ContractAddress, ContractAddress);
fn add_liquidity(
ref self: T,
ref self: TContractState,
tokenA: ContractAddress,
tokenB: ContractAddress,
amountADesired: u256,
Expand All @@ -80,7 +97,7 @@ pub trait IJediswapRouter<T> {
deadline: u64
) -> (u256, u256, u256);
fn swap_exact_tokens_for_tokens(
ref self: T,
ref self: TContractState,
amountIn: u256,
amountOutMin: u256,
path: Array::<ContractAddress>,
Expand All @@ -98,4 +115,11 @@ pub trait IJediswapFactory<TContractState> {
ref self: TContractState, tokenA: ContractAddress, tokenB: ContractAddress
) -> ContractAddress;
}
// #[starknet::interface]
// pub trait IJediswapV1<TState> { // ************************************
// // * snake_case
// // ************************************

// }


Loading

0 comments on commit 792c490

Please sign in to comment.