Skip to main content

Deregistering a Pool

Overview

A specific pair (e.g ASTRO/axlUSDC) cannot have both a stableswap and a xyk pool at the same time. If someone creates a xyk for a specific token pair, Astroport governance will have to deregister the pool if the intent was to use stableswap instead. The same principle applies if someone created an invalid stableswap pool and liquidity should go to an xyk pool instead. In short, an xyk pool should not be upgraded to a stableswap pool or vice-versa.

Using the Astroport Web App

Use when submitting a proposal to deregister a pool through the Astroport Web App. This tutorial walks you through the Executable Messages field of the proposal.

Vec<ProposalMessage>

The Executable Messages field in our proposal takes in a vector containing objects of type ProposalMessage. Each ProposalMessage requires the following parameters:

  • order: The order of execution of the message
  • msg: Execution message of type CosmosMsg

_30
[
_30
{
_30
{
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": toBase64(
_30
{
_30
"deregister": {
_30
"asset_infos": [
_30
{
_30
"token": {
_30
"contract_addr": astroAddress
_30
}
_30
},
_30
{
_30
"token": {
_30
"contract_addr": steakAddress
_30
}
_30
}
_30
]
_30
}
_30
}
_30
),
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
]

wasm

CosmosMsg is an enum that supports various types of messages. To deregister a pool, our CosmosMsg must be of type wasm. Furthermore, our wasm message must be of type execute. In the backgrund, we are creating a wasm contract call to the submit_proposal endpoint in the Assembly contract.


_30
[
_30
{
_30
{
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": toBase64(
_30
{
_30
"deregister": {
_30
"asset_infos": [
_30
{
_30
"token": {
_30
"contract_addr": astroAddress
_30
}
_30
},
_30
{
_30
"token": {
_30
"contract_addr": steakAddress
_30
}
_30
}
_30
]
_30
}
_30
}
_30
),
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
]

execute

The execute operation requires the following parameters:

  • contract_addr: Address of the contract where the execute message is being sent to. For deregistering a pool, this would be the Factory contract.
  • msg: A binary encoded message containing our contract call.
  • funds: Any funds to send along with our transaction.
NOTE

This tutorial uses placeholder variables for contract addresses. Use the actual string representation of each contract address when submitting a proposal.


_30
[
_30
{
_30
{
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": toBase64(
_30
{
_30
"deregister": {
_30
"asset_infos": [
_30
{
_30
"token": {
_30
"contract_addr": astroAddress
_30
}
_30
},
_30
{
_30
"token": {
_30
"contract_addr": steakAddress
_30
}
_30
}
_30
]
_30
}
_30
}
_30
),
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
]

msg

The code in this section uses a custom function (toBase64) to display our binary message - this function needs to be defined elsewhere to be used and is not accessible within the Astroport Web App.

Use for demonstration purposes only. The actual string representation of our message will be an encoded binary, which will be covered below.


_30
[
_30
{
_30
{
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": toBase64(
_30
{
_30
"deregister": {
_30
"asset_infos": [
_30
{
_30
"token": {
_30
"contract_addr": astroAddress
_30
}
_30
},
_30
{
_30
"token": {
_30
"contract_addr": steakAddress
_30
}
_30
}
_30
]
_30
}
_30
}
_30
),
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
]

deregister

To deregister a pool, our proposal msg must point to the deregister endpoint in the Factory contract.

deregister takes in the address or native denomination of each token for the pool being deregistered stored in a vector of type AssetInfo.


_16
{
_16
"deregister": {
_16
"asset_infos": [
_16
{
_16
"token": {
_16
"contract_addr": astroAddress
_16
}
_16
},
_16
{
_16
"token": {
_16
"contract_addr": steakAddress
_16
}
_16
}
_16
]
_16
}
_16
}

Encoding our deregister msg

Our deregister message needs to be encoded and and passed as an input into our msg parameter within our execute call.

Since we are using the Astroport Web App to submit our proposal, we will encode our message manually using an online Base64 encoder.

Make sure to replace the substitute variables with contract addresses before encoding your message.

Final result

Once we encode our message, our final Executable Message that we would submit to the Astroport Web App to deregister a pool ends up looking something like the code in this section.

You can see our contract call to the deregister endpoint by decoding our msg using a Base64 decoder.


_13
[
_13
{
_13
{
_13
"wasm": {
_13
"execute": {
_13
"contract_addr": "terra1z3y69xas85r7egusa0c7m5sam0yk97gsztqmh8f2cc6rr4s4anysudp7k0", // factoryAddress
_13
"msg": "ewogICJkZXJlZ2lzdGVyIjogewogICAgImFzc2V0X2luZm9zIjogWwogICAgICB7CiAgICAgICAgInRva2VuIjogewogICAgICAgICAgImNvbnRyYWN0X2FkZHIiOiAidGVycmExNjdkc3FraDJhbHVyeDk5N3dteWN3OXlka3l1NTRneXN3ZTN5Z21yczRsd3VtZTN2bXdrczhydXFudiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAidG9rZW4iOiB7CiAgICAgICAgICAiY29udHJhY3RfYWRkciI6ICJ0ZXJyYTF4enRueDhtbTdkYWduNGNrM2RneWxhcXVjcDZoNmFndzgzcG15YzI5aG5wbHE3MzU1dHJzNzhma2NxIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ==",
_13
"funds": []
_13
}
_13
}
_13
}
_13
}
_13
]

Vec<ProposalMessage>

The Executable Messages field in our proposal takes in a vector containing objects of type ProposalMessage. Each ProposalMessage requires the following parameters:

  • order: The order of execution of the message
  • msg: Execution message of type CosmosMsg

wasm

CosmosMsg is an enum that supports various types of messages. To deregister a pool, our CosmosMsg must be of type wasm. Furthermore, our wasm message must be of type execute. In the backgrund, we are creating a wasm contract call to the submit_proposal endpoint in the Assembly contract.

execute

The execute operation requires the following parameters:

  • contract_addr: Address of the contract where the execute message is being sent to. For deregistering a pool, this would be the Factory contract.
  • msg: A binary encoded message containing our contract call.
  • funds: Any funds to send along with our transaction.
NOTE

This tutorial uses placeholder variables for contract addresses. Use the actual string representation of each contract address when submitting a proposal.

msg

The code in this section uses a custom function (toBase64) to display our binary message - this function needs to be defined elsewhere to be used and is not accessible within the Astroport Web App.

Use for demonstration purposes only. The actual string representation of our message will be an encoded binary, which will be covered below.

deregister

To deregister a pool, our proposal msg must point to the deregister endpoint in the Factory contract.

deregister takes in the address or native denomination of each token for the pool being deregistered stored in a vector of type AssetInfo.

Encoding our deregister msg

Our deregister message needs to be encoded and and passed as an input into our msg parameter within our execute call.

Since we are using the Astroport Web App to submit our proposal, we will encode our message manually using an online Base64 encoder.

Make sure to replace the substitute variables with contract addresses before encoding your message.

Final result

Once we encode our message, our final Executable Message that we would submit to the Astroport Web App to deregister a pool ends up looking something like the code in this section.

You can see our contract call to the deregister endpoint by decoding our msg using a Base64 decoder.


_30
[
_30
{
_30
{
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": toBase64(
_30
{
_30
"deregister": {
_30
"asset_infos": [
_30
{
_30
"token": {
_30
"contract_addr": astroAddress
_30
}
_30
},
_30
{
_30
"token": {
_30
"contract_addr": steakAddress
_30
}
_30
}
_30
]
_30
}
_30
}
_30
),
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
]

Submitting a Proposal Directly

An advantage of submitting a proposal directly using, for example, a js script is that you could encode your message automatically using a custom function. However, some additional steps are required to submit a proposal.

Before continuing with this section, make sure to read the section above on submitting a proposal through the Astroport Web App. The Astroport Web App essentially wraps our executable message (covered above) within a submit_proposal message to the Assembly contract. This section will focus on completing this last step.

send

To submit a proposal, you need to execute a contract call pointing to the send endpoint in the xASTRO token contract.

The send operation takes in a:

  • contract - Address where xASTRO tokens are being sent to (Assembly address)
  • amount - Amount to send/stake (30,000 xASTRO for mainnet)
  • msg - Binary encoded message containing our contract call to submit_proposal

_30
{
_30
"send": {
_30
"contract": assemblyAddress,
_30
"amount": "1000", // testnet deposit amount
_30
"msg": toBase64(
_30
{
_30
"submit_proposal": {
_30
"title": "deregister astro-steak pair",
_30
"description": "proposal to deregister inactive pair",
_30
"link": "https://forum.astroport.fi/t/arc-37-update-deployed-stableswaps-to-latest-pool-version/927",
_30
"messages": [
_30
{
_30
"order": "1",
_30
"msg": {
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": "ewogICJkZXJlZ2lzdGVyIjogewogICAgImFzc2V0X2luZm9zIjogWwogICAgICB7CiAgICAgICAgInRva2VuIjogewogICAgICAgICAgImNvbnRyYWN0X2FkZHIiOiAidGVycmExNjdkc3FraDJhbHVyeDk5N3dteWN3OXlka3l1NTRneXN3ZTN5Z21yczRsd3VtZTN2bXdrczhydXFudiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAidG9rZW4iOiB7CiAgICAgICAgICAiY29udHJhY3RfYWRkciI6ICJ0ZXJyYTF4enRueDhtbTdkYWduNGNrM2RneWxhcXVjcDZoNmFndzgzcG15YzI5aG5wbHE3MzU1dHJzNzhma2NxIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ",
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
],
_30
"ibc_channel": "..."
_30
}
_30
}
_30
)
_30
}
_30
}

submit_proposal

Our encoded message performs a contract call to the submit_proposal endpoint in the Assembly contract.

submit_proposal takes in the following parameters:

  • title: Proposal title
  • description: Description for the proposal
  • link: Link to forum discussion
  • messages: Proposal message containing our binary contract call to deregister
  • ibc_channel: If the proposal should be executed on a remote chain, this field should specify the governance channel.

All further steps to the messages parameter can be found above.


_30
{
_30
"send": {
_30
"contract": assemblyAddress,
_30
"amount": "1000", // testnet deposit amount
_30
"msg": toBase64(
_30
{
_30
"submit_proposal": {
_30
"title": "deregister astro-steak pair",
_30
"description": "proposal to deregister inactive pair",
_30
"link": "https://forum.astroport.fi/t/arc-37-update-deployed-stableswaps-to-latest-pool-version/927",
_30
"messages": [
_30
{
_30
"order": "1",
_30
"msg": {
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": "ewogICJkZXJlZ2lzdGVyIjogewogICAgImFzc2V0X2luZm9zIjogWwogICAgICB7CiAgICAgICAgInRva2VuIjogewogICAgICAgICAgImNvbnRyYWN0X2FkZHIiOiAidGVycmExNjdkc3FraDJhbHVyeDk5N3dteWN3OXlka3l1NTRneXN3ZTN5Z21yczRsd3VtZTN2bXdrczhydXFudiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAidG9rZW4iOiB7CiAgICAgICAgICAiY29udHJhY3RfYWRkciI6ICJ0ZXJyYTF4enRueDhtbTdkYWduNGNrM2RneWxhcXVjcDZoNmFndzgzcG15YzI5aG5wbHE3MzU1dHJzNzhma2NxIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ",
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
],
_30
"ibc_channel": "..."
_30
}
_30
}
_30
)
_30
}
_30
}

Encoding our submit_proposal msg

Finally, our submit_proposal message needs to be encoded and passed as an input into our msg parameter within our send call.


_30
{
_30
"send": {
_30
"contract": assemblyAddress,
_30
"amount": "1000", // testnet deposit amount
_30
"msg": toBase64(
_30
{
_30
"submit_proposal": {
_30
"title": "deregister astro-steak pair",
_30
"description": "proposal to deregister inactive pair",
_30
"link": "https://forum.astroport.fi/t/arc-37-update-deployed-stableswaps-to-latest-pool-version/927",
_30
"messages": [
_30
{
_30
"order": "1",
_30
"msg": {
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": "ewogICJkZXJlZ2lzdGVyIjogewogICAgImFzc2V0X2luZm9zIjogWwogICAgICB7CiAgICAgICAgInRva2VuIjogewogICAgICAgICAgImNvbnRyYWN0X2FkZHIiOiAidGVycmExNjdkc3FraDJhbHVyeDk5N3dteWN3OXlka3l1NTRneXN3ZTN5Z21yczRsd3VtZTN2bXdrczhydXFudiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAidG9rZW4iOiB7CiAgICAgICAgICAiY29udHJhY3RfYWRkciI6ICJ0ZXJyYTF4enRueDhtbTdkYWduNGNrM2RneWxhcXVjcDZoNmFndzgzcG15YzI5aG5wbHE3MzU1dHJzNzhma2NxIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ",
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
],
_30
"ibc_channel": "..."
_30
}
_30
}
_30
)
_30
}
_30
}

toBase64

The code in this section uses a custom function (toBase64) to display our binary message - this function needs to be defined elsewhere to be used. The actual string representation of our message would be an encoded binary, similar to our deregister message.


_3
let toBase64 = (obj) => {
_3
return Buffer.from(JSON.stringify(obj)).toString("base64");
_3
};

send

To submit a proposal, you need to execute a contract call pointing to the send endpoint in the xASTRO token contract.

The send operation takes in a:

  • contract - Address where xASTRO tokens are being sent to (Assembly address)
  • amount - Amount to send/stake (30,000 xASTRO for mainnet)
  • msg - Binary encoded message containing our contract call to submit_proposal

submit_proposal

Our encoded message performs a contract call to the submit_proposal endpoint in the Assembly contract.

submit_proposal takes in the following parameters:

  • title: Proposal title
  • description: Description for the proposal
  • link: Link to forum discussion
  • messages: Proposal message containing our binary contract call to deregister
  • ibc_channel: If the proposal should be executed on a remote chain, this field should specify the governance channel.

All further steps to the messages parameter can be found above.

Encoding our submit_proposal msg

Finally, our submit_proposal message needs to be encoded and passed as an input into our msg parameter within our send call.

toBase64

The code in this section uses a custom function (toBase64) to display our binary message - this function needs to be defined elsewhere to be used. The actual string representation of our message would be an encoded binary, similar to our deregister message.


_30
{
_30
"send": {
_30
"contract": assemblyAddress,
_30
"amount": "1000", // testnet deposit amount
_30
"msg": toBase64(
_30
{
_30
"submit_proposal": {
_30
"title": "deregister astro-steak pair",
_30
"description": "proposal to deregister inactive pair",
_30
"link": "https://forum.astroport.fi/t/arc-37-update-deployed-stableswaps-to-latest-pool-version/927",
_30
"messages": [
_30
{
_30
"order": "1",
_30
"msg": {
_30
"wasm": {
_30
"execute": {
_30
"contract_addr": factoryAddress,
_30
"msg": "ewogICJkZXJlZ2lzdGVyIjogewogICAgImFzc2V0X2luZm9zIjogWwogICAgICB7CiAgICAgICAgInRva2VuIjogewogICAgICAgICAgImNvbnRyYWN0X2FkZHIiOiAidGVycmExNjdkc3FraDJhbHVyeDk5N3dteWN3OXlka3l1NTRneXN3ZTN5Z21yczRsd3VtZTN2bXdrczhydXFudiIKICAgICAgICB9CiAgICAgIH0sCiAgICAgIHsKICAgICAgICAidG9rZW4iOiB7CiAgICAgICAgICAiY29udHJhY3RfYWRkciI6ICJ0ZXJyYTF4enRueDhtbTdkYWduNGNrM2RneWxhcXVjcDZoNmFndzgzcG15YzI5aG5wbHE3MzU1dHJzNzhma2NxIgogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ",
_30
"funds": []
_30
}
_30
}
_30
}
_30
}
_30
],
_30
"ibc_channel": "..."
_30
}
_30
}
_30
)
_30
}
_30
}