4 releases (2 stable)

1.0.4 Mar 26, 2024
1.0.4-astroport-v2 Dec 7, 2023
1.0.3 Oct 23, 2023
1.0.3-astroport-v2 Oct 31, 2023

#10 in #liquidity

Download history 61/week @ 2024-07-26 56/week @ 2024-08-02 71/week @ 2024-08-09 188/week @ 2024-08-16 200/week @ 2024-08-23 128/week @ 2024-08-30 57/week @ 2024-09-06 43/week @ 2024-09-13 71/week @ 2024-09-20 49/week @ 2024-09-27 85/week @ 2024-10-04 80/week @ 2024-10-11 73/week @ 2024-10-18 60/week @ 2024-10-25 87/week @ 2024-11-01 35/week @ 2024-11-08

267 downloads per month
Used in 4 crates (via cw-it)

GPL-3.0-only

580KB
13K SLoC

Astroport Liquidity Manager

The Astroport Liquidity Manager is a contract that allows users to provide and withdraw liquidity from the Astroport xyk and stable pools with additional slippage limit enforcement. This contract is meant to be non-upgradable and standalone. It depends only on the actual Astroport factory address. Liquidity Manager also exposes provide/withdraw simulation queries for xyk and stable pools.


InstantiateMsg

Initializes the contract with the Astroport factory contract address.

{
  "astroport_factory": "wasm1..."
}

ExecuteMsg

receive

CW20 receive msg. Handles only withdraw messages which should come from Astroport LP tokens.

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

where <base64_encoded_json_string> is a base64 encoded json string of the following format:

{
  "withdraw_liquidity": {
    "pair_msg": {
      "withdraw_liquidity": {}
    },
    "min_assets_to_receive": [
      {
        "info": {
          "native_token": {
            "denom": "uusd"
          }
        },
        "amount": "100000"
      },
      {
        "info": {
          "token": {
            "contract_addr": "wasm1...cw20address"
          }
        },
        "amount": "100000"
      }
    ]
  }
}

min_assets_to_receive enforces after-withdraw check that the user receives at least the specified amount of assets.

provide_liquidity

Provides liquidity through Liquidity Manager with slippage limit enforcement. Handles XYK pair imbalanced provide and returns excess assets to the user.

{
  "provide_liquidity": {
    "pair_addr": "wasm1...",
    "pair_msg": {
      "provide_liquidity": {
        "assets": [
          {
            "info": {
              "native_token": {
                "denom": "uusd"
              }
            },
            "amount": "100000"
          },
          {
            "info": {
              "token": {
                "contract_addr": "wasm1...cw20address"
              }
            },
            "amount": "100000"
          }
        ],
        "slippage_tolerance": "0.02",
        "auto_stake": true,
        "receiver": "wasm1...addr"
      }
    },
    "min_lp_to_receive": "1000"
  }
}

pair_msg is equal to original Astroport provide message for all pools. min_lp_to_receive enforces after-provide check that the user receives at least the specified amount of LP tokens.

QueryMsg

simulate

Simulates liquidity provide or withdraw.

Provide simulation example:

{
  "simulate_provide": {
    "pair_addr": "wasm1...addr",
    "pair_msg": {
      "provide_liquidity": {
        "assets": [
          {
            "info": {
              "native_token": {
                "denom": "uusd"
              }
            },
            "amount": "100000"
          },
          {
            "info": {
              "token": {
                "contract_addr": "wasm1...cw20address"
              }
            },
            "amount": "100000"
          }
        ],
        "slippage_tolerance": "0.02",
        "auto_stake": true,
        "receiver": "wasm1...addr"
      }
    }
  }
}

Withdraw simulation example:

{
  "simulate_withdraw": {
    "pair_addr": "wasm1...addr",
    "lp_tokens": "1000"
  }
}

Dependencies

~16MB
~343K SLoC