Skip to content

Commit

Permalink
implement usdc converter contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sotnikov-s committed May 27, 2024
1 parent 127d9f8 commit 818d68e
Show file tree
Hide file tree
Showing 10 changed files with 624 additions and 6 deletions.
47 changes: 41 additions & 6 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"contracts/cw20-merkle-airdrop",
"contracts/price-feed",
"contracts/astroport/*",
"contracts/usdc-converter",
]

[profile.release]
Expand Down
15 changes: 15 additions & 0 deletions contracts/usdc-converter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build results
/target

# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327)
.cargo-ok

# Text file backups
**/*.rs.bk

# macOS
.DS_Store

# IDEs
*.iml
.idea
34 changes: 34 additions & 0 deletions contracts/usdc-converter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
authors = ["Sergei Sotnikov <ssotnikov93@gmail.com>"]
description = "A contract for NTRN<>USDC.axl LP tokens conversion to NTRN and Noble USDC native assets, providing them to the pair and staking them to Astroport incentives"
edition = "2021"
name = "usdc-converter"
repository = "https://github.com/neutron-org/neutron-tge-contracts"
version = "0.1.0"

[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]
cosmwasm-schema = { version = "1.3.0" }
cosmwasm-std = { version = "1.3.0" }
cosmwasm-storage = { version = "1.3.0" }
cw-controllers = "1.1.0"
cw-storage-plus = "1.1.0"
cw-utils = { version = "1.0.1" }
cw2 = "1.1.0"
cw20 = { workspace = true }
schemars = "0.8.8"
serde = { version = "1.0.175", default-features = false, features = ["derive"] }
thiserror = { version = "1.0" }
astroport = { path = "../../packages/astroport" }

[dev-dependencies]
anyhow = "1.0.57"
cw-multi-test = "0.16.5"
41 changes: 41 additions & 0 deletions contracts/usdc-converter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
### USDC converter contract

This contract is designed to facilitate Lockdrop participants migration to Noble USDC. It's only `ConvertAndStake` `Receive` handler processes the following operations:
1. Making a `WithdrawLiquidity` call to the `NTRN<>USDC.axl` pair using a given amount of LP tokens;
2. Swapping the withdrawn USDC.axl to Noble USDC;
3. Making a `ProvideLiquidity` call to the `NTRN<>USDC` pair using the withdrawn amount of NTRN and swapped amount of USDC.

### Call example

Here's a `ConvertAndStake` message run on a mainnet fork explanation:
```json
{
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
"sender": "neutron1kyn3jx88wvnm3mhnwpuue29alhsatwzrpkwhu6",
"contract": "neutron137rzkacryzstfyylvvvu2vq9uj5l89yzx9v7gxp0s77xq5ach2xs3t6t3p",
"msg": {
"send": {
"contract": "neutron1zqskhhcn3t45q6y6ljly6nnwreyjw92ejpewc6aj4cfsuyj8mpxsfnxp56",
"amount": "10000000",
"msg": "eyJjb252ZXJ0X2FuZF9zdGFrZSI6eyJ0cmFuc211dGVyX3Bvb2wiOiJuZXV0cm9uMW5zMnRjdW5ybHJrNXlrNjJmcGw3NHljYXphbmNleWZtbXE3ZGxqNnNxOG4wcm5rdXZrN3N6c3RreXgiLCJub2JsZV9wb29sIjoibmV1dHJvbjFxM3JmbWZsaHA3OXJ6MHNkanhkZ2Y3dDN4NXR3Y2U5YXo2bjBmZWdzcGtqc3RyYXg0MmtxMGc5NnJuIiwibm9ibGVfdXNkY19kZW5vbSI6ImliYy9CNTU5QTgwRDYyMjQ5QzhBQTA3QTM4MEUyQTJCRUE2RTVDQTlBNkYwNzlDOTEyQzNBOUU5QjQ5NDEwNUU0RjgxIiwicHJvdmlkZV9saXF1aWRpdHlfc2xpcHBhZ2VfdG9sZXJhbmNlIjoiMC4wMSJ9fQ=="
}
},
"funds": []
}
]
}
```

where the decoded message is
```json
{
"convert_and_stake": {
"transmuter_pool": "neutron1ns2tcunrlrk5yk62fpl74ycazanceyfmmq7dlj6sq8n0rnkuvk7szstkyx",
"noble_pool": "neutron1q3rfmflhp79rz0sdjxdgf7t3x5twce9az6n0fegspkjstrax42kq0g96rn",
"noble_usdc_denom": "ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81",
"provide_liquidity_slippage_tolerance": "0.01"
}
}
```
Loading

0 comments on commit 818d68e

Please sign in to comment.