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

LSM LP functionality #89

Merged
merged 13 commits into from
Feb 22, 2024
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"contracts/multi_staking",
"contracts/router",
"contracts/governance_admin",
"contracts/superfluid_lp",
"packages/*"
]

Expand Down
34 changes: 18 additions & 16 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
ec744098d4b8e64b006efa5ea4d38005b66fe6a04868c5731411a5218510d122 dexter_governance_admin-aarch64.wasm
4ae1b5525f1c0a157b9bb681b7cdd96585963c3b7d50b8beb5e40dbb635f4a06 dexter_governance_admin.wasm
f1637c62e407f3a8e632d1646ba059a07574742c66484d22baf2aa9ce53747cd dexter_keeper-aarch64.wasm
eed9ca38fae4f1898b5b9cef3bd6d93353823c139fc81dd502ce3d9bc829a628 dexter_keeper.wasm
c7aca4e73e5f5418d6c9a78e32ff97b3d7a21afe7055a05ff5bc74410e3e367a dexter_multi_staking-aarch64.wasm
010616b1325998fa5ce47437b9c909cb47a6c011282665687aa7e6d7dbc30fdf dexter_multi_staking.wasm
8a55ee7c47ad6e97cef64b2b8ddc7b208c3bfcad870b52c356536739223d4dfe dexter_router-aarch64.wasm
2770cf94f9eb6c25f0f41a122dd83515702ba96e11596dc695d0a58acbbbe5f2 dexter_router.wasm
ccc87e6af394f8d6ed23f3d8501f26bb2e475e2d47e29f516ab46f0b37098b63 dexter_vault-aarch64.wasm
7ce2c09ec05be2e08fdbdbc672f419cf51d8cdab892f35850401b1783fb131f6 dexter_vault.wasm
d1ffada7fa5d2111debc4a0bba615322dc398c17624d7dea68e482aa5bf8d51a lp_token-aarch64.wasm
54ff6959266af5653f95f703e36f1b5d8d72d35b93c535f38cc94b5511634f0c lp_token.wasm
6b83675d1a9b0b34eabea0b4058998a923b836a31310aafccf5c87537b0133ab stable_pool-aarch64.wasm
f457177d505873465476f417e272991876bbb181b812097de8f513ef5938ffaa stable_pool.wasm
6a6a257e606478a66c6dd2db8f37322620ab01e18cbecedcce883985454be770 weighted_pool-aarch64.wasm
0c3ef881f46191127131fe042ca1579f34c20c8af2b93908dd9e14ac46e1249e weighted_pool.wasm
4dab2fc6bd56a50b3765baf335c14ec05b49f4815099e17519f4a7114010d023 dexter_governance_admin-aarch64.wasm
61fd5eb6d634ef8b531298698e4e45424cfd26d92a1228511642608287cddbf4 dexter_governance_admin.wasm
2c6ac09506b69a0ac06ce22079c9477dac495d3f2ff5e4d2c62068887ca0e64e dexter_keeper-aarch64.wasm
2a2c9c0488feba7ac4e9fab0a3bb9b2f1d95a80b2414671593a6dd42b982b4f0 dexter_keeper.wasm
d96e7c699d163ef8f15079ad340015350ac64c84dfef15320815aef6269c67c1 dexter_multi_staking-aarch64.wasm
7cd99e6f45131c63e35949ebd076e5f053d8da065f07fc24550cc3b51b839408 dexter_multi_staking.wasm
68de586576ab108c927259201288f75b00f90276cbc80ba909993981dd425a19 dexter_router-aarch64.wasm
4102b52a873a4fffa114b0c772117c842addc85762362366479099c64d2b69bf dexter_router.wasm
f3046bc7873053f1a64033fe41160a3ac2be874b6ac2f2f1b67b91046bace936 dexter_superfluid_lp-aarch64.wasm
88697e167e6da1af0389c77bd3c740cbb8ffab0e6c79ac8a5b5c86e5b4136d19 dexter_superfluid_lp.wasm
5089880ebaaa47e7d8641368920eeb5298480a1ea025bfc019f501ee5c7e3594 dexter_vault-aarch64.wasm
f86dce8871e7466e2c24922cd753812830277dd8372e3002a94cecd476d5bb9a dexter_vault.wasm
45a289fd2342621e0dbe9d2c6193536be7e7a17843cacb56e392a94ce5a62dcb lp_token-aarch64.wasm
b944e64e40cbea733c247e8bfeed7329ea2159bd295dde402a485d61e81ba1aa lp_token.wasm
dbcb817d905d9ccc1183c62715f32e9592981cbf5329fe529353b8d12a2f8316 stable_pool-aarch64.wasm
0d2a3990e5b0fdd6276fe330adb2ed38c1235150b2acebc2be2f734ccf1dfc89 stable_pool.wasm
08436930bb4abe2cb78f5f7ae8583410b10fc3eef57e6bc9e6e021f61ef739d8 weighted_pool-aarch64.wasm
755d6a4c78ea6f1579260b7b61b52545d11f2b90c149838eee078924453a274a weighted_pool.wasm
17 changes: 9 additions & 8 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
b712ae72f337b514b412980b318d6354e0dd3ab8e33cc87e0da94d78f0e875d7 target/wasm32-unknown-unknown/release/dexter_governance_admin.wasm
73c81bb6a9e418e0c5eaca3f38efcf9687ed39d20e39f3aad7648b52fd66277b target/wasm32-unknown-unknown/release/dexter_keeper.wasm
d5fedf51f7b10a4d2705331e053efe8999148421b1f2ba8bee577082cf4ff9a9 target/wasm32-unknown-unknown/release/dexter_multi_staking.wasm
29b9ab70ff4438b6fc2394c87f3965106ba313590e5c9b6bc85d937a9cefa41d target/wasm32-unknown-unknown/release/dexter_router.wasm
52026056c605a76edf8e20197badae509076117c6684db72c94d3af3ef614cc7 target/wasm32-unknown-unknown/release/dexter_vault.wasm
9bd1325f5a7460e8857d86525cd24c6354684f500c580112782a96d23e914cd4 target/wasm32-unknown-unknown/release/lp_token.wasm
688fc035141cf14036baf03fc665ff1eb7f789f04152e7b46555c525d3401af1 target/wasm32-unknown-unknown/release/stable_pool.wasm
705ff501c260f21bc07d4ea39d702afb980cbb81c679e490a1bc8f311fb35849 target/wasm32-unknown-unknown/release/weighted_pool.wasm
6864211daf765d04b611daed7e4aa91fa1594f8c65eb1a1669e065ce4f9504f2 target/wasm32-unknown-unknown/release/dexter_governance_admin.wasm
337c3945a6fd4f80383370664b7a10fae5bcc2ffa665de30e51cf1fe81e9a4fd target/wasm32-unknown-unknown/release/dexter_keeper.wasm
ac31cf4d60749229327a513a630efe212096a1de1d5af4da0c78beb46dca2087 target/wasm32-unknown-unknown/release/dexter_multi_staking.wasm
fb899ce3aa92829910f318462dfe735303023e76cd76a24189a6bb45f06472ca target/wasm32-unknown-unknown/release/dexter_router.wasm
7304a5cacdf40b2fca1f5d69bd1504167905bd94083df06a31014fc10d52ed28 target/wasm32-unknown-unknown/release/dexter_superfluid_lp.wasm
6b5dc74e43757d44d35bab7ae7f3a4807a836540a4f675b2dd35f8715ab63864 target/wasm32-unknown-unknown/release/dexter_vault.wasm
5e37e85f31a5c762543e16159c3bba55413b1436937690465166fb4ce96558a4 target/wasm32-unknown-unknown/release/lp_token.wasm
4725f4f4d7b910a529182fc47b0b2cfd47ef1343e4652ce6d5449941d7a021e3 target/wasm32-unknown-unknown/release/stable_pool.wasm
ed142f681bfe3b3bba578ccfc3af05009cb3d03147fb3fa9561edabc78dcf270 target/wasm32-unknown-unknown/release/weighted_pool.wasm
Binary file modified artifacts/dexter_governance_admin-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/dexter_governance_admin.wasm
Binary file not shown.
Binary file modified artifacts/dexter_keeper-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/dexter_keeper.wasm
Binary file not shown.
Binary file modified artifacts/dexter_multi_staking-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/dexter_multi_staking.wasm
Binary file not shown.
Binary file modified artifacts/dexter_router-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/dexter_router.wasm
Binary file not shown.
Binary file added artifacts/dexter_superfluid_lp-aarch64.wasm
Binary file not shown.
Binary file added artifacts/dexter_superfluid_lp.wasm
Binary file not shown.
Binary file modified artifacts/dexter_vault-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/dexter_vault.wasm
Binary file not shown.
Binary file modified artifacts/lp_token-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/lp_token.wasm
Binary file not shown.
Binary file modified artifacts/stable_pool-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/stable_pool.wasm
Binary file not shown.
Binary file modified artifacts/weighted_pool-aarch64.wasm
Binary file not shown.
Binary file modified artifacts/weighted_pool.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dexter-governance-admin",
"contract_version": "1.0.0",
"contract_version": "1.1.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
6 changes: 6 additions & 0 deletions contracts/superfluid_lp/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test dexter_superfluid_lp"
schema = "run --example dexter_superfluid_lp"
39 changes: 39 additions & 0 deletions contracts/superfluid_lp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "dexter-superfluid-lp"
version = "1.0.0"
authors = ["PersistenceLabs"]
edition = "2021"
description = "Superfluid LP contract to facilitate staked token -> LST -> LP 1-click conversion"
license = "MIT"

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

[features]
backtraces = ["cosmwasm-std/backtraces"]


[dependencies]
dexter = { path = "../../packages/dexter", default-features = false }
cw20 = "1.0.1"
cw2 = "1.0.1"
cw20-base = { version = "1.0.1", features = ["library"] }
cosmwasm-std = "1.5.0"
cw-storage-plus = "1.0.1"
schemars = "0.8.11"
thiserror = "1.0.38"
serde = { version = "1.0.152", default-features = false, features = ["derive"] }
serde-json-wasm = "0.5.0"
cosmwasm-schema = "1.5.0"
const_format = "0.2.30"
cw-utils = "1.0.3"

[dev-dependencies]
# we only need to enable this if we use integration tests
cw-multi-test = "0.16.2"
dexter-vault = { path = "../vault"}
dexter-multi-staking = { path = "../multi_staking"}
stable-pool = { path = "../pools/stable_pool" }
weighted-pool = { path = "../pools/weighted_pool"}
lp-token = { path = "../lp_token"}
cw20 = "1.0.1"
104 changes: 104 additions & 0 deletions contracts/superfluid_lp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Dexter Superfluid LP contract

Dexter superfluid LP contract enables 1-click LP position from staked chain tokens directly to a bonded LP position.

This is part of the stkXPRT rollout. For more details, see [here]()

