Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API-2792] Add hallswap adapter #102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions contracts/adapters/swap/hallswap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "skip-api-swap-adapter-hallswap"
version = { workspace = true }
rust-version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
documentation = { workspace = true }
keywords = { workspace = true }

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
astroport = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
cw20 = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
skip = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
test-case = { workspace = true }
97 changes: 97 additions & 0 deletions contracts/adapters/swap/hallswap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Hallswap Adapter Contract

The Hallswap adapter contract is responsible for:

1. Taking the standardized entry point swap operations message format and converting it to Hallswap entry point swap execute message.
2. Swapping by dispatching the multi-hop swap operations to the Hallswap contract.
3. Providing query methods that can be called by the entry point contract (generally, to any external actor) to simulate multi-hop swaps that either specify an exact amount in (estimating how much would be received from the swap).

Note: Swap adapter contracts expect to be called by an entry point contract that provides basic validation and minimum amount out safety guarantees for the caller. There are no slippage guarantees provided by swap adapter contracts.

WARNING: Do not send funds directly to the contract without calling one of its functions. Funds sent directly to the contract do not trigger any contract logic that performs validation / safety checks (as the Cosmos SDK handles direct fund transfers in the `Bank` module and not the `Wasm` module). There are no explicit recovery mechanisms for accidentally sent funds.

## InstantiateMsg

Instantiates a new Dexter swap adapter contract using the Entrypoint contract address provided in the instantiation message.

``` json
{
"entry_point_contract_address": "terra1....",
"hallswap_contract_address": "terra1...."
}
```

## ExecuteMsg

### `swap`

Swaps the coin sent using the operations provided.

``` json
{
"swap": {
"offer_asset": {
"native": {
"denom": "uluna",
"amount": "10000"
}
},
"operations": [
{
"pool": "terra...",
"denom_in": "uluna",
"denom_out": "ibc/..."
},
{
"pool": "terra...",
"denom_in": "ibc/...",
"denom_out": "factory/..."
}
]
}
}
```

## QueryMsg

### `simulate_swap_exact_coin_in`

Returns the coin out that would be received from swapping the `coin_in` specified in the call (swapped through the `swap_operatons` provided)

Query:

``` json
{
"simulate_swap_exact_coin_in": {
"asset_in": {
"native": {
"denom": "uluna",
"amount": "2000000"
}
},
"swap_operations": [
{
"pool": "terra...",
"denom_in": "uluna",
"denom_out": "ibc/..."
},
{
"pool": "terra...",
"denom_in": "ibc/...",
"denom_out": "factory/..."
}
]
}
}
```

Response:

``` json
{
"native": {
"denom": "factory/...",
"amount": "1900000"
}
}
```
10 changes: 10 additions & 0 deletions contracts/adapters/swap/hallswap/src/bin/hallswap-schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use cosmwasm_schema::write_api;
use skip::swap::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
execute: ExecuteMsg,
query: QueryMsg
}
}
Loading
Loading