BondingCurveAdmin

Class: BondingCurveAdmin

Properties overview

  • curve: State;
  • events: {
    mint: typeof BondingMintEvent;
    redeem: typeof BondingRedeemEvent;
    };
  • mint: typeof BondingMintEvent = BondingMintEvent;
  • redeem: typeof BondingRedeemEvent = BondingRedeemEvent;
  • Overrides: TokenContract.events
  • feeMaster: State;
  • insideMint: State;
  • owner: State;
  • token: State;
  • Overrides: TokenContract.approveBase
  • Overrides: TokenContract.deploy

Methods overview

  • approveBase()
  • canChangeAdmin()
  • canChangeVerificationKey()
  • canMint()
  • canPause()
  • canResume()
  • deploy()
  • ensureOwnerSignature()
  • initialize()
  • mint()
  • redeem()
  • sync()
  • updateVerificationKey()

Defined in: packages/token/src/BondingCurveAdmin.ts:112

Extends

  • TokenContract

Implements

  • FungibleTokenAdminBase

Constructors

new BondingCurveAdmin()

new BondingCurveAdmin(address: PublicKey, tokenId?: Field): BondingCurveAdmin

Defined in: node_modules/o1js/dist/node/lib/mina/zkapp.d.ts:148

Parameters

address

PublicKey

tokenId?

Field

Returns

BondingCurveAdmin

Inherited from

TokenContract.constructor

Properties

curve

curve: State<Field>;

Defined in: packages/token/src/BondingCurveAdmin.ts:119


events

events: {
  mint: typeof BondingMintEvent;
  redeem: typeof BondingRedeemEvent;
};

Defined in: packages/token/src/BondingCurveAdmin.ts:122

A list of event types that can be emitted using this.emitEvent()`.

mint

mint: typeof BondingMintEvent = BondingMintEvent;

redeem

redeem: typeof BondingRedeemEvent = BondingRedeemEvent;

Implementation of

FungibleTokenAdminBase.events

Overrides

TokenContract.events

feeMaster

feeMaster: State<PublicKey>;

Defined in: packages/token/src/BondingCurveAdmin.ts:118


insideMint

insideMint: State<Bool>;

Defined in: packages/token/src/BondingCurveAdmin.ts:120


owner

owner: State<PublicKey>;

Defined in: packages/token/src/BondingCurveAdmin.ts:116


token

token: State<PublicKey>;

Defined in: packages/token/src/BondingCurveAdmin.ts:117

Methods

approveBase()

approveBase(forest: AccountUpdateForest): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:146

Parameters

forest

AccountUpdateForest

Returns

Promise<void>

Overrides

TokenContract.approveBase

canChangeAdmin()

canChangeAdmin(_admin: PublicKey): Promise<Bool>

Defined in: packages/token/src/BondingCurveAdmin.ts:516

Parameters

_admin

PublicKey

Returns

Promise<Bool>

Implementation of

FungibleTokenAdminBase.canChangeAdmin

canChangeVerificationKey()

canChangeVerificationKey(_vk: VerificationKey): Promise<Bool>

Defined in: packages/token/src/BondingCurveAdmin.ts:534

Parameters

_vk

VerificationKey

Returns

Promise<Bool>

Implementation of

FungibleTokenAdminBase.canChangeVerificationKey

canMint()

canMint(_accountUpdate: AccountUpdate): Promise<Bool>

Defined in: packages/token/src/BondingCurveAdmin.ts:509

Parameters

_accountUpdate

AccountUpdate

Returns

Promise<Bool>

Implementation of

FungibleTokenAdminBase.canMint

canPause()

canPause(): Promise<Bool>

Defined in: packages/token/src/BondingCurveAdmin.ts:522

Returns

Promise<Bool>

Implementation of

FungibleTokenAdminBase.canPause

canResume()

canResume(): Promise<Bool>

Defined in: packages/token/src/BondingCurveAdmin.ts:528

Returns

Promise<Bool>

Implementation of

FungibleTokenAdminBase.canResume

deploy()

deploy(props: DeployArgs): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:127

Deploys a TokenContract.

In addition to base smart contract deployment, this adds two steps:

  • set the access permission to proofOrSignature(), to prevent against unauthorized token operations
    • not doing this would imply that anyone can bypass token contract authorization and simply mint themselves tokens
  • require the zkapp account to be new, using the isNew precondition.
    this guarantees that the access permission is set from the very start of the existence of this account.
    creating the zkapp account before deployment would otherwise be a security vulnerability that is too easy to introduce.

Note that because of the isNew precondition, the zkapp account must not be created prior to calling deploy().

If the contract needs to be re-deployed, you can switch off this behaviour by overriding the isNew precondition:

async deploy() {
  await super.deploy();
  // DON'T DO THIS ON THE INITIAL DEPLOYMENT!
  this.account.isNew.requireNothing();
}

Parameters

props

DeployArgs

Returns

Promise<void>

Implementation of

FungibleTokenAdminBase.deploy

Overrides

TokenContract.deploy

ensureOwnerSignature()

ensureOwnerSignature(): AccountUpdate

Defined in: packages/token/src/BondingCurveAdmin.ts:501

Returns

AccountUpdate


initialize()

initialize(props: BondingCurveAdminInitializeProps): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:151

Parameters

props

BondingCurveAdminInitializeProps

Returns

Promise<void>


mint()

mint(
   to: PublicKey, 
   amount: UInt64, 
price: UInt64): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:203

Parameters

to

PublicKey

amount

UInt64

price

UInt64

Returns

Promise<void>


redeem()

redeem(
   amount: UInt64, 
   minPrice: UInt64, 
slippage: UInt32): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:329

Parameters

amount

UInt64

minPrice

UInt64

slippage

UInt32

Returns

Promise<void>


sync()

sync(): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:479

In case the user burned tokens without calling the redeem method,
we need to sync the supply to the actual circulated supply

Returns

Promise<void>


updateVerificationKey()

updateVerificationKey(vk: VerificationKey): Promise<void>

Defined in: packages/token/src/BondingCurveAdmin.ts:497

Update the verification key.
Note that because we have set the permissions for setting the verification key to impossibleDuringCurrentVersion(), this will only be possible in case of a protocol update that requires an update.

Parameters

vk

VerificationKey

Returns

Promise<void>