List of pool events
Pool factory contract address
Protocol address stored in the pool to not exceed account update limit on swap
Return a public key that is forced to sign this transaction.
Note: This doesn't prove that the return value is the transaction sender, but it proves that whoever created the transaction controls the private key associated with the returned public key.
The public key of the current transaction's sender account.
Throws an error if not inside a transaction, or the sender wasn't passed in.
Warning: The fact that this public key equals the current sender is not part of the proof. A malicious prover could use any other public key without affecting the validity of the proof.
Consider using this.sender.getAndRequireSignature() if you need to prove that the sender controls this account.
Address of first token in the pool (ordered by address) PublicKey.empty() in case of native mina
Address of second token in the pool Can't be empty
Static Optional_methodStatic Optional_methodsStatic Optional_proversStatic Optional_verificationStaticFactoryWe declare the factory contract as a static property so that it can be easily replaced in case of factory upgrade
We declare the factory contract as a static property so that it can be easily replaced in case of factory upgrade
Rest...args: anyStaticMAX_The maximum number of account updates using the token in a single transaction that this contract supports.
StaticmaxFrontend max fee, 0.10%
StaticminimumMinimun liquidity in the pool, 1000
Current account of the SmartContract.
Balance of this SmartContract.
Current global slot on the network. This is the slot at which this transaction is included in a block. Since we cannot know this value
at the time of transaction construction, this only has the assertBetween() method but no get() (impossible to implement)
or assertEquals() (confusing, because the developer can't know the exact slot at which this will be included either)
Helper methods to use from within a token contract.
Current network state of the SmartContract.
Returns the current AccountUpdate associated to this SmartContract.
Approve an account update or tree / forest of updates. Doing this means you include the account update in the zkApp's public input, which allows you to read and use its content in a proof, make assertions about it, and modify it.
`@method` myApprovingMethod(update: AccountUpdate) {
  this.approve(update);
  // read balance on the account (for example)
  let balance = update.account.balance.getAndRequireEquals();
}
Under the hood, "approving" just means that the account update is made a child of the zkApp in the tree of account updates that forms the transaction. Similarly, if you pass in an AccountUpdateTree, the entire tree will become a subtree of the zkApp's account update.
Passing in a forest is a bit different, because it means you set the entire children of the zkApp's account update
at once. approve() will fail if the zkApp's account update already has children, to prevent you from accidentally
excluding important information from the public input.
Use forEachUpdate() to prove that the total balance change of child account updates is zero.
This is provided out of the box as it is both a good example, and probably the most common implementation, of approveBase().
Asynchronously fetches events emitted by this SmartContract and returns an array of events with their corresponding types.
Optionalstart: UInt32The start height of the events to fetch.
Optionalend: UInt32The end height of the events to fetch. If not provided, fetches events up to the latest height.
A promise that resolves to an array of objects, each containing the event type and event data for the specified range.
Iterate through the account updates in updates and apply callback to each.
This method is provable and is suitable as a base for implementing approveUpdates().
Use this command if the account update created by this SmartContract should be signed by the account owner, instead of authorized with a proof.
Note that the smart contract's Permissions determine which updates have to be (can be) authorized by a signature.
If you only want to avoid creating proofs for quicker testing, we advise you to
use LocalBlockchain({ proofsEnabled: false }) instead of requireSignature(). Setting
proofsEnabled to false allows you to test your transactions with the same authorization flow as in production,
with the only difference being that quick mock proofs are filled in instead of real proofs.
Use this command if the account update created by this SmartContract should have no authorization on it, instead of being authorized with a proof.
WARNING: This is a method that should rarely be useful. If you want to disable proofs for quicker testing, take a look
at LocalBlockchain({ proofsEnabled: false }), which causes mock proofs to be created and doesn't require changing the
authorization flow.
Method to call on the first time liquidity is supplied to the token pool
amount of token 0 to add to the pool
amount of token 1 to add to the pool
liquity amount minted
Supply liquidity to the mina/token pool if it's not the first time The reserves max and supply min permit concurrent call, use slippage mechanism to calculate it
mina to add to the pool
token to add to the pool
reserve max of mina in the pool
reserve max of token in the pool
minimun liquidity in the pool
liquity amount minted
Supply liquidity to the token/token pool if it's not the first time The reserves max and supply min permit concurrent call, use slippage mechanism to calculate it
amount of token 0 to add to the pool
amount of token 1 to add to the pool
minimun liquidity in the pool
liquity amount minted
Don't call this method directly, use pool token holder or you will just lost mina
use in the previous method
mina amount in
actual reserve max in
Swap token to mina
address who collect the frontend fees
fees applied by the frontend
amount of token to swap
minimum mina to received
minimum balance of token in the pool
maximum balance of mina in the pool
Don't call this method directly, use withdrawLiquidity from PoolTokenHolder
StaticanalyzeThis function is run internally before compiling a smart contract, to collect metadata about what each of your smart contract methods does.
For external usage, this function can be handy because calling it involves running all methods in the same "mode" as compile() does,
so it serves as a quick-to-run check for whether your contract can be compiled without errors, which can greatly speed up iterating.
analyzeMethods() will also return the number of rows of each of your method circuits (i.e., the number of constraints in the underlying proof system),
which is a good indicator for circuit size and the time it will take to create proofs.
To inspect the created circuit in detail, you can look at the returned gates.
Note: If this function was already called before, it will short-circuit and just return the metadata collected the first time.
Optional__namedParameters: { Optionalprintan object, keyed by method name, each entry containing:
rows the size of the constraint system created by this methoddigest a digest of the method circuitactions the number of actions the method dispatchesgates the constraint system, represented as an array of gatesStaticcompileCompile your smart contract.
This generates both the prover functions, needed to create proofs for running @methods,
and the verification key, needed to deploy your zkApp.
Although provers and verification key are returned by this method, they are also cached internally and used when needed, so you don't actually have to use the return value of this function.
Under the hood, "compiling" means calling into the lower-level Pickles and Kimchi libraries to create multiple prover & verifier indices (one for each smart contract method as part of a "step circuit" and one for the "wrap circuit" which recursively wraps it so that proofs end up in the original finite field). These are fairly expensive operations, so expect compiling to take at least 20 seconds, up to several minutes if your circuit is large or your hardware is not optimal for these operations.
Optional__namedParameters: { Optionalcache?: CacheOptionalforceStaticdigestComputes a hash of your smart contract, which will reliably change whenever one of your method circuits changes. This digest is quick to compute. it is designed to help with deciding whether a contract should be re-compiled or a cached verification key can be used.
the digest, as a hex string
StaticgetCalculate amount out on swap, use by pool and pool token holder contracts
fees applied by the frontend
amount of tokenIn to swap
minimum balance of tokenIn in the pool
maximum balance of tokenOut in the pool
amount of token out
StaticgetStaticProofReturns a Proof type that belongs to this SmartContract.
Readonlyprovable: { Optionalvalue: Proof<any, any>OptionaltoStaticrunStaticset
Main Pool contract for Lumina dex