This repo maintains contracts and support libraries for implementation of Isotonic protocol. This was originally developed by Confio for use on Osmosis in early 2022. However, as Mars Protocol came to launch on Osmosis, this project was never released.
One year later, Confio and Osmosis have agreed to release this code under a permissive MIT license as an example both of a lending protocol, as well as how to design contracts to interact with Osmosis AMM pools. It shows how to query spot prices and auto-liquidate on Osmosis AMMs.
We couldn't use TWAP as it was not available a the time of development, but please never use spot price as an oracle. This is a huge cause of DeFi hacks. Use TWAP or other oracle solutions.
It is organized like cosmwasm-plus
. You can use that as a reference.
To compile all the contracts, run the following in the repo root:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.4
This will compile all packages in the contracts
directory and output the
stripped and optimized wasm code under the artifacts
directory as output,
along with a checksums.txt
file.
If you hit any issues there and want to debug, you can try to run the
following in each contract dir:
RUSTFLAGS="-C link-arg=-s" cargo build --release --target=wasm32-unknown-unknown --locked
You can start with cosmwasm-template as a basis:
cd contracts
cargo generate --git https://github.com/CosmWasm/cosmwasm-template.git --name CONTRACT_NAME
cd CONTRACT_NAME
# remove unneeded files
rm -rf .circleci .github .git
rm .cargo-ok .editorconfig .gitignore rustfmt.toml
rm Developing.md Importing.md Publishing.md LICENSE NOTICE
# regenerate schema for CI tests
cargo schema
git add .
Then add it to CI, by editing .circleci/config.yml
. Just copy the contract_tgrade_dso
section and
rename it, pointing to your new contract.
Finally, update Cargo.toml
to use the current version used by all other contracts in this repo.
All code is released under an MIT license. See LICENSE.