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.2
InstantiateMsg
token_address
Address of the CW20 token to be sold.
kernel_address
String
owner
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.
asset
The asset that may be used to purchase the token.
exchange_rate
Uint128
The amount of the above asset
required to purchase a single token.
recipient
Option<String>
The recipient of the sale proceeds. Defaults to the sender if not specified.
start_time
duration
Optional duration for the sale in milliseconds from the start_time
. If not specified then the sale never expires.
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.
recipient
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.
asset
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.
recipient
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.
asset
The asset of the sale to get info for.
SaleResponse
sale
Option<Sale>
The sale data if it exists.
Sale
exchange_rate
Uint128
The amount of exchange asset needed to purchase one token.
amount
Uint128
The amount of tokens for sale at the specified exchange_rate.
recipient
String
The recipient of the sale proceeds.
start_time
The time when the sale starts.
end_time
The time when the sale ends.
start_amount
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.
start_after
Option<String>
An optional address for which to start after, used for pagination.
limit
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.
Last updated