A decentralized vault system built on Neutron using CosmWasm smart contracts. The project integrates Neutron's feature set to create an Integrated Market Maker (IMM) with high-frequency oracle integration and concentrated liquidity management via constant sum AMMs.
The mmvault contract is a liquidity management vault deployed on the Neutron blockchain. Its primary purpose is to manage user deposits of two tokens (e.g., token0 and token1 ) and efficiently allocate liquidity into the Neutron DEX (Duality) by performing automated deposits and withdrawals, driven by off-chain price data and strategic configuration parameters. The vault contract abstracts away direct DEX interactions from end users. Instead, users interact with the vault through standardized deposit and withdrawal flows, while the vault itself takes full custody of user assets and autonomously manages liquidity provisioning via Cron-triggered rebalancing logic.
Users can deposit paired tokens into the vault using the ExecuteMsg::Deposit
entry
point. In return, they receive LP shares (minted using the token factory module)
representing their proportional claim on the vault’s total value. Shares are minted
based on:
- Vault’s total value (fetched using slinky price oracle),
- Existing LP supply (
config.totalshares
), and - Whether the deposit is the first-ever or a subsequent one.
Shares are minted using the
get_mint_amount()
logic, ensuring proportional issuance. LP share tracking is maintained throughconfig.total_shares
, which increases on every deposit
Users can redeem their LP shares via ExecuteMsg::Withdraw
, triggering a burn of the
specified amount of LP shares. If the vault holds no active DEX positions, the
withdrawal immediately transfers the user’s share of vault-held tokens using
get_withdrawal_messages()
. If active DEX deposits exist, the vault issues a submessage
to withdraw them (MsgWithdrawal
), and the actual token payout happens in the reply
handler, followed by a fresh MsgDeposit to redeploy remaining liquidity.
The withdrawal flow ensures that config.total_shares decreases by the exact burned
amount.
he vault relies on Neutron's Cron module to trigger periodic rebalancing of its DEX positions through two privileged entry points:
- dex_withdrawal() : Executed first each block by Cron, this function:
- Queries all active DEX positions owned by the vault,
- Issues MsgWithdrawal messages to remove liquidity from all active pools,
- Ensures the vault regains custody of all tokens before re-depositing.
- dex_deposit() :
Executed immediately after
dex_withdrawal()
, it:
- Verifies that all prior positions have been withdrawn,
- Fetches fresh oracle prices via the Slinky module,
- Computes the target tick index and rebalancing logic based on:
- Fee tier allocation,
- Imbalance between
token0
/token1
values, - Configured skew/imbalance settings,
- Issues
MsgDeposit
messages to redeploy liquidity across different price ranges and fee tiers.
All deposits and withdrawals are issued on behalf of the vault (creator
== receiver
==
contract address
), ensuring it retains full custody of all f
unds and LP shares.
├── contracts/
│ ├── mmvault/ # Core vault (IMM) implementation
│ ├── slinky-oracle/ # Primary oracle
│ ├── lst-oracle/ # LST rate oracle
│ └── dasset-oracle/ # Drop d-asset oracle
- Rust 1.69 or higher
- Cargo with Wasm target:
rustup target add wasm32-unknown-unknown
- Neutron CLI
- Make
- Docker (for building)
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add Wasm target
rustup target add wasm32-unknown-unknown
# Clone repository
git clone https://github.com/your-org/slinky-vault
cd slinky-vault
# Build all contracts
make optimize
# Run tests
make test
The project includes an interactive Python visualization tool to understand how the dynamic fee tier adjustment system works. This tool provides real-time visualization of tick index movements, spread adjustments, and fee tier changes based on imbalance ratios. An interactive version of these curves can be found on Desmos
- Python 3.8 or higher
- pip package manager
# Install Python dependencies
pip install -r requirements.txt
# Run the interactive visualization
python3 fee_tier_visualization.py
Interactive Dashboard (create_dynamic_tick_visualization()
):
- Real-time sliders to adjust imbalance ratio, spread factor, spread cap, and base spread
- Visual representation of tick index movement and spread bounds
- Live updates showing how fee tiers adjust based on market conditions
- Blue tick line: Shows current tick index position within the spread bounds
- Red bounds: Upper and lower spread boundaries that move based on imbalance
- Yellow/colored spread area: Active trading spread that adjusts dynamically
- Fee tier display: Shows how base fees are modified by the adjustment algorithm
The tool helps visualize how the vault responds to token imbalances by:
- Moving tick indices and windening spread in order make the undersupplied token more expensive
- Does this in aoccordance to the chosed curve parameters set bu the
spread factor
parameter
TBD -
For security concerns, please email nicholas.evans@hadronlabs.org