Skip to main content

Passive Concentrated Liquidity Pools

Overview

Astroport’s passive concentrated liquidity (PCL) pools optimize for a passive and automatic LP experience for concentrated liquidity. Instead of depositors actively managing their price ranges, liquidity becomes concentrated around an internal oracle price - this is the moving average of recent trades in a pair.

More details around how PCL pools function can be found here.

InstantiateMsg

Initializes a new concentrated liquidity pair.

json
Copy

_17
{
_17
"token_code_id": 123,
_17
"factory_addr": "terra...",
_17
"asset_infos": [
_17
{
_17
"token": {
_17
"contract_addr": "terra..."
_17
}
_17
},
_17
{
_17
"native_token": {
_17
"denom": "uusd"
_17
}
_17
}
_17
],
_17
"init_params": "<base64_encoded_json_string>"
_17
}

where <base64_encoded_json_string> is

json
Copy

_12
{
_12
"amp": "40.0",
_12
"gamma": "0.0001",
_12
"mid_fee": "0.005",
_12
"out_fee": "0.01",
_12
"fee_gamma": "0.001",
_12
"repeg_profit_threshold": "0.0001",
_12
"min_price_scale_delta": "0.000001",
_12
"initial_price_scale": "1.5",
_12
"ma_half_time": 600,
_12
"owner": "terra..."
_12
}

Note, the aforementioned values are just examples and have no practical meaning.

ExecuteMsg

receive

Withdraws liquidity or assets that were swapped to (ask assets from a swap operation).

json
Copy

_7
{
_7
"receive": {
_7
"sender": "terra...",
_7
"amount": "123",
_7
"msg": "<base64_encoded_json_string>"
_7
}
_7
}

provide_liquidity

Provides liquidity by sending a user's native or token assets to the pool.

NOTE

NOTE: you should increase your token allowance for the pool before providing liquidity!

json
Copy

_25
{
_25
"provide_liquidity": {
_25
"assets": [
_25
{
_25
"info": {
_25
"token": {
_25
"contract_addr": "terra..."
_25
}
_25
},
_25
"amount": "1000000"
_25
},
_25
{
_25
"info": {
_25
"native_token": {
_25
"denom": "uusd"
_25
}
_25
},
_25
"amount": "1000000"
_25
}
_25
],
_25
"auto_stake": false,
_25
"receiver": "terra...",
_25
"slippage_tolerance": "0.01"
_25
}
_25
}

withdraw_liquidity

Burn LP tokens and withdraw liquidity from a pool. This call must be sent to a LP token contract associated with the pool from which you want to withdraw liquidity from.

json
Copy

_3
{
_3
"withdraw_liquidity": {}
_3
}

swap

Perform a swap. offer_asset is your source asset and to is the address that will receive the ask assets. All fields are optional except offer_asset.

json
Copy

_15
{
_15
"swap": {
_15
"offer_asset": {
_15
"info": {
_15
"native_token": {
_15
"denom": "uluna"
_15
}
_15
},
_15
"amount": "123"
_15
},
_15
"belief_price": "123",
_15
"max_spread": "123",
_15
"to": "terra..."
_15
}
_15
}

update_config

Update the concentrated liquidity pair's configuration.

json
Copy

_5
{
_5
"update_config": {
_5
"params": "<base64_encoded_json_string>"
_5
}
_5
}

where <base64_encoded_json_string> is one of

  1. Update parameters
json
Copy

_7
{
_7
"update": {
_7
"mid_fee": "0.1",
_7
"out_fee": "0.01",
_7
...
_7
}
_7
}

  1. Update Amp or Gamma
json
Copy

_7
{
_7
"promote": {
_7
"next_amp": "44",
_7
"next_gamma": "0.001",
_7
"future_time": 1570257049
_7
}
_7
}

  1. Stop Amp and Gamma change
json
Copy

_3
{
_3
"stop_changing_amp_gamma": {}
_3
}

QueryMsg

pair

Queries information about a pair.

json
pair_concentrated.rs
Copy

_3
{
_3
"pair": {}
_3
}

Returns a PairInfo response struct.

pool

Queries information about a pool.

json
pair_concentrated.rs
Copy

_3
{
_3
"pool": {}
_3
}

PoolResponse

This struct is used to return a query result with the total amount of LP tokens and assets in a specific pool.

json
pair_concentrated.rs
Copy

_21
{
_21
"assets": [
_21
{
_21
"info": {
_21
"token": {
_21
"contract_addr": "..."
_21
}
_21
},
_21
"amount": "100000"
_21
},
_21
{
_21
"info": {
_21
"native_token": {
_21
"denom": "..."
_21
}
_21
},
_21
"amount": "100000"
_21
}
_21
],
_21
"total_share": "1234567"
_21
}

ParamsTypeDescription
assetsVec<Asset>The assets in the pool together with asset amounts
total_shareUint128The total amount of LP tokens currently issued

config

Queries contract configuration settings.

json
pair_concentrated.rs
Copy

_3
{
_3
"config": {}
_3
}

ConfigResponse

This struct is used to return a query result with the general contract configuration.

json
pair_concentrated.rs
Copy

