2 unstable releases
0.2.0 | Mar 26, 2024 |
---|---|
0.1.0 | Oct 23, 2023 |
#14 in #astroport
1,316 downloads per month
Used in 22 crates
(2 directly)
15KB
286 lines
Astroport Core
Multi pool type automated market-maker (AMM) protocol powered by smart contracts on the Terra blockchain.
Contracts diagram
General Contracts
Name | Description |
---|---|
factory |
Pool creation factory |
pair |
Pair with x*y=k curve |
pair_stable |
Pair with stableswap invariant curve |
pair_stable_bluna |
Pair with stableswap invariant curve handling bLUNA rewards for LPs |
token |
CW20 (ERC20 equivalent) token implementation |
router |
Multi-hop trade router |
oracle |
TWAP oracles for x*y=k pool types |
whitelist |
CW1 whitelist contract |
Tokenomics Contracts
Tokenomics related smart contracts are hosted on ../contracts/tokenomics.
Name | Description |
---|---|
generator |
Rewards generator for liquidity providers |
generator_proxy_to_mirror |
Rewards generator proxy for liquidity providers |
maker |
Fee collector and swapper |
staking |
xASTRO staking contract |
vesting |
ASTRO distributor for generator rewards |
xastro_token |
xASTRO token contract |
Building Contracts
You will need Rust 1.64.0+ with wasm32-unknown-unknown target installed.
You can compile each contract:
Go to contract directory and run
cargo wasm
cp ../../target/wasm32-unknown-unknown/release/astroport_token.wasm .
ls -l astroport_token.wasm
sha256sum astroport_token.wasm
You can run tests for all contracts
Run the following from the repository root
cargo test
For a production-ready (compressed) build:
Run the following from the repository root
./scripts/build_release.sh
The optimized contracts are generated in the artifacts/ directory.
Deployment
You can find versions and commits for actually deployed contracts here.
Docs
Docs can be generated using cargo doc --no-deps
Bug Bounty
The contracts in this repo are included in a bug bounty program.
lib.rs
:
Circular buffer which is built over Item
and [Map
].
Might be useful to store time series data in contracts.
Example
use cosmwasm_std::testing::MockStorage;
use astroport_circular_buffer::{BufferManager, CircularBuffer};
const CIRCULAR_BUFFER: CircularBuffer<u128> = CircularBuffer::new("buffer_state", "buffer");
let mut store = MockStorage::new();
BufferManager::init(&mut store, CIRCULAR_BUFFER, 10).unwrap();
let mut buffer = BufferManager::new(&store, CIRCULAR_BUFFER).unwrap();
let data = (1..=10u128).collect::<Vec<_>>();
buffer.push_many(&data);
buffer.commit(&mut store).unwrap();
let values = buffer.read(&store, 0u32..=9, true).unwrap();
let all_values = buffer.read_all(&store).unwrap();
Dependencies
~3.5–5.5MB
~117K SLoC