Saltearse al contenido

token_coin_swap - [testnet]

Esta página aún no está disponible en tu idioma.

Deprecated module

use 0x1::error;
use 0x1::event;
use 0x1::string;
use 0x1::table;
use 0x1::type_info;
use 0x3::token;

Constants

Deprecated module

const EDEPRECATED_MODULE: u64 = 8;

Not enough coin to buy token

const ENOT_ENOUGH_COIN: u64 = 7;

Token already listed

const ETOKEN_ALREADY_LISTED: u64 = 1;

Token buy amount doesn’t match listing amount

const ETOKEN_AMOUNT_NOT_MATCH: u64 = 6;

Token cannot be moved out of escrow before the lockup time

const ETOKEN_CANNOT_MOVE_OUT_OF_ESCROW_BEFORE_LOCKUP_TIME: u64 = 4;

Token listing no longer exists

const ETOKEN_LISTING_NOT_EXIST: u64 = 2;

Token buy price doesn’t match listing price

const ETOKEN_MIN_PRICE_NOT_MATCH: u64 = 5;

Token is not in escrow

const ETOKEN_NOT_IN_ESCROW: u64 = 3;

Structs

TokenCoinSwap

TokenCoinSwap records a swap ask for swapping token_amount with CoinType with a minimal price per token

struct TokenCoinSwap<CoinType> has drop, store
Fields
token_amount: u64
min_price_per_token: u64

TokenEscrow

TokenEscrow holds the tokens that cannot be withdrawn or transferred

struct TokenEscrow has store
Fields
token: token::Token
locked_until_secs: u64

TokenListingEvent

struct TokenListingEvent has drop, store
Fields
token_id: token::TokenId
amount: u64
min_price: u64
locked_until_secs: u64
coin_type_info: type_info::TypeInfo

TokenSwapEvent

struct TokenSwapEvent has drop, store
Fields
token_id: token::TokenId
token_buyer: address
token_amount: u64
coin_amount: u64
coin_type_info: type_info::TypeInfo

Resources

TokenListings

The listing of all tokens for swapping stored at token owner’s account

struct TokenListings<CoinType> has key
Fields
listings: table::Table<token::TokenId, token_coin_swap::TokenCoinSwap<CoinType>>
listing_events: event::EventHandle<token_coin_swap::TokenListingEvent>
swap_events: event::EventHandle<token_coin_swap::TokenSwapEvent>

TokenStoreEscrow

TokenStoreEscrow holds a map of token id to their tokenEscrow

struct TokenStoreEscrow has key
Fields
token_escrows: table::Table<token::TokenId, token_coin_swap::TokenEscrow>

Functions

does_listing_exist

public fun does_listing_exist<CoinType>(_token_owner: address, _token_id: token::TokenId): bool
Implementation
public fun does_listing_exist<CoinType>(
_token_owner: address,
_token_id: TokenId
): bool {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

exchange_coin_for_token

Coin owner withdraw coin to swap with tokens listed for swapping at the token owner’s address.

public fun exchange_coin_for_token<CoinType>(_coin_owner: &signer, _coin_amount: u64, _token_owner: address, _creators_address: address, _collection: string::String, _name: string::String, _property_version: u64, _token_amount: u64)
Implementation
public fun exchange_coin_for_token<CoinType>(
_coin_owner: &signer,
_coin_amount: u64,
_token_owner: address,
_creators_address: address,
_collection: String,
_name: String,
_property_version: u64,
_token_amount: u64,
) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

list_token_for_swap

Token owner lists their token for swapping

public entry fun list_token_for_swap<CoinType>(_token_owner: &signer, _creators_address: address, _collection: string::String, _name: string::String, _property_version: u64, _token_amount: u64, _min_coin_per_token: u64, _locked_until_secs: u64)
Implementation
public entry fun list_token_for_swap<CoinType>(
_token_owner: &signer,
_creators_address: address,
_collection: String,
_name: String,
_property_version: u64,
_token_amount: u64,
_min_coin_per_token: u64,
_locked_until_secs: u64
) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

initialize_token_listing

Initalize the token listing for a token owner

fun initialize_token_listing<CoinType>(_token_owner: &signer)
Implementation
fun initialize_token_listing<CoinType>(_token_owner: &signer) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

initialize_token_store_escrow

Intialize the token escrow

fun initialize_token_store_escrow(_token_owner: &signer)
Implementation
fun initialize_token_store_escrow(_token_owner: &signer) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

deposit_token_to_escrow

Put the token into escrow that cannot be transferred or withdrawed by the owner.

public fun deposit_token_to_escrow(_token_owner: &signer, _token_id: token::TokenId, _tokens: token::Token, _locked_until_secs: u64)
Implementation
public fun deposit_token_to_escrow(
_token_owner: &signer,
_token_id: TokenId,
_tokens: Token,
_locked_until_secs: u64
) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

withdraw_token_from_escrow_internal

Private function for withdraw tokens from an escrow stored in token owner address

fun withdraw_token_from_escrow_internal(_token_owner_addr: address, _token_id: token::TokenId, _amount: u64): token::Token
Implementation
fun withdraw_token_from_escrow_internal(
_token_owner_addr: address,
_token_id: TokenId,
_amount: u64
): Token {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

withdraw_token_from_escrow

Withdraw tokens from the token escrow. It needs a signer to authorize

public fun withdraw_token_from_escrow(_token_owner: &signer, _token_id: token::TokenId, _amount: u64): token::Token
Implementation
public fun withdraw_token_from_escrow(
_token_owner: &signer,
_token_id: TokenId,
_amount: u64
): Token {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

cancel_token_listing

Cancel token listing for a fixed amount

public fun cancel_token_listing<CoinType>(_token_owner: &signer, _token_id: token::TokenId, _token_amount: u64)
Implementation
public fun cancel_token_listing<CoinType>(
_token_owner: &signer,
_token_id: TokenId,
_token_amount: u64,
) {
abort error::invalid_argument(EDEPRECATED_MODULE)
}

Specification

pragma verify = false;