Skip to content

Commit 2aba09a

Browse files
thal0xNotJeremyLiuYonggiee
authored
Jw/smart swap exact in (#109)
* add SmartSwapExactAssetIn swap type * Revert "Add split route support in all adapters (#103)" This reverts commit 1fa4f21. * Revert "Support multiple routes in astroport adapter (#99)" This reverts commit a95f17d. * Revert "Support split routes in entry point contract (#101)" This reverts commit 94c3bbf. * Revert "Update contract types to support route splitting (#98)" This reverts commit ec1fd57. * Revert "add interface field to SwapOperation (#96)" This reverts commit eb37618. * remove deployed test contracts * fix fmt issue * update schema * since user_swap is mutatable, we can mutate in place * swap excess funds * update schema * lint change * fix test * add optional interface field to SwapOperation (#108) * return error for largest_route_index * [API-2792] Add hallswap adapter (#102) * feat: add hallswap adapter * chore: add readme * pr fixes * add optional interface field to SwapOperation * update hallswap adapter to implement updated interface * remove get_hallswap_routes_from_skip_routes --------- Co-authored-by: thal0x <[email protected]> --------- Co-authored-by: Jeremy Liu <[email protected]> Co-authored-by: Yonggiee <[email protected]>
1 parent bf540d0 commit 2aba09a

File tree

10 files changed

+536
-0
lines changed

10 files changed

+536
-0
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "skip-api-swap-adapter-hallswap"
3+
version = { workspace = true }
4+
rust-version = { workspace = true }
5+
authors = { workspace = true }
6+
edition = { workspace = true }
7+
license = { workspace = true }
8+
homepage = { workspace = true }
9+
repository = { workspace = true }
10+
documentation = { workspace = true }
11+
keywords = { workspace = true }
12+
13+
[lib]
14+
crate-type = ["cdylib", "rlib"]
15+
16+
[features]
17+
# for more explicit tests, cargo test --features=backtraces
18+
backtraces = ["cosmwasm-std/backtraces"]
19+
# use library feature to disable all instantiate/execute/query exports
20+
library = []
21+
22+
[dependencies]
23+
astroport = { workspace = true }
24+
cosmwasm-schema = { workspace = true }
25+
cosmwasm-std = { workspace = true }
26+
cw2 = { workspace = true }
27+
cw20 = { workspace = true }
28+
cw-storage-plus = { workspace = true }
29+
cw-utils = { workspace = true }
30+
skip = { workspace = true }
31+
thiserror = { workspace = true }
32+
33+
[dev-dependencies]
34+
test-case = { workspace = true }
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Hallswap Adapter Contract
2+
3+
The Hallswap adapter contract is responsible for:
4+
5+
1. Taking the standardized entry point swap operations message format and converting it to Hallswap entry point swap execute message.
6+
2. Swapping by dispatching the multi-hop swap operations to the Hallswap contract.
7+
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).
8+
9+
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.
10+
11+
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.
12+
13+
## InstantiateMsg
14+
15+
Instantiates a new Dexter swap adapter contract using the Entrypoint contract address provided in the instantiation message.
16+
17+
``` json
18+
{
19+
"entry_point_contract_address": "terra1....",
20+
"hallswap_contract_address": "terra1...."
21+
}
22+
```
23+
24+
## ExecuteMsg
25+
26+
### `swap`
27+
28+
Swaps the coin sent using the operations provided.
29+
30+
``` json
31+
{
32+
"swap": {
33+
"offer_asset": {
34+
"native": {
35+
"denom": "uluna",
36+
"amount": "10000"
37+
}
38+
},
39+
"operations": [
40+
{
41+
"pool": "terra...",
42+
"denom_in": "uluna",
43+
"denom_out": "ibc/..."
44+
},
45+
{
46+
"pool": "terra...",
47+
"denom_in": "ibc/...",
48+
"denom_out": "factory/..."
49+
}
50+
]
51+
}
52+
}
53+
```
54+
55+
## QueryMsg
56+
57+
### `simulate_swap_exact_coin_in`
58+
59+
Returns the coin out that would be received from swapping the `coin_in` specified in the call (swapped through the `swap_operatons` provided)
60+
61+
Query:
62+
63+
``` json
64+
{
65+
"simulate_swap_exact_coin_in": {
66+
"asset_in": {
67+
"native": {
68+
"denom": "uluna",
69+
"amount": "2000000"
70+
}
71+
},
72+
"swap_operations": [
73+
{
74+
"pool": "terra...",
75+
"denom_in": "uluna",
76+
"denom_out": "ibc/..."
77+
},
78+
{
79+
"pool": "terra...",
80+
"denom_in": "ibc/...",
81+
"denom_out": "factory/..."
82+
}
83+
]
84+
}
85+
}
86+
```
87+
88+
Response:
89+
90+
``` json
91+
{
92+
"native": {
93+
"denom": "factory/...",
94+
"amount": "1900000"
95+
}
96+
}
97+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use cosmwasm_schema::write_api;
2+
use skip::swap::{ExecuteMsg, InstantiateMsg, QueryMsg};
3+
4+
fn main() {
5+
write_api! {
6+
instantiate: InstantiateMsg,
7+
execute: ExecuteMsg,
8+
query: QueryMsg
9+
}
10+
}

0 commit comments

Comments
 (0)