_5
{
_5
"block_time_last": 1234567,
_5
"params": "<base64_encoded_json_string>",
_5
"owner": "..."
_5
}

ParamsTypeDescription
block_time_lastu64The assets in the pool together with asset amounts
paramsOption<Binary>The pool's parameters
ownerOption<Addr>The contract owner

share

Queries information about the share of a pool.

json
pair_concentrated.rs
Copy

_5
{
_5
"share": {
_5
"amount": "1000000"
_5
}
_5
}

ParamsTypeDescription
amountUint128Share of the pool

Returns a vector that contains objects of type Asset.

simulation

Queries information about a swap simulation.

json
pair_concentrated.rs
Copy

_17
{
_17
"simulation": {
_17
"offer_asset": {
_17
"info": {
_17
"token": {
_17
"contract_addr": "..."
_17
}
_17
},
_17
"amount": "100000"
_17
},
_17
"ask_asset_info": {
_17
"native_token": {
_17
"denom": "..."
_17
}
_17
}
_17
}
_17
}

ParamsTypeDescription
offer_assetAssetOffer asset
ask_asset_infoOption<AssetInfo>Ask asset info

SimulationResponse

This structure holds the parameters that are returned from a swap simulation response.

json
pair_concentrated.rs
Copy

_5
{
_5
"return_amount": "123456",
_5
"spread_amount": "0",
_5
"commission_amount": "123"
_5
}

ParamsTypeDescription
return_amountUint128The amount of ask assets returned by the swap
spread_amountUint128The spread used in the swap operation
commission_amountUint128The amount of fees charged by the transaction

reverse_simulation

Queries information about a reverse swap simulation.

json
pair_concentrated.rs
Copy

_17
{
_17
"reverse_simulation": {
_17
"offer_asset_info": {
_17
"native_token": {
_17
"denom": "..."
_17
}
_17
},
_17
"ask_asset": {
_17
"info": {
_17
"token": {
_17
"contract_addr": "..."
_17
}
_17
},
_17
"amount": "100000"
_17
}
_17
}
_17
}

ParamsTypeDescription
offer_asset_infoOption<AssetInfo>Offer asset info
ask_assetAssetAsk asset

ReverseSimulationResponse

This structure holds the parameters that are returned from a reverse swap simulation response.

json
pair_concentrated.rs
Copy

_5
{
_5
"offer_amount": "12345",
_5
"spread_amount": "0",
_5
"commission_amount": "123"
_5
}

ParamsTypeDescription
offer_amountUint128The amount of offer assets returned by the reverse swap
spread_amountUint128The spread used in the swap operation
commission_amountUint128The amount of fees charged by the transaction

cumulative_prices

Queries information about cumulative prices in a pool.

json
pair_concentrated.rs
Copy

_3
{
_3
"cumulative_prices": {}
_3
}

CumulativePricesResponse

This structure is used to return a cumulative prices query response.

json
pair_concentrated.rs
Copy

_23
{
_23
"assets": [
_23
{
_23
"info": {
_23
"token": {
_23
"contract_addr": "..."
_23
}
_23
},
_23
"amount": "100000"
_23
},
_23
{
_23
"info": {
_23
"native_token": {
_23
"denom": "..."
_23
}
_23
},
_23
"amount": "100000"
_23
}
_23
],
_23
"total_share": "12345667",
_23
"price0_cumulative_last": "12345667",
_23
"price1_cumulative_last": "12345667"
_23
}

ParamsTypeDescription
assetsVec<Asset>The assets in the pool to query
total_shareUint128The total amount of LP tokens currently issued
cumulative_pricesVec<(AssetInfo, AssetInfo, Uint128)>The vector contains cumulative prices for each pair of assets in the pool

query_compute_d

Returns current D value for the pool.

json
pair_concentrated.rs
Copy

_3
{
_3
"query_compute_d": {}
_3
}

Returns Decimal256

lp_price

Query LP token virtual price.

json
pair_concentrated.rs
Copy

_3
{
_3
"lp_price": {}
_3
}

Returns Decimal256

amp_gamma

Query curremt Amp and Gamma parameters.

json
pair_concentrated.rs
Copy

_3
{
_3
"amp_gamma": {}
_3
}

asset_balance_at

Queries the balance of the specified asset that was in the pool just preceeding the moment of the specified block height creation. The query will return None (null) if the balance was not tracked up to the specified block height.

json
pair_concentrated.rs
Copy

_10
{
_10
"asset_balance_at": {
_10
"asset_info": {
_10
"native_token": {
_10
"denom": "stake"
_10
}
_10
},
_10
"block_height": "12345678"
_10
}
_10
}

observe

Queries price from stored observations. If observation was not found at exact time then it is interpolated using surrounding observations.

json
pair_concentrated.rs
Copy

_5
{
_5
"observe": {
_5
"seconds_ago": 3600
_5
}
_5
}

OracleObservation (Response)

This structure is used to return an observation query response.

json
observation.rs
Copy

_4
{
_4
"timestamp": 12345,
_4
"price": "1.23"
_4
}

ParamsTypeDescription
timestampu64The timestamp for returned price observations
priceDecimalThe price from stored observations