Contract Info
Contract Name: move_fun::legacy_coin
Resources
Info
Represents the global storage for managing the legacy coin supply and details.
struct Info<phantom BuyCoinType, phantom SellCoinType> has key {
total_bound_supply: u64,
liquidity_supply: Coin<BuyCoinType>,
target_price_numerator: u64,
target_price_denominator: u64,
buy_coin_store: Coin<BuyCoinType>,
sell_coin_store: Coin<SellCoinType>,
virtual_balance_store: smart_table::SmartTable<address, Coin<BuyCoinType>>,
max_wallet_balance: Option<u64>,
}
CoinMetadata
Stores metadata for the legacy coin.
struct CoinMetadata<phantom CoinType> has key, store {
name: String,
symbol: String,
decimals: u8,
max_supply: u64,
logo: String,
banner: String,
description: String,
links: vector<String>
}
Events
CoinDeployed
Emitted when the coin is deployed.
#[event]
struct CoinDeployed has drop, store {
coin_address: String,
name: String,
symbol: String,
decimals: u8,
max_supply: u64,
logo: String,
banner: String,
description: String,
links: vector<String>
}
CoinBought
Emitted when coins are bought.
#[event]
struct CoinBought has drop, store {
buyer: address,
coin: String,
amount_base_value: u64,
amount_exponent_value: u64,
at_price_numerator: u64,
at_price_denominator: u64,
paid: u64,
paid_coin: String,
accumulated_sell_supply: u64,
remaining_supply: u64,
}
CoinSold
Emitted when coins are sold.
#[event]
struct CoinSold has drop, store {
seller: address,
coin: String,
amount_base_value: u64,
amount_exponent_value: u64,
at_price_numerator: u64,
at_price_denominator: u64,
received: u64,
received_coin: String,
accumulated_sell_supply: u64,
remaining_supply: u64,
}
Public Functions
Initialize Legacy Coin
Initializes the legacy coin with bonding curve parameters and metadata.
public(friend) fun initialize<BuyCoinType, SellCoinType>(
signer_ref: &signer,
max_supply: u64,
initial_price_numerator: u64,
initial_price_denominator: u64,
target_price_numerator: u64,
target_price_denominator: u64,
bound_supply_percentage: u8,
logo: String,
banner: String,
description: String,
links: vector<String>,
max_wallet_balance: Option<u64>
)
Buy Legacy Coin
Allows users to buy coins based on the bonding curve.
public(friend) fun buy<BuyCoinType, SellCoinType>(
buyer: &signer,
amount_base_value: u64,
amount_exponent_value: u64
) acquires Info
Sell Legacy Coin
Allows users to sell coins back into the bonding curve.
public(friend) fun sell<BuyCoinType, SellCoinType>(
seller: &signer,
amount_base_value: u64,
amount_exponent_value: u64
) acquires Info
View Functions
Get Metadata
Retrieves the metadata for the legacy coin.
#[view]
public fun metadata<CoinType>(): (String, String, u8, u64, String, String, String, vector<String>) acquires CoinMetadata