From 296359a832c9fbc10fc503d2a1610271998aa6e0 Mon Sep 17 00:00:00 2001 From: Vinay Singh Date: Wed, 14 Feb 2024 21:25:32 +0530 Subject: [PATCH] all pairs fetched from multicontract handling --- src/contracts/factoryAddress/abi.json | 317 ++++++++++---------------- src/hooks/useV2Pairs.ts | 6 +- 2 files changed, 122 insertions(+), 201 deletions(-) diff --git a/src/contracts/factoryAddress/abi.json b/src/contracts/factoryAddress/abi.json index 7ec43f1a..1215ec2e 100644 --- a/src/contracts/factoryAddress/abi.json +++ b/src/contracts/factoryAddress/abi.json @@ -1,248 +1,167 @@ [ { - "name": "JediSwapV2FactoryImpl", - "type": "impl", - "interface_name": "jediswap_v2_core::jediswap_v2_factory::IJediSwapV2Factory" - }, - { - "name": "jediswap_v2_core::jediswap_v2_factory::IJediSwapV2Factory", - "type": "interface", - "items": [ - { - "name": "fee_amount_tick_spacing", - "type": "function", - "inputs": [ - { - "name": "fee", - "type": "core::integer::u32" - } - ], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" + "data": [ + { + "name": "token0", + "type": "felt" }, { - "name": "get_pool", - "type": "function", - "inputs": [ - { - "name": "token_a", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "token_b", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "fee", - "type": "core::integer::u32" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" + "name": "token1", + "type": "felt" }, { - "name": "create_pool", - "type": "function", - "inputs": [ - { - "name": "token_a", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "token_b", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "fee", - "type": "core::integer::u32" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" + "name": "pair", + "type": "felt" }, { - "name": "enable_fee_amount", - "type": "function", - "inputs": [ - { - "name": "fee", - "type": "core::integer::u32" - }, - { - "name": "tick_spacing", - "type": "core::integer::u32" - } - ], - "outputs": [], - "state_mutability": "external" + "name": "total_pairs", + "type": "felt" } - ] + ], + "keys": [], + "name": "pair_created", + "type": "event" }, { - "name": "OwnableImpl", - "type": "impl", - "interface_name": "openzeppelin::access::ownable::interface::IOwnable" - }, - { - "name": "openzeppelin::access::ownable::interface::IOwnable", - "type": "interface", - "items": [ - { - "name": "owner", - "type": "function", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - }, + "inputs": [ { - "name": "transfer_ownership", - "type": "function", - "inputs": [ - { - "name": "new_owner", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" + "name": "pair_contract_class_hash", + "type": "felt" }, { - "name": "renounce_ownership", - "type": "function", - "inputs": [], - "outputs": [], - "state_mutability": "external" + "name": "fee_to_setter", + "type": "felt" } - ] + ], + "name": "constructor", + "outputs": [], + "type": "constructor" }, { - "name": "constructor", - "type": "constructor", "inputs": [ { - "name": "owner", - "type": "core::starknet::contract_address::ContractAddress" + "name": "token0", + "type": "felt" }, { - "name": "pool_class_hash", - "type": "core::starknet::class_hash::ClassHash" + "name": "token1", + "type": "felt" + } + ], + "name": "get_pair", + "outputs": [ + { + "name": "pair", + "type": "felt" } - ] + ], + "stateMutability": "view", + "type": "function" }, { - "kind": "struct", - "name": "jediswap_v2_core::jediswap_v2_factory::JediSwapV2Factory::PoolCreated", - "type": "event", - "members": [ + "inputs": [], + "name": "get_all_pairs", + "outputs": [ { - "kind": "data", - "name": "token0", - "type": "core::starknet::contract_address::ContractAddress" + "name": "all_pairs_len", + "type": "felt" }, { - "kind": "data", - "name": "token1", - "type": "core::starknet::contract_address::ContractAddress" - }, + "name": "all_pairs", + "type": "felt*" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "get_num_of_pairs", + "outputs": [ { - "kind": "data", - "name": "fee", - "type": "core::integer::u32" - }, + "name": "num_of_pairs", + "type": "felt" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "get_fee_to", + "outputs": [ { - "kind": "data", - "name": "tick_spacing", - "type": "core::integer::u32" - }, + "name": "address", + "type": "felt" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "get_fee_to_setter", + "outputs": [ { - "kind": "data", - "name": "pool", - "type": "core::starknet::contract_address::ContractAddress" + "name": "address", + "type": "felt" } - ] + ], + "stateMutability": "view", + "type": "function" }, { - "kind": "struct", - "name": "jediswap_v2_core::jediswap_v2_factory::JediSwapV2Factory::FeeAmountEnabled", - "type": "event", - "members": [ - { - "kind": "data", - "name": "fee", - "type": "core::integer::u32" - }, + "inputs": [], + "name": "get_pair_contract_class_hash", + "outputs": [ { - "kind": "data", - "name": "tick_spacing", - "type": "core::integer::u32" + "name": "class_hash", + "type": "felt" } - ] + ], + "stateMutability": "view", + "type": "function" }, { - "kind": "struct", - "name": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred", - "type": "event", - "members": [ - { - "kind": "data", - "name": "previous_owner", - "type": "core::starknet::contract_address::ContractAddress" + "inputs": [ + { + "name": "tokenA", + "type": "felt" }, { - "kind": "data", - "name": "new_owner", - "type": "core::starknet::contract_address::ContractAddress" + "name": "tokenB", + "type": "felt" } - ] + ], + "name": "create_pair", + "outputs": [ + { + "name": "pair", + "type": "felt" + } + ], + "type": "function" }, { - "kind": "enum", - "name": "openzeppelin::access::ownable::ownable::OwnableComponent::Event", - "type": "event", - "variants": [ - { - "kind": "nested", - "name": "OwnershipTransferred", - "type": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred" + "inputs": [ + { + "name": "new_fee_to", + "type": "felt" } - ] + ], + "name": "set_fee_to", + "outputs": [], + "type": "function" }, { - "kind": "enum", - "name": "jediswap_v2_core::jediswap_v2_factory::JediSwapV2Factory::Event", - "type": "event", - "variants": [ - { - "kind": "nested", - "name": "PoolCreated", - "type": "jediswap_v2_core::jediswap_v2_factory::JediSwapV2Factory::PoolCreated" - }, - { - "kind": "nested", - "name": "FeeAmountEnabled", - "type": "jediswap_v2_core::jediswap_v2_factory::JediSwapV2Factory::FeeAmountEnabled" - }, + "inputs": [ { - "kind": "flat", - "name": "OwnableEvent", - "type": "openzeppelin::access::ownable::ownable::OwnableComponent::Event" + "name": "new_fee_to_setter", + "type": "felt" } - ] + ], + "name": "set_fee_to_setter", + "outputs": [], + "type": "function" } ] diff --git a/src/hooks/useV2Pairs.ts b/src/hooks/useV2Pairs.ts index c00d32dd..3c72a055 100644 --- a/src/hooks/useV2Pairs.ts +++ b/src/hooks/useV2Pairs.ts @@ -27,6 +27,8 @@ export function useV2Pairs( [currencies] ) + const allPairs = useAllPairs() + const pairAddresses = useMemo( () => tokens.map(([tokenA, tokenB]) => { @@ -38,8 +40,8 @@ export function useV2Pairs( ) const validatedPairAddress = useMemo( - () => pairAddresses.map((addr) => (addr && pairs.includes(addr) ? addr : undefined)), - [pairs, pairAddresses] + () => pairAddresses.map((addr) => (addr && allPairs.includes(addr) ? addr : undefined)), + [allPairs, pairAddresses] ) const results = useMultipleContractSingleData(validatedPairAddress, JediswapPairABI, 'get_reserves')