Pair (ERC 20)

This documentation covers ERC-20 functionality for denominating pool tokens. For JediSwap-specific functionality, see Pair.

Code

Pair.cairo

Events

Approval​

@event
func Approval(owner: felt, spender: felt, amount: Uint256):
end

Emitted each time allowances is updated in approve, increaseAllowance, decreaseAllowance or transferFrom

Transfer​

@event
func Transfer(from_address: felt, to_address: felt, amount: Uint256):
end

Emitted each time a transfer occurs via transfer, transferFrom, mint, or burn.

View Functions

name​

func name() -> (name: felt):

Returns JediSwap Pair for all pairs.

symbol​

func symbol() -> (symbol: felt):

Returns JEDIP for all pairs.

decimals​

func decimals() -> (decimals: felt):

Returns 18 for all pairs.

totalSupply​

func totalSupply() -> (totalSupply: Uint256):

Returns the total amount of pool tokens for a pair.

balanceOf​

func balanceOf(account: felt) -> (balance: Uint256):

Returns the amount of pool tokens owned by an address.

allowance​

func allowance(owner: felt, spender: felt) -> (remaining: Uint256):

Returns the amount of liquidity tokens owned by an address that a spender is allowed to transfer via transferFrom.

State-Changing Functions

approve​

func approve(spender: felt, amount: Uint256) -> (success: felt):

Lets caller set their allowance for a spender.

increaseAllowance​

func increaseAllowance(spender: felt, added_value: Uint256) -> (success: felt):

Lets caller increase their allowance for a spender by added_value.

decreaseAllowance​

func decreaseAllowance(spender: felt, subtracted_value: Uint256) -> (success: felt):

Lets caller decrease their allowance for a spender by subtracted_value.

transfer​

func transfer(recipient: felt, amount: Uint256) -> (success: felt):

Lets caller send pool tokens to an address.

transferFrom​

func transferFrom(
            sender: felt, 
            recipient: felt, 
            amount: Uint256
        ) -> (success: felt):

Sends pool tokens from one address to another.

Interface

%lang starknet

from starkware.cairo.common.uint256 import Uint256

@contract_interface
namespace IJediSwapPairERC20:
    func name() -> (name: felt):
    end

    func symbol() -> (symbol: felt):
    end

    func decimals() -> (decimals: felt):
    end

    func totalSupply() -> (totalSupply: Uint256):
    end

    func balanceOf(account: felt) -> (balance: Uint256):
    end

    func allowance(owner: felt, spender: felt) -> (remaining: Uint256):
    end

    func transfer(recipient: felt, amount: Uint256) -> (success: felt):
    end

    func transferFrom(
            sender: felt, 
            recipient: felt, 
            amount: Uint256
        ) -> (success: felt):
    end

    func approve(spender: felt, amount: Uint256) -> (success: felt):
    end

    func increaseAllowance(spender: felt, added_value: Uint256) -> (success: felt):
    end

    func decreaseAllowance(spender: felt, subtracted_value: Uint256) -> (success: felt):
    end
end

ABI

See Pair ABI

Last updated