The contracts in this repository are used in Skip Go API to enable any-to-any swaps as part of multi-chain workflows.
Skip Go is a unified REST API, Widget, and Core Package that helps developers create more seamless cross-chain experiences for their end users with IBC (Inter-Blockchain Communication protocol).
Skip Go API is designed so that even developers who are new to IBC can offer incredible cross-chain experiences, like swaps and transfers between any two IBC-enabled chains and tokens in as few transactions as possible, with reliable multi-chain relaying, packet tracking, and more.
The on-chain components of the swapping functionality consist of:
The entry point contract is responsible for providing a standardized interface (w/ safety checks) to interact with Skip Swap across all CosmWasm-enabled chains. The contract:
Swap Adapter contracts are developed and deployed for each swap venue supported by Skip Swap. The contracts are responsible for:
IBC Transfer adapter contracts are developed and deployed for each chain supported by Skip Swap. The contracts are responsible for:
A simplified example flow showcasing the interactions between the contracts is as follows:
swap_and_action
on the entry point contract.swap
on the relevant swap adapter contract, sending the coin to swap to the swap adapter contract.transfer_funds_back
on itself, which transfers the post-swap contract balance back to the entry point contract.ibc_transfer
on the IBC transfer adapter contract.
The repository is organized in the following way:
│
├── contracts/ <- Contains all contracts
│ ├── entry-point/ <- Contains source code and tests for entry point contract
│ └── adapters/ <- Contains source code and tests for all network adapter contracts
│ ├── ibc/
│ │ ├── ibc-hooks/
│ │ └── neutron-transfer/
│ └── swap/
│ ├── astroport/
│ └── osmosis-poolmanager/
│
├── deployed-contracts/ <- Contains deployed contracts info for each network
│ ├── neutron/
│ └── osmosis/
│
├── packages/ <- Contains all package code used by the contracts
│ └── skip/
│
├── scripts/ <- Contains all configs and deployment scripts
│ ├── configs/
│ ├── deploy.py
│ └── requirements.txt
│
├── README.md
├── Cargo.lock
├── Cargo.toml
├── Makefile
└── README.md
All tests can be found in the tests folder in each respective contract package.
Run all tests in the repo:
make test
Note: Due to the nature of the adapter contracts using stargate messages and interacting with chain-specific modules, integration testing is conducted on the respective testnets. See Deployment section for deployment instructions.
The repository's CI is triggered on pull requests and will fail if any error or warnings appear running the check
, clippy
, and fmt
commands found in the Makefile.
Each command and how to run them are as follows:
cargo check --target wasm32-unknown-unknown
is used to compile the contracts and verify they are valid wasm:
make check
clippy
is used for linting:
make clippy
rustfmt
is used for formatting:
make fmt
To deploy the Skip Swap contracts, the steps are as follows:
Build the optimized wasm bytecode of the contracts by running (they will appear in an artifacts folder):
make optimize
Ensure you have python 3.10 installed to run the deploy script. Download python 3.10 if you don't have it installed.
python3.10 --version
Go into the scripts directory and create a virtual environment to download the python dependencies:
cd scripts
python3.10 -m venv venv
Activate virtual environment, (venv) will show on left-hand side of shell
source venv/bin/activate
Install all the dependencies:
pip install -r requirements.txt
Add the mnemonic of the deployer address in the respsective chain's config toml file (located in configs folder):
# Enter your mnemonic here
MNEMONIC = "<YOUR MNEMONIC HERE>"
Generate the entry point contract address using instatiate2
which generates determinsitic cosmwasm contract addresses. This is necessary to allow the adapter contracts to whitelist the entry point contract before it is instantiated. To do this, you will need the daemon of the respective chain you are deploying on, and running the following command for the chain's CLI (replace osmosisd with network client being used):
osmosisd query wasm build-address <CHECK SUM HASH OF CONTRACT> <ADDRESS THAT WILL INSTANTIATE> <SALT AS HEX STRING (31 is b'1')>
Add the generated entry point address in the respective chain's config toml file
# @DEV MUST CHANGE SALT ACCORDINGLY TO OBTAIN THIS PRE GENERATED ADDRESS
ENTRY_POINT_PRE_GENERATED_ADDRESS = "<PRE GENERATED ADDRESS HERE>"
Update the salt used in the config if needed (default is "1", which is 31 in the chain daemon generator)
# SALT USED TO GENERATE A DETERMINSTIC ADDRESS
SALT = "1"
Run the deploy script with the following format (changing the chain [options: osmosis, neutron] and network [options: testnet, mainnet] depending on what is to be deployed):
python deploy.py <CHAIN> <NETWORK>
Example:
python deploy.py osmosis testnet
Note: If deploying injective, must run this command instead:
python deploy_injective.py injective mainnet
After running the deploy script, a toml file will be added/updated in the deployed-contracts/{CHAIN} folder with all relevant info for the deployment.
Skip helps developers provide extraordinary user experiences across all stages of the transaction lifecycle, from transaction construction, through cross-chain relaying + tracking, to block construction.