> For the complete documentation index, see [llms.txt](https://nostraswap.gitbook.io/nostraswap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nostraswap.gitbook.io/nostraswap/protocol/smart-contract-architecture/nostraswappair.md).

# NostraSwapPair

## Code <a href="#code" id="code"></a>

//add link to code

## Address <a href="#address" id="address"></a>

//add link to address

## Events <a href="#events" id="events"></a>

### Mint <a href="#mint" id="mint"></a>

```
event Mint(address indexed sender, uint amount0, uint amount1);
```

Emitted each time liquidity tokens are created via [mint](https://uniswap.org/docs/v2/smart-contracts/pair/#mint-1).

### Burn <a href="#burn" id="burn"></a>

```
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
```

Emitted each time liquidity tokens are destroyed via [burn](https://uniswap.org/docs/v2/smart-contracts/pair/#burn-1).

### Swap <a href="#swap" id="swap"></a>

```
event Swap(address indexed sender,  uint amount0In,  uint amount1In,  uint amount0Out,  uint amount1Out,  address indexed to, uint preArbK, uint postArbK);
```

Emitted each time a swap occurs via [swap](https://uniswap.org/docs/v2/smart-contracts/pair/#swap-1).

### Sync <a href="#sync" id="sync"></a>

```
event Sync(uint112 reserve0, uint112 reserve1);
```

Emitted each time reserves are updated via [mint](https://uniswap.org/docs/v2/smart-contracts/pair/#mint-1), [burn](https://uniswap.org/docs/v2/smart-contracts/pair/#burn-1), [swap](https://uniswap.org/docs/v2/smart-contracts/pair/#swap-1), or [sync](https://uniswap.org/docs/v2/smart-contracts/pair/#sync-1).

## Read-Only Functions <a href="#read-only-functions" id="read-only-functions"></a>

### MINIMUM\_LIQUIDITY <a href="#minimum_liquidity" id="minimum_liquidity"></a>

```
function MINIMUM_LIQUIDITY() external pure returns (uint);
```

Returns `1000` for all pairs. See Minimum Liquidity.

### factory <a href="#factory" id="factory"></a>

```
function factory() external view returns (address);
```

Returns the [factory address](https://uniswap.org/docs/v2/smart-contracts/factory/#address).

### token0 <a href="#token0" id="token0"></a>

```
function token0() external view returns (address);
```

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

### token1 <a href="#token1" id="token1"></a>

```
function token1() external view returns (address);
```

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

### getReserves <a href="#getreserves" id="getreserves"></a>

```
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
```

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

### externalPool0 <a href="#price0cumulativelast" id="price0cumulativelast"></a>

```
function externalPool0() external view returns (uint);
```

Returns address of the corresponding pair in a third-party DEX. See [A](https://uniswap.org/docs/v2/core-concepts/oracles/)rbitrage.

### externalPool1 <a href="#price1cumulativelast" id="price1cumulativelast"></a>

```
function externalPool1() external view returns (uint);
```

Returns address of the corresponding pair in a third-party DEX. See Arbitrage.

### kLast <a href="#klast" id="klast"></a>

```
function kLast() external view returns (uint);
```

Returns the product of the reserves as of the most recent liquidity event.

### limitRate

```
function limitRate() external view returns(uint224);
```

Returns the limitRate per second used to calculate oracle prices.

### lpips

```
function lpips() external view returns(uint224[2][7] memory);
```

Returns the limitPriceImpactPerSecond array calculated from `limitRate`

## State-Changing Functions <a href="#state-changing-functions" id="state-changing-functions"></a>

### mint <a href="#mint-1" id="mint-1"></a>

```
function mint(address to) external returns (uint liquidity);
```

Creates pool tokens.

* Emits [Mint](https://uniswap.org/docs/v2/smart-contracts/pair/#mint), [Sync](https://uniswap.org/docs/v2/smart-contracts/pair/#sync), [Transfer](https://uniswap.org/docs/v2/smart-contracts/pair-erc-20#transfer).

### burn <a href="#burn-1" id="burn-1"></a>

```
function burn(address to) external returns (uint amount0, uint amount1);
```

Destroys pool tokens.

* Emits [Burn](https://uniswap.org/docs/v2/smart-contracts/pair/#burn), [Sync](https://uniswap.org/docs/v2/smart-contracts/pair/#sync), [Transfer](https://uniswap.org/docs/v2/smart-contracts/pair-erc-20#transfer).

### swap <a href="#swap-1" id="swap-1"></a>

```
function swap(uint amount0Out, uint amount1Out, address to, bool refund0) external;
```

Swaps tokens. Refunds profit to `to`

* Emits [Swap](https://uniswap.org/docs/v2/smart-contracts/pair/#swap), [Sync](https://uniswap.org/docs/v2/smart-contracts/pair/#sync).

### skim <a href="#skim" id="skim"></a>

```
function skim(address to) external;
```

Transfer leftover balances to `msg.sender`

### sync <a href="#sync-1" id="sync-1"></a>

```
function sync() external;
```

Syncs reserves with balances

* Emits [Sync](https://uniswap.org/docs/v2/smart-contracts/pair/#sync).

### setLimitPriceImpact

```
function setLimitPriceImpact(uint224) external;
```

Set `limitRate` and recalculate `lpips` array. Only timelock contract may call this.

## Interface <a href="#interface" id="interface"></a>

```
pragma solidity >=0.5.0;

interface INostraSwapPair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function getOraclePrice1() external view returns (uint224 oraclePrice, uint32 latestBlockTimestamp);
    function getOraclePrice0() external view returns (uint224 oraclePrice, uint32 latestBlockTimestamp);
    function kLast() external view returns (uint);

    function limitRate() external view returns(uint224);
    function lpips() external view returns(uint224[2][7] memory);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bool refund0) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
    function setLimitPriceImpact(uint224) external;
}

```

### ABI

//add abi
