CW20 Exchange
Introduction
The CW20 Exchange ADO is used to sell CW20 tokens for other assets. The token to be sold is specified at instantiation, and then sales can be started on the token by the contract owner by sending them to this ADO. Each sale has an "asset" to purchase the tokens with. This asset can be:
CW20
Native
Users can then purchase the CW20 token being sold by sending the required asset to the contract.
Multiple sales can take place at the same time but no two sales can have the same purchasing asset.
ado_type: cw20-exchange
Version: 2.0.1-beta.1
InstantiateMsg
Name | Type | Description |
---|---|---|
| Address of the CW20 token to be sold. | |
| String | Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts. |
| Option<String> | Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified. |
ExecuteMsg
Receive
Receives CW20 tokens sent from the token_address
contract by performing a Send. These tokens can be set for sale or used to purchase other CW20 tokens. This depends on the attached hook message.
Cw20ReceiveMsg
The msg
in the Cw20ReceiveMsg
should be a base64 encoded Cw20HookMsg
.
Cw20HookMsg
The CW20 tokens sent with StartSale should come from the contract address specified at instantiation.
The CW20 tokens sent with Purchase should be the same as the defined Asset from StartSale message.
StartSale
Only available to the contract owner.
The asset to be traded cannot be the same as the asset being bought specified at instantiation.
Starts a sale on the CW20 tokens sent. This is attached as a msg
when sending the CW20 tokens to the Exchange ADO.
Name | Type | Description |
---|---|---|
| The asset that may be used to purchase the token. | |
| Uint128 | The amount of the above |
| Option<String> | The recipient of the sale proceeds. Defaults to the sender if not specified. |
| Optional start time in milliseconds since epoch. If not specified, then the sale will start immediately. | |
| Optional duration for the sale in milliseconds from the |
AssetInfo
Native SDK coins: To create an asset info instance of this type, provide the denomination
CW20 tokens: To create an asset info instance of this type, provide the contract address
Purchase
Purchase tokens using the CW20 tokens sent. This is attached as a msg
when sending the CW20 tokens to the Exchange ADO.
You need to send an amount wich will get you a whole number in exchange. For example if the exchange rate is 5, then you need to send a multiple of 5 and nothing in between.
Name | Type | Description |
---|---|---|
| Option<String> | Optional recipient of the purchased CW20 tokens. If not set, defaults to the sender. |
CancelSale
Only available for the contract owner.
Cancels an ongoing sale.
Name | Type | Description |
---|---|---|
| The purchasing asset of the sale to cancel. |
Purchase
Purchase tokens with native funds.
Dont be confused by the previous Purchase message. Although they share the same name, the first message is attached to a CW20 Send and is used to buy using CW20 tokens while this message is called directly on the CW20 Exchange ADO and is used to buy using native funds.
You need to attach the native funds to the message when calling this Purchase.
Name | Type | Description |
---|---|---|
| Option<String> | Optional recipient to receive the purchased tokens. Defaults to the sender if not specified. |
Base Executes
The rest of the execute messages can be found in the ADO Base section.
QueryMsg
Sale
Queries the sale info for the specified asset.
Name | Type | Description |
---|---|---|
| The asset of the sale to get info for. |
SaleResponse
Name | Type | Description |
---|---|---|
| Option<Sale> | The sale data if it exists. |
Sale
Name | Type | Description |
---|---|---|
| Uint128 | The amount of exchange asset needed to purchase one token. |
| Uint128 | The amount of tokens for sale at the specified exchange_rate. |
| String | The recipient of the sale proceeds. |
| The time when the sale starts. | |
| The time when the sale ends. | |
| Uint128 | The amount of CW20 tokens for sale at the given rate at the start of the sale |
TokenAddress
Queries the contract address of the token being purchased.
TokenAddressResponse
The address of the token being sold.
SaleAssets
Queries the different assets of the sale.
Name | Type | Description |
---|---|---|
| Option<String> | An optional address for which to start after, used for pagination. |
| Option<u32> | Optional limit to the number of assets that are returned. Default limit is 50 and the max limit is 100. |
SaleAssetsResponse
A vec of string containing each of the assets.
Base Queries
The rest of the query messages can be found in the ADO Base section.