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

feat: LP migration to PCL v2 #72

Merged
merged 1 commit into from
Feb 26, 2024
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
15 changes: 15 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
members = [
"contracts/auction",
"contracts/lockdrop",
"contracts/lockdrop-pcl",
"contracts/credits",
"contracts/vesting-lp",
"contracts/vesting-lti",
"contracts/vesting-investors",
"contracts/cw20-merkle-airdrop",
"contracts/price-feed",
"contracts/astroport/*"
"contracts/astroport/*",
]

[profile.release]
Expand Down
4 changes: 4 additions & 0 deletions contracts/lockdrop-pcl/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example lockdrop_schema"
38 changes: 38 additions & 0 deletions contracts/lockdrop-pcl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "neutron-lockdrop"
version = "1.2.1"
authors = ["_astromartian"]
edition = "2021"


exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[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]
# we have to keep it 0.15.1 because it is the same version as in astroport
cw-storage-plus = { version = "0.15.1" }
astroport = { git = "https://github.com/astroport-fi/astroport-core.git", tag = "v2.5.0" }
credits = { path = "../credits" }
astroport-periphery = { workspace = true }
cosmwasm-std = { workspace = true }
cw20 = { workspace = true }
cw2 = { workspace = true }
serde = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
61 changes: 61 additions & 0 deletions contracts/lockdrop-pcl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Lockdrop

The lockdrop contract allows users to lock any of the supported Terraswap LP tokens locked for a selected duration against which they will receive ASTRO tokens pro-rata to their weighted share of the LP tokens to the total deposited LP tokens for that particular pool in the contract.

- Upon lockup expiration, users will receive Astroport LP tokens on an equivalent weight basis as per their initial Terraswap LP token deposits.

Note - Users can open muliple lockup positions with different lockup duration for each LP Token pool

## Contract Design

### Handle Messages

| Message | Description |
|-----------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ExecuteMsg::UpdateConfig` | Can only be called by the admin. Facilitates updating configuration parameters |
| `ExecuteMsg::EnableClaims` | Executed by the Bootstrap auction contract when liquidity is added to the ASTRO-UST pool. Enables ASTRO withdrawals by the lockdrop recipients. |
| `ExecuteMsg::InitializePool` | Admin function. Facilitates addition of new Pool (Terraswap Pools) whose LP tokens can then be locked in the lockdrop contract |
| `ExecuteMsg::UpdatePool` | Admin function to update any configuraton parameter for a terraswap pool whose LP tokens are currently accepted for the lockdrop |
| `ExecuteMsg::IncreaseLockup` | Facilitates opening a new user position or adding to an existing position |
| `ExecuteMsg::IncreaseAstroIncentives` | Admin function to increase the ASTRO incentives that are to be distributed |
| `ExecuteMsg::WithdrawFromLockup` | Facilitates LP token withdrawals from lockup positions by users. 100% amount can be withdrawn during deposit window, which is then limited to 50% during 1st half of deposit window which then decreases linearly during 2nd half of deposit window. Only 1 withdrawal can be made by a user during the withdrawal windows |
| `ExecuteMsg::MigrateLiquidity` | Admin function. Facilitates migration of liquidity (locked terraswap LP tokens) from Terraswap to Astroport (Astroport LP tokens) |
| `ExecuteMsg::StakeLpTokens` | Admin function. Facilitates staking of Astroport LP tokens for a particular LP pool with the generator contract |
| `ExecuteMsg::DelegateAstroToAuction` | This function facilitates ASTRO tokens delegation to the Bootstrap auction contract during the bootstrap auction phase. Delegated ASTRO tokens are added to the user's position in the bootstrap auction contract |
| `ExecuteMsg::ClaimRewardsAndOptionallyUnlock` | Facilitates rewards claim by users for a particular lockup position along with unlock when possible |
| `ExecuteMsg::ClaimAssetReward` | Collects assets reward from LP and distribute reward to user if all requirements are met |
| `ExecuteMsg::TogglePoolRewards` | Admin function. Enables assets reward for specified LP |
| `ExecuteMsg::ProposeNewOwner` | Admin function. Creates an offer to change the contract ownership. The validity period of the offer is set in the `expires_in` variable. After `expires_in` seconds pass, the proposal expires and cannot be accepted anymore. |
| `ExecuteMsg::DropOwnershipProposal` | Admin function. Removes an existing offer to change the contract owner. |
| `ExecuteMsg::ClaimOwnership` | Admin function. Used to claim contract ownership. |

### Handle Messages :: Callback

| Message | Description |
|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `CallbackMsg::UpdatePoolOnDualRewardsClaim` | Callback function to update contract state after pending dual staking rewards are claimed from the generator contract |
| `CallbackMsg::WithdrawUserLockupRewardsCallback` | Callback function to withdraw user rewards for a particular lockcup position along with optional LP tokens withdrawal (upon lockup duration expiration) |
| `CallbackMsg::WithdrawLiquidityFromTerraswapCallback` | Callback function used during liquidity migration to update state after liquidity is removed from terraswap |
| `CallbackMsg::DistributeAssetReward` | Callback function used for assets reward distribution after rewards claiming from LP |

### Query Messages

| Message | Description |
|---------------------------------|------------------------------------------------------------------------------------------------------------------|
| `QueryMsg::Config` | Returns the config info |
| `QueryMsg::State` | Returns the contract's global state |
| `QueryMsg::Pool` | Returns info regarding a certain supported LP token pool |
| `QueryMsg::UserInfo` | Returns info regarding a user (total ASTRO rewards, list of lockup positions) |
| `QueryMsg::LockUpInfo` | Returns info regarding a particular lockup position with a given duration and identifer for the LP tokens locked |
| `QueryMsg::PendingAssetReward` | Returns the amount of pending asset rewards for the specified recipient and for a specific lockup position |

## Build schema and run unit-tests

```
cargo schema
cargo test
```

## License

TBD
12 changes: 12 additions & 0 deletions contracts/lockdrop-pcl/examples/lockdrop_schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cosmwasm_schema::write_api;

use astroport_periphery::lockdrop::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

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