-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e23f8d8
commit c666c8a
Showing
9 changed files
with
1,604 additions
and
113 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[package] | ||
name = "skip-go-swap-adapter-shade-protocol" | ||
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 } | ||
|
||
cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.1.11"} | ||
cosmwasm-schema = "1.4.0" | ||
secret-toolkit = { git = "https://github.com/scrtlabs/secret-toolkit", tag = "v0.10.0" } | ||
secret-storage-plus = { git = "https://github.com/securesecrets/secret-plus-utils", tag = "v0.1.1", features = [] } | ||
serde = "1.0.114" | ||
schemars = "0.8.1" | ||
|
||
[dev-dependencies] | ||
test-case = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Neutron Astroport Swap Adapter Contract | ||
|
||
The Neutron Astroport swap adapter contract is responsible for: | ||
1. Taking the standardized entry point swap operations message format and converting it to Astroport pool swaps message format. | ||
2. Swapping by dispatching swaps to Astroport pool contracts. | ||
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) or an exact amount out (estimating how much is required to get the specified amount out). | ||
|
||
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 Neutron Astroport swap adapter contract using the Entrypoint contract address provided in the instantiation message. | ||
|
||
``` json | ||
{ | ||
"entry_point_contract_address": "neutron..." | ||
} | ||
``` | ||
|
||
## ExecuteMsg | ||
|
||
### `swap` | ||
|
||
Swaps the coin sent using the operations provided. | ||
|
||
``` json | ||
{ | ||
"swap": { | ||
"operations": [ | ||
{ | ||
"pool": "neutron...", | ||
"denom_in": "uatom", | ||
"denom_out": "untrn" | ||
}, | ||
{ | ||
"pool": "neutron...", | ||
"denom_in": "untrn", | ||
"denom_out": "uosmo" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
### `transfer_funds_back` | ||
|
||
Transfers all contract funds to the address provided, called by the swap adapter contract to send back the entry point contract the assets received from swapping. | ||
|
||
Note: This function can be called by anyone as the contract is assumed to have no balance before/after it's called by the entry point contract. Do not send funds directly to this contract without calling a function. | ||
|
||
``` json | ||
{ | ||
"transfer_funds_back": { | ||
"caller": "neutron..." | ||
} | ||
} | ||
``` | ||
|
||
## QueryMsg | ||
|
||
### `simulate_swap_exact_coin_out` | ||
|
||
Returns the coin in required to receive the `coin_out` specified in the call (swapped through the `swap_operatons` provided) | ||
|
||
Query: | ||
``` json | ||
{ | ||
"simulate_swap_exact_coin_out": { | ||
"coin_out": { | ||
"denom": "untrn", | ||
"amount": "200000" | ||
}, | ||
"swap_operations": [ | ||
{ | ||
"pool": "neutron...", | ||
"denom_in": "uatom", | ||
"denom_out": "untrn" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
Response: | ||
``` json | ||
{ | ||
"denom": "uatom", | ||
"amount": "100" | ||
} | ||
``` | ||
|
||
### `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": { | ||
"coin_in": { | ||
"denom": "uatom", | ||
"amount": "100" | ||
}, | ||
"swap_operations": [ | ||
{ | ||
"pool": "neutron...", | ||
"denom_in": "uatom", | ||
"denom_out": "untrn" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
Response: | ||
``` json | ||
{ | ||
"denom": "untrn", | ||
"amount": "100000" | ||
} | ||
``` |
10 changes: 10 additions & 0 deletions
10
contracts/adapters/swap/shade-protocol/src/bin/shade-protocol-schema.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.