Bonding Curve

Contract Info

  • Contract Name: move_fun::bonding_curve

  • Contract Address: [tba]

Resources


BondingCurve

Represents a bonding curve for a token.

struct BondingCurve has key, drop {
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    growth_constant: u128
}
Name
Type
Description

initial_price_numerator

u128

Initial price numerator for the token.

initial_price_denominator

u128

Initial price denominator for the token.

growth_constant

u128

Growth constant (k) that determines how the price scales with supply.


Public Functions


Initialize

Initializes the bonding curve with initial price and growth constant.

public(friend) fun initialize(
    signer_ref: &signer,
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    growth_constant: u128
)
Input Values
Type
Description

signer_ref

signer

The signer's reference.

initial_price_numerator

u128

The initial numerator for the token price.

initial_price_denominator

u128

The initial denominator for the token price.

growth_constant

u128

The growth constant (k) for the bonding curve.


Calculate Growth Constant

Calculates the growth constant ( k ) based on the bonding curve parameters.

public(friend) fun calculate_k(
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    target_price_numerator: u128,
    target_supply: u128,
    max_supply: u128
): u128
Input Values
Type
Description

initial_price_numerator

u128

Initial price numerator.

initial_price_denominator

u128

Initial price denominator.

target_price_numerator

u128

Target price numerator.

target_supply

u128

Target supply amount.

max_supply

u128

Maximum supply amount.


Calculate Price

Calculates the token price based on the supply and bonding curve parameters.

public(friend) fun calculate_price(
    curve: &BondingCurve,
    max_supply: u128,
    decimals: u128,
    new_supply_base_value: u128,
    new_supply_exponent_value: u128
): u128
Input Values
Type
Description

curve

&BondingCurve

The bonding curve reference.

max_supply

u128

Maximum supply of the token.

decimals

u128

Number of decimals to use for precision.

new_supply_base_value

u128

The new supply base value.

new_supply_exponent_value

u128

The new supply exponent value.


Set Market Cap Goal

Adjusts the bonding curve based on a new target market cap.

public(friend) fun set_market_cap_goal(
    coin_addr: address, 
    initial_price_numerator: u128,
    initial_price_denominator: u128,
    target_price_numerator: u128,
    target_supply: u128,
    max_supply: u128
): u128 acquires BondingCurve
Input Values
Type
Description

coin_addr

address

Address of the token.

initial_price_numerator

u128

Initial price numerator.

initial_price_denominator

u128

Initial price denominator.

target_price_numerator

u128

Target price numerator.

target_supply

u128

Target supply amount.

max_supply

u128

Maximum supply amount.


View Functions


Initial Price

Returns the initial price of the bonding curve for a token.

public fun initial_price<CoinType>(): (u128, u128) acquires BondingCurve
Return Values
Type
Description

initial_price_numerator

u128

Initial price numerator of the token.

initial_price_denominator

u128

Initial price denominator of the token.


Growth Constant

Returns the growth constant ( k ) for the bonding curve of a token.

public fun growth_constant<CoinType>(): u128 acquires BondingCurve
Return Values
Type
Description

growth_constant

u128

Growth constant ( k ) of the bonding curve.

Last updated