## Roles

**Owner**: Manages the contract admin parameters. Currently the only admin parameter is the vault contract address.

**User**: Person who locks LST tokens in the contract and then uses them to create a bonded LP position.


## Supported state transition functions

### Owner executable

Following transition functions can only be executed by the `owner` of the contract.

#### 1. _**Update config**_

Updates the contract admin parameters.

```json
{
"update_config": {
"vault_address": "persistence1..."
}
}
```

#### 2. _**Add allowed lockable token**_

Adds a new token denom to the list of allowed lockable tokens. This is used to whitelist tokens that can be locked in the contract.

```json
{
"add_allowed_lockable_token": {
"native_token": {
"denom": "stk/uxprt"
}
}
}
```

### User executable

#### 1. _**Lock LST**_

Locks LST tokens in the contract which can then be used to create a bonded LP position. This is ideally part of a superfluid LP transaction.

Only a set of whitelisted token denoms an be locked in the contract. These can be added by the contract owner.

This calls from the liquidstake module once the LST has been minted for the user, to lock it in the same message.

Post this, another messages can be sent, ideally in the same transaction to use the locked LST to create a bonded LP position using the correspondng transition function.

```json
{
"lock_lst": {
"asset": {
"amount": "1000000000000000000000000",
"info": {
"native_token": {
"denom": "stk/uxprt"
}
}
}
}
}
```

#### 2. _**Join pool and bond using Locked LST**_

Allows a user who locked his LST to use any combination of the locked LST and extra tokens that he sent to add liquidity to a pool and also bond it. Ideally, this message is part of a single transaction that converts a staked asset to LST and then lock it using the `lock_lst` transition function.


```json
{
"join_pool_and_bond_using_locked_lst": {
"pool_id": "1",
"total_assets": [
{
"amount": "900000000",
"info": {
"native_token": {
"denom": "stk/uxprt"
}
}
},
{
"amount": "1000000000",
"info": {
"token": {
"contract_addr": "persistence1..."
}
}
}
],
"min_lp_to_receive": "100000000"
}
}
```

11 changes: 11 additions & 0 deletions contracts/superfluid_lp/examples/dexter_superfluid_lp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;
use dexter::router::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

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