@rever22411/amm-commands
v0.3.10
Published
Solana AMM Commands
Downloads
1,599
Readme
Amm (Work In Progress)
Concentrated liquidity market maker (CLMM) program built for the Solana ecosystem.
Concentrated Liquidity Market Maker (CLMM) pools allow liquidity providers to select a specific price range at which liquidity is active for trades within a pool. This is in contrast to constant product Automated Market Maker (AMM) pools, where all liquidity is spread out on a price curve from 0 to ∞. For LPs, CLMM design enables capital to be deployed with higher efficiency and earn increased yield from trading fees. For traders, CLMMs improve liquidity depth around the current price which translates to better prices and lower price impact on swaps. CLMM pools can be configured for pairs with different volatility.
Deploy
- cambiare wallet
src/private/admin_wallet.json
e ovunque sia hardcodata la publicKey - creare un nuovo wallet dedicato alle createPoolFee
- cambiare wallet
src/private/create_pool_fee.json
e ovunque sia hardcodata la publicKey - cancellare cartella
target
- nel file
Anchor.toml
decommentare il cluster di dev anchor build
compila i programmianchor keys list
per recuperare le publicKey dei programmi prima di deployare (dalla cartella target)- aggiornare tutte le publicKey vecchie con quelle nuove (sopprattutto Smart Contract declare_id!)
- aggiornare il file
src/config.ts
la createProtocolFee anchor deploy
deploya i contratti- nel file
Anchor.toml
decommentare il cluster local - copiare le cartelle
target/idl
etarget/types
rispettivamente insrc/program_idl
eprogram_types
- pubblicare la nuova versione del pacchetto
- aggiornare il be
- lanciare lo script con
anchor test
avendo prima decommentato solamente l'importdeploy
nel filesrc/tests/index.ts
- lo script crea bla bla bla
- sostituire l'address nella const USDCToken nel file
src/config.ts
Environment Setup
- Install Rust.
- Install Solana and then run
solana-keygen new
to create a keypair at the default location. - install Anchor.
Quickstart
Clone the repository and enter the source code directory.
Build
anchor build
After building, the smart contract files are all located in the target directory.
Deploy
anchor deploy
Attention, check your configuration and confirm the environment you want to deploy.
Smart Contracts
Le dimensioni degli account devono essere multiple di 8 Byte se la struct ha dati interni non multipli di 8 Byte (per esempio con un u8 che occupa 1 Byte) la dimensione viene arrotondata per eccesso al primo multiplo
info:
- la dimensione è scritta nel tooltip nell'IDE VsCode quando metti il cursore sopra il nome della struct
- per ricavare la dimensione si può usare:
mem::size_of::<StructName>()
- bisogna poi aggiungere 8 Byte di header per l'account
Develop
anchor build
create contracts target build- copy to
/tests/src/src/program_types/
the/target/types/*
files - copy to
/tests/src/src/program_idl/
the/target/idl/*
files
Description
- FALSO in PROD e sembra vero in LOCAL: una pool appena creata ha bisogna di una deposit (oltre a quello in creazione) per poter fare swap
- quando chiudo un account Wsol il contentuto viene swappato in sol e inviato all'account indicato
Publish
- update package.json version
npm i
check all package install itself correctly and update locknpm publish --access public
publish package over npmjs.com
Prepare devnet
- set .env.local variable:
VITE_CHAIN=https://api.devnet.solana.com
anchor run pre_deploy
launch test to prepare accounts (wip)
Testing
You can launch it with command clear && anchor test
that launch file specified in package.json