🔬
JediSwap
  • 👋Welcome to JediSwap
  • 🛠️Become a contributor
  • 🎁DeFi spring STRK incentives for v2
  • 🎁DeFi Spring STRK incentives for v1
  • FAQ
  • How to use JediSwap
    • How to set up a Starknet wallet
      • How to set up an Argent X wallet
      • How to set up an Argent Web Wallet
      • How to set up a Braavos wallet
    • How to bridge assets to Starknet
      • How to bridge to Starknet using Starkgate
      • How to bridge to Starknet using Orbiter Finance
      • How to bridge to Starknet using LayerSwap
    • How to make a swap
    • How to add liquidity
      • How to add liquidity V1
      • How to add liquidity V2
    • How to ZAP
      • How to ZAP from Ethereum L1 to Starknet
      • How to ZAP on Starknet
    • Points
      • LP Leaderboard
      • Volume Leaderboard
  • For Developers
    • Jediswap v2
      • Core
        • jediswap_v2_factory
        • jediswap_v2_pool
      • Periphery
        • jediswap_v2_nft_position_manager
        • jediswap_v2_swap_router
      • Contract Addresses
      • Deprecated Contract Addresses
    • Jediswap v1
      • Smart Contract integration
        • Implement a swap
        • Providing liquidity
        • Pair Addresses
      • Smart contract reference
        • Router
        • Pair
        • Factory
        • Pair (ERC 20)
  • Risks associated with JediSwap
Powered by GitBook
On this page
  • get_pair
  • Off-Chain
  1. For Developers
  2. Jediswap v1
  3. Smart Contract integration

Pair Addresses

PreviousProviding liquidityNextSmart contract reference

Last updated 1 year ago

get_pair

The best way to get the address for a pair is to call on the . If the pair exists, this function will return its address else 0

  • The "canonical" way to determine whether or not a pair exists.

  • Requires an on-chain lookup.

Off-Chain

Python Example:

from starkware.starknet.core.os.contract_address.contract_address import calculate_contract_address_from_hash
from starkware.cairo.lang.vm.crypto import pedersen_hash


def get_create2_address(token0: int, token1: int, class_hash: int) -> int:

    salt = pedersen_hash(token0, token1)

    constructor_calldata = [token0,
                            token1]

    create2_pair_address = calculate_contract_address_from_hash(
        salt=salt, class_hash=class_hash, deployer_address=factory, constructor_calldata=constructor_calldata)

    return create2_pair_address
  • token0 must be strictly less than token1 by sort order.

  • Can be computed offline.

  • Requires the ability to perform pedersen_hash.

Factory
get_pair