Skip to content

Latest commit

 

History

87 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pablo Vault

Artifacts Main Coverage [codecov](https://codecov.io/github/InstrumentalFi/instrumental-contracts/

This repository contains the source code for the Pablo Vault and Fee Distribution Contracts.

Behaviour

This section elaborates on the functionalities and interactions of CosmWasm contracts used for staking and fee distribution within the Cosmos network.

1. Distributor Contract

  • Functionality: Receives and allocates tokens based on predefined rules.
  • Features:
    • Supports various Cosmos denominations (denoms), accounts, and percentage-based distributions.
    • Enables the transfer of tokens to multiple contracts or addresses, ensuring versatile distribution.
    • Suitable for various applications including staking and the Osmosis adapter pool (note: no integration with the pool).

2. Fee Collector Contract

  • Functionality: Serves as a recipient for tokens from the Distributor contract, acting as a secure storage.
  • Characteristics:
    • Receives a specific portion of tokens from the Distributor contract.
    • Implements checks and permissions to ensure secure and authorized withdrawals of tokens.
    • Allows the Staking contract to withdraw tokens.

3. Staking Contract

  • Functionality: Manages the staking of tokens and facilitates the distribution of rewards.
  • Features:
    • "Tokens per interval" parameter sets a maximum limit for distribution within a specified timeframe.
    • Distributes the lesser of total tokens in the collector or "time x tokens per interval."
    • Issues stTokens to users in representation of their stake.
    • stTokens are value-accruing, allowing holders to collect a portion of fees proportional to their stToken holdings.
  • Distribution:
    • Occurs at predefined intervals with immediate accrual of user shares upon staking.
    • Adopts a pro-rata distribution model, ensuring fee distribution is proportional to each user’s stToken holdings.
    • Utilizes a precise user share tracking mechanism akin to other reward systems.

Special Considerations

  • Passive Stakers: Further investigation is necessary to ensure that passive stakers are adequately protected and fairly treated compared to those who stake at the last minute. The case of one chain accumulates and sends transfers peridocally is important.

Environment set up

  • Install rustup. Once installed, make sure you have the wasm32 target:

    rustup default stable
    rustup update stable
    rustup target add wasm32-unknown-unknown
  • Install Docker

  • Install cargo-make

    cargo install --force cargo-make
  • Compile all contracts:

cargo make rust-optimizer
  • Download CW20 contract:
wget -P ./artifacts/ https://github.com/CosmWasm/cw-plus/releases/download/v1.1.0/cw20_base.wasm

This compiles and optimizes all contracts, storing them in /artifacts directory along with checksum.txt which contains sha256 hashes of each of the .wasm files (The script just uses CosmWasm's rust-optimizer).

Note: Intel/Amd 64-bit processor is required. While there is experimental ARM support for CosmWasm/rust-optimizer, it's discouraged to use in production.

NOTE: on Apple devices an architecture suffix may be required.

Deployment

See deployment scripts.

Schemas

cargo make --makefile Makefile.toml generate-all-schemas

Creates JSON schema files for relevant contract calls, queries and query responses (See: cosmwams-schema).

Linting

rustfmt is used to format any Rust source code:

cargo +nightly fmt

clippy is used as a linting tool:

cargo make clippy

Testing

Integration tests (task integration-test or test) use .wasm files. They have to be generated with cargo make build.

Run unit tests:

cargo make unit-test

Run all tests:

cargo make test

Deployments

chain contract code id git commit store tx
osmosis liquidator 398 27aad556a2c6ac6dbb3a4c078fc523982c2b02dc 9734C67B5E046BA7AE57D566BFB8FCD7611C842A1D4063CA03D81D4636670C12
neutron collector 603 27aad556a2c6ac6dbb3a4c078fc523982c2b02dc D2CDBB27AC03976D239852E01ED43CEB5100574AA4192677E64AC1E4248515A8
neutron staking 604 27aad556a2c6ac6dbb3a4c078fc523982c2b02dc 6DA9CAC7377E8D9EBD567E2372A79D8AAD2354D31871586E6AC2927F4E238B95
neutron distributor 605 27aad556a2c6ac6dbb3a4c078fc523982c2b02dc FD8A8BA705181B0FFD351B27AEE8DA405D844F972EF67535C5BD7595205D3051

License

Contents of this repository are open source under GNU General Public License v3 or later.

About

Autocompounding Vault for Pablo DEX

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages