Curve

Introduction

The Curve ADO allows users to to move a value along a curve. The owner of the ADO can specify the exact curve equation they desire. The curve can be either a growth (Value increasing) or decay (Value decreasing) based on what the owner specifies.

Exponential curves have the following form:

y=abcxy= ab^{cx}

Where:

a is the base value,

b is the constant value,

and c is the multiple variable value.

For decay curves, the formula would be:

y=abcxy= ab^{-cx}

The constants a, c, and b are defined at instantiation. Users can then query the equation for the y value given the x value.

Currently only exponential curves are allowed.

Ado_type: curve

Version: 0.2.0

InstantiateMsg

pub struct InstantiateMsg {
    pub curve_config: CurveConfig,
    pub authorized_operator_addresses: Option<Vec<AndrAddr>>,
    pub kernel_address: String,
    pub owner: Option<String>,
} 
Name
Type
Description

curve_config

Specifies the curve equation to use.

authorized_operator_addresses

Option<Vec<AndrAddr>>

Optional set of addresses that are authorized to update or reset the curve.

kernel_address

String

Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts.

owner

Option<String>

Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

CurveConfig

Specifies the equation of the curve. The equation is of the form:

y=abcxy= ab^{cx}

For decay curves, the formula would be:

y=abcxy= ab^{-cx}
#[cw_serde]
pub enum CurveConfig {
    ExpConfig {
        curve_id: CurveId,
        base_value: u64,
        multiple_variable_value: Option<u64>,
        constant_value: Option<u64>,
    },
}

#[cw_serde]
pub enum CurveId {
    Growth,
    Decay,
}
Name
Type
Description

curve_id

CurveId

Whether to use a growing curve (multiple variable is taken as positive) or a decaying curve (multiple variable is taken as negative).

base_value

u64

Specifies the a constant.

multiple_variable_value

Option<u64>

Specifies the c constant. Defaults to 1 if not specified.

constant_value

Option<u64>

Specifies the b constant. Defaults to 0 if not specified.

Examples

Curve Id
Base Value
Multiple Value
Constant Value
Equation

Growth

4

3

10

y=1043xy = 10*4^{3x}

Decay

7

3

8

y=873xy = 8*7^{-3x}

Growth

2

undefined

undefined

y=2xy = 2^x

ExecuteMsg

UpdateCurveConfig

Updates the curve equation set at instantiation.

Only available to the contract owner or one of the authorized addresses.

pub enum ExecuteMsg {
    UpdateCurveConfig {
         curve_config: CurveConfig 
         }
    }

Reset

Removes the curve data from the ADO. If called, the curve will no longer exist. UpdateCurveConfig can be called to create a new one.

Only available to the contract owner or one of the authorized addresses.

pub enum ExecuteMsg {
  Reset {},
  }

Base Executes

The rest of the execute messages can be found in the ADO Base section.

QueryMsg

GetCurveConfig

Queries the curve equation values set by the owner.

pub enum QueryMsg {
#[returns(GetCurveConfigResponse)]
    GetCurveConfig {},
}

GetCurveConfigResponse

#[cw_serde]
pub struct GetCurveConfigResponse {
    pub curve_config: CurveConfig,
}

Returns a CurveConfig struct.

GetPlotYFromX

Specify the X value for the equation and get the Y value.

pub enum QueryMsg {
#[returns(GetPlotYFromXResponse)]
    GetPlotYFromX { x_value: f64 },
    }
Name
Type
Description

x_value

String

The x value to be used to compute the y value.

GetPlotYFromResponse

#[cw_serde]
pub struct GetPlotYFromXResponse {
    pub y_value: String,
}
Name
Type
Description

y_value

String

The y value that is computed from the specified x value.

Base Queries

The rest of the query messages can be found in the ADO Base section.

Last updated