Skip to content

Set of lockbox contracts on Solana for Olas protocol.

License

Notifications You must be signed in to change notification settings

valory-xyz/lockbox-solana

Repository files navigation

Lockbox Solana

Set of liquidity lockbox contracts on Solana for Olas protocol.

Introduction

This folder contains the liquidity lockbox set of contracts on Solana.

The lockbox program is designed to allow “bonders” to receive in exchange for OLAS and SOL tokens fungible token equivalents to the liquidity created by depositing a such amount of OLAS and SOL tokens with full range in the (OLAS-SOL) Orca whirlpool.

The description of the concept can be found here: Liquidity lockbox concept.

Pre-requisites

A successful program CPI with Orca Whirlpool program requires that the following environment is satisfied:

anchor --version
anchor-cli 0.26.0
solana --version
solana-cli 1.14.29 (src:36af529e; feat:139196142)
rustc --version
rustc 1.62.0 (a8314ef7d 2022-06-27)

Advise the script setup-env.sh to correctly install the required environment.

Development

Install the dependencies:

yarn

If you need to remove / check dependencies, run:

cargo clean
cargo tree

You might also want to completely remove the Cargo.lock file.

Build the code with:

anchor build

Run the validator in a separate window:

./validator.sh

Export environment variables:

export ANCHOR_PROVIDER_URL=http://127.0.0.1:8899
export ANCHOR_WALLET=artifacts/id.json

To run the initial script that would just initialize the lockbox program along with having Orca Whirlpool program and required user accounts setup, run:

solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && npx ts-node tests/lockbox_init.ts

To run integration test, make sure to stop and start the validator.sh in a separate window. Then run:

solana airdrop 10000 9fit3w7t6FHATDaZWotpWqN7NpqgL3Lm1hqUop4hAy8h --url localhost && npx ts-node tests/liquidity_lockbox.ts

The deployed program ID must be 7ahQGWysExobjeZ91RTsNqTCN3kWyHGZ43ud2vB7VVoZ and corresponds to the declare_id in the programs/liquidity_lockbox/src/lib.rs and Anchor.toml file.

For debugging a program address, after the launch of local validator, run:

solana logs -v --url localhost 7ahQGWysExobjeZ91RTsNqTCN3kWyHGZ43ud2vB7VVoZ

In order to just calculate and verify the added liquidity, export your credentials and execute the corresponding script:

export ANCHOR_PROVIDER_URL=https://api.mainnet-beta.solana.com
export ANCHOR_WALLET=your_wallet.json
npx ts-node tests/calculate_liquidity.ts

Documents

All the project-related documents are located here: docs.

Tests

Stub test with only initializing the lockbox program along with having Orca Whirlpool program and required user accounts setup is located here: lockbox_init.ts

Integration test is located here: liquidity_lockbox.ts.

Audits

  • The audit is provided as development matures. The latest audit report can be found here: audits.

Deployment

The deployment procedure is described here: deployment.

Addresses

Verification

IDL publishing:

anchor idl init -f scripts/liquidity_lockbox.json --provider.cluster https://api.mainnet-beta.solana.com 1BoXeb8hobfLCHNsyCoG1jpEv41ez4w4eDrJ48N1jY3

Solana Verify CLI.

Acknowledgements

The liquidity lockbox contracts were inspired and based on the following sources:

About

Set of lockbox contracts on Solana for Olas protocol.

Resources

License

Stars

Watchers

Forks

Packages

No packages published