Smart Contracts

Module: move_fun::bonding_curve

Module Info

  • Description: Core logic for managing bonding curves used in fungible asset pricing.


Resources

BondingCurves

struct BondingCurves has key {
    table: table::Table<String, BondingCurve>
}

BondingCurve

struct BondingCurve has key, drop, store, copy {
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    growth_constant: u128
}

Public Functions

Function
Arguments
Type
Description

initialize<CoinType>

Initialize bonding curve for a token.

initialize_fa

Initialize bonding curve for a fungible asset object.

calculate_k

initial_price_n, initial_price_d, goal

u128, u128, u128

Calculate the growth constant k.

calculate_buy_amount_out

amount_in, supply, k

u128, u128, u128

Get amount out when buying with given input.

calculate_buy_amount_in

amount_out, supply, k

u128, u128, u128

Get amount needed to buy specific output.

calculate_sell_amount_out

amount_in, supply, k

u128, u128, u128

Get amount received when selling tokens.

calculate_sell_amount_in

amount_out, supply, k

u128, u128, u128

Calculate tokens needed to get a specific return.

calculate_price

supply, k

u128, u128

Calculate token price based on supply.

calculate_price_by_amounts

amount, supply, k

u128, u128, u128

Quick price calculation helper.

set_market_cap_goal

curve_id, new_goal

String, u128

Adjust bonding curve’s growth constant k.

bonding_curve<CoinType>

Access bonding curve for a token.

fa_bonding_curve

fa_addr

address

Access bonding curve for a fungible asset.

initial_price

curve_id

String

Return initial price numerator and denominator.

growth_constant

curve_id

String

Return the growth constant k.


Errors

Code
Description

1

Same growth constant as existing.

2

Amount out exceeds limits.


Module: move_fun::fungible_asset

Module Info

  • Description: Defines a fungible asset backed by a bonding curve with mechanisms for buying, selling, and tracking supply.


Resources

Resource
Description

Registry

Manages fungible asset info per address.

Info

Stores bonding curve data and metadata.

Store

Manages virtual balances for wallets.

FaMetadata

Holds icon, banner, description, and external links.


Events

Event
Description

FaDeployed

Emitted after deploying a FA.

FaBought

Emitted after a successful FA buy.

FaSold

Emitted after a successful FA sale.

BundleBuy

Emitted after bundled buy distribution.

FeeExtracted

Emitted after fee extraction.


Entry Functions

Function
Arguments
Type
Description

initialize_registry

Setup the registry resource.

initialize<DEX>

signer, metadata, config

&signer, struct, struct

Initialize a new fungible asset with DEX target.

buy_exact_out

&signer, amount

&signer, u64

Buy exact amount of FA, paying MOVE.

buy_exact_in

&signer, amount_in

&signer, u64

Buy as much FA as possible with fixed MOVE input.

sell_exact_in

&signer, amount_in

&signer, u64

Sell fixed amount of FA for MOVE.

sell_exact_out

&signer, amount_out

&signer, u64

Sell tokens to receive exact MOVE amount.

quote_buy_exact_in

amount_in

u64

Return FA amount receivable for given MOVE input.

quote_buy_exact_out

amount_out

u64

Return MOVE needed to get exact FA amount.

quote_sell_exact_in

amount_in

u64

Return MOVE receivable from selling FA.

quote_sell_exact_out

amount_out

u64

Return FA needed to receive target MOVE.

retrieve_accumulated_supply

&signer

&signer

Withdraw raised MOVE from bonding curve.

claim

&signer

&signer

Claim tokens after bonding phase ends.

retrieve_liquidity_supply

&signer

&signer

Withdraw liquidity-bound FA.

distribute_virtual_balances

Distribute virtual tokens to holders.

target_price

Get the current FA target price.

transfer_from_virtual_balance

&signer, recipient, amount

&signer, address, u64

Transfer virtual balance tokens.

batch_transfer

&signer, recipients, amounts

&signer, vector<address>, vector<u64>

Transfer to many recipients.

set_bonding_curve_goal_reached

&signer

&signer

Finalize bonding curve.

Last updated