🔬
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
  • Code
  • Address
  • Events
  • Mint​
  • Burn​
  • Swap​
  • Sync​
  • View Functions
  • token0​
  • token1​
  • get_reserves
  • price_0_cumulative_last
  • price_1_cumulative_last
  • kLast​
  • State-Changing Functions
  • mint​
  • burn​
  • swap​
  • skim​
  • sync​
  • Interface
  • ABI
  1. For Developers
  2. Jediswap v1
  3. Smart contract reference

Pair

PreviousRouterNextFactory

Last updated 1 year ago

This documentation covers Uniswap-specific functionality. For ERC-20 functionality, see .

Code

Address

See

Events

Mint​

@event
func Mint(sender: felt, amount0: Uint256, amount1: Uint256):
end

Emitted each time liquidity tokens are created via .

Burn​

@event
func Burn(sender: felt, amount0: Uint256, amount1: Uint256, to: felt):
end

Swap​

@event
func Swap(sender: felt, amount0In: Uint256, amount1In: Uint256, amount0Out: Uint256, amount1Out: Uint256, to: felt):
end

Sync​

@event
func Sync(reserve0: Uint256, reserve1: Uint256):
end

View Functions

token0​

func token0() -> (address: felt):

Returns the address of the pair token with the lower sort order.

token1​

func token1() -> (address: felt):

Returns the address of the pair token with the higher sort order.

get_reserves

func get_reserves() -> (reserve0: Uint256, reserve1: Uint256, block_timestamp_last: felt):

Returns the reserves of token0 and token1 used to price trades and distribute liquidity. Also returns the get_block_timestamp() (mod 2**32) of the last block during which an interaction occurred for the pair.

price_0_cumulative_last

​func price_0_cumulative_last() -> (res: Uint256):

Returns cumulative price for token0 on last update. See Oracles. TODO

price_1_cumulative_last

​func price_1_cumulative_last() -> (res: Uint256):

Returns cumulative price for token1 on last update. See Oracles. TODO

kLast​

​func klast() -> (res: Uint256):

Returns the product of the reserves as of the most recent liquidity event. See Protocol Charge Calculation. TODO

State-Changing Functions

mint​

func mint(to: felt) -> (liquidity: Uint256):

Creates pool tokens.

burn​

func burn(to: felt) -> (amount0: Uint256, amount1: Uint256):

Destroys pool tokens.

swap​

func swap(amount0Out: Uint256, amount1Out: Uint256, to: felt, data_len: felt, data: felt*):

Swaps tokens. For regular swaps, data.length must be 0. Also see Flash Swaps. TODO

skim​

func skim(to: felt):

sync​

func sync():

Interface

%lang starknet

from starkware.cairo.common.uint256 import Uint256

@contract_interface
namespace IJediSwapPair:
    func token0() -> (address: felt):
    end

    func token1() -> (address: felt):
    end

    func get_reserves() -> (reserve0: Uint256, reserve1: Uint256, block_timestamp_last:     felt):
    end

    ​func price_0_cumulative_last() -> (res: Uint256):
    end

    ​func price_1_cumulative_last() -> (res: Uint256):
    end

    ​func klast() -> (res: Uint256):
    end

    func mint(to: felt) -> (liquidity: Uint256):
    end

    func burn(to: felt) -> (amount0: Uint256, amount1: Uint256):
    end

    func swap(amount0Out: Uint256, amount1Out: Uint256, to: felt, data_len: felt, data: felt*):
    end

    func skim(to: felt):
    end

    func sync():
    end
end

ABI

[
    {
        "members": [
            {
                "name": "low",
                "offset": 0,
                "type": "felt"
            },
            {
                "name": "high",
                "offset": 1,
                "type": "felt"
            }
        ],
        "name": "Uint256",
        "size": 2,
        "type": "struct"
    },
    {
        "data": [
            {
                "name": "from_",
                "type": "felt"
            },
            {
                "name": "to",
                "type": "felt"
            },
            {
                "name": "value",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Transfer",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "owner",
                "type": "felt"
            },
            {
                "name": "spender",
                "type": "felt"
            },
            {
                "name": "value",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Approval",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "from_address",
                "type": "felt"
            },
            {
                "name": "to_address",
                "type": "felt"
            },
            {
                "name": "amount",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Transfer",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "owner",
                "type": "felt"
            },
            {
                "name": "spender",
                "type": "felt"
            },
            {
                "name": "amount",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Approval",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "sender",
                "type": "felt"
            },
            {
                "name": "amount0",
                "type": "Uint256"
            },
            {
                "name": "amount1",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Mint",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "sender",
                "type": "felt"
            },
            {
                "name": "amount0",
                "type": "Uint256"
            },
            {
                "name": "amount1",
                "type": "Uint256"
            },
            {
                "name": "to",
                "type": "felt"
            }
        ],
        "keys": [],
        "name": "Burn",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "sender",
                "type": "felt"
            },
            {
                "name": "amount0In",
                "type": "Uint256"
            },
            {
                "name": "amount1In",
                "type": "Uint256"
            },
            {
                "name": "amount0Out",
                "type": "Uint256"
            },
            {
                "name": "amount1Out",
                "type": "Uint256"
            },
            {
                "name": "to",
                "type": "felt"
            }
        ],
        "keys": [],
        "name": "Swap",
        "type": "event"
    },
    {
        "data": [
            {
                "name": "reserve0",
                "type": "Uint256"
            },
            {
                "name": "reserve1",
                "type": "Uint256"
            }
        ],
        "keys": [],
        "name": "Sync",
        "type": "event"
    },
    {
        "inputs": [
            {
                "name": "token0",
                "type": "felt"
            },
            {
                "name": "token1",
                "type": "felt"
            }
        ],
        "name": "constructor",
        "outputs": [],
        "type": "constructor"
    },
    {
        "inputs": [],
        "name": "name",
        "outputs": [
            {
                "name": "name",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "symbol",
        "outputs": [
            {
                "name": "symbol",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "totalSupply",
        "outputs": [
            {
                "name": "totalSupply",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "decimals",
        "outputs": [
            {
                "name": "decimals",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "account",
                "type": "felt"
            }
        ],
        "name": "balanceOf",
        "outputs": [
            {
                "name": "balance",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "owner",
                "type": "felt"
            },
            {
                "name": "spender",
                "type": "felt"
            }
        ],
        "name": "allowance",
        "outputs": [
            {
                "name": "remaining",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "token0",
        "outputs": [
            {
                "name": "address",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "token1",
        "outputs": [
            {
                "name": "address",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "get_reserves",
        "outputs": [
            {
                "name": "reserve0",
                "type": "Uint256"
            },
            {
                "name": "reserve1",
                "type": "Uint256"
            },
            {
                "name": "block_timestamp_last",
                "type": "felt"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "price_0_cumulative_last",
        "outputs": [
            {
                "name": "res",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "price_1_cumulative_last",
        "outputs": [
            {
                "name": "res",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "klast",
        "outputs": [
            {
                "name": "res",
                "type": "Uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "recipient",
                "type": "felt"
            },
            {
                "name": "amount",
                "type": "Uint256"
            }
        ],
        "name": "transfer",
        "outputs": [
            {
                "name": "success",
                "type": "felt"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "sender",
                "type": "felt"
            },
            {
                "name": "recipient",
                "type": "felt"
            },
            {
                "name": "amount",
                "type": "Uint256"
            }
        ],
        "name": "transferFrom",
        "outputs": [
            {
                "name": "success",
                "type": "felt"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "spender",
                "type": "felt"
            },
            {
                "name": "amount",
                "type": "Uint256"
            }
        ],
        "name": "approve",
        "outputs": [
            {
                "name": "success",
                "type": "felt"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "spender",
                "type": "felt"
            },
            {
                "name": "added_value",
                "type": "Uint256"
            }
        ],
        "name": "increaseAllowance",
        "outputs": [
            {
                "name": "success",
                "type": "felt"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "spender",
                "type": "felt"
            },
            {
                "name": "subtracted_value",
                "type": "Uint256"
            }
        ],
        "name": "decreaseAllowance",
        "outputs": [
            {
                "name": "success",
                "type": "felt"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "to",
                "type": "felt"
            }
        ],
        "name": "mint",
        "outputs": [
            {
                "name": "liquidity",
                "type": "Uint256"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "to",
                "type": "felt"
            }
        ],
        "name": "burn",
        "outputs": [
            {
                "name": "amount0",
                "type": "Uint256"
            },
            {
                "name": "amount1",
                "type": "Uint256"
            }
        ],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "amount0Out",
                "type": "Uint256"
            },
            {
                "name": "amount1Out",
                "type": "Uint256"
            },
            {
                "name": "to",
                "type": "felt"
            },
            {
                "name": "data_len",
                "type": "felt"
            },
            {
                "name": "data",
                "type": "felt*"
            }
        ],
        "name": "swap",
        "outputs": [],
        "type": "function"
    },
    {
        "inputs": [
            {
                "name": "to",
                "type": "felt"
            }
        ],
        "name": "skim",
        "outputs": [],
        "type": "function"
    },
    {
        "inputs": [],
        "name": "sync",
        "outputs": [],
        "type": "function"
    }
]

Emitted each time liquidity tokens are destroyed via .

Emitted each time a swap occurs via .

Emitted each time reserves are updated via , , or .

Emits , , .

Emits , , .

Emits , .

See the .

See the .

Emits .

uniswap whitepaper
uniswap whitepaper
Pair (ERC-20)
Pair.cairo
Pair Addresses
mint
burn
swap
mint
burn
swap
sync
Swap
Sync
Sync
Mint
Sync
Burn
Sync
Transfer
Transfer