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: vesting and vault interface #18

Merged
merged 18 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 10 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
29 changes: 29 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["contracts/auction", "contracts/lockdrop", "contracts/credits", "contracts/cw20-merkle-airdrop", "contracts/price-feed", "contracts/astroport/*"]
members = ["contracts/auction", "contracts/lockdrop", "contracts/credits", "contracts/vesting-lp", "contracts/cw20-merkle-airdrop", "contracts/price-feed", "contracts/astroport/*"]

[profile.release]
rpath = false
Expand Down
6 changes: 3 additions & 3 deletions contracts/astroport/factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ pub fn execute(
owner,
expires_in,
config.owner,
OWNERSHIP_PROPOSAL,
&OWNERSHIP_PROPOSAL,
)
.map_err(Into::into)
}
ExecuteMsg::DropOwnershipProposal {} => {
let config = CONFIG.load(deps.storage)?;

drop_ownership_proposal(deps, info, config.owner, OWNERSHIP_PROPOSAL)
drop_ownership_proposal(deps, info, config.owner, &OWNERSHIP_PROPOSAL)
.map_err(Into::into)
}
ExecuteMsg::ClaimOwnership {} => {
Expand All @@ -183,7 +183,7 @@ pub fn execute(

PAIRS_TO_MIGRATE.save(deps.storage, &pairs)?;

claim_ownership(deps, info, env, OWNERSHIP_PROPOSAL, |deps, new_owner| {
claim_ownership(deps, info, env, &OWNERSHIP_PROPOSAL, |deps, new_owner| {
CONFIG
.update::<_, StdError>(deps.storage, |mut v| {
v.owner = new_owner;
Expand Down
6 changes: 3 additions & 3 deletions contracts/astroport/pair_stable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub fn execute(
owner,
expires_in,
config.owner.unwrap_or(factory_config.owner),
OWNERSHIP_PROPOSAL,
&OWNERSHIP_PROPOSAL,
)
.map_err(|e| e.into())
}
Expand All @@ -254,12 +254,12 @@ pub fn execute(
deps,
info,
config.owner.unwrap_or(factory_config.owner),
OWNERSHIP_PROPOSAL,
&OWNERSHIP_PROPOSAL,
)
.map_err(|e| e.into())
}
ExecuteMsg::ClaimOwnership {} => {
claim_ownership(deps, info, env, OWNERSHIP_PROPOSAL, |deps, new_owner| {
claim_ownership(deps, info, env, &OWNERSHIP_PROPOSAL, |deps, new_owner| {
CONFIG.update::<_, StdError>(deps.storage, |mut config| {
config.owner = Some(new_owner);
Ok(config)
Expand Down
6 changes: 6 additions & 0 deletions contracts/vesting-lp/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example vesting_schema"
25 changes: 25 additions & 0 deletions contracts/vesting-lp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "vesting-lp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it vesting-lp? what does lp mean here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually lp stands for liquidity provider, but to be honest I don't see anything related to market making in this contract.

version = "1.1.0"
authors = ["Astroport"]
edition = "2021"

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

[features]
# use library feature to disable all init/handle/query exports
library = []

[dependencies]
vesting-base = {path = "../../packages/vesting-base"}
astroport = { path = "../../packages/astroport", default-features = false }
cosmwasm-schema = { version = "1.1", default-features = false }
cosmwasm-std = { version = "1.1" }
cw-storage-plus = "0.15"

[dev-dependencies]
cw-multi-test = "0.15"
astroport-token = {path = "../astroport/token"}
cw20 = { version = "0.15" }
cw-utils = "0.15"
12 changes: 12 additions & 0 deletions contracts/vesting-lp/examples/vesting_schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cosmwasm_schema::write_api;

use astroport::vesting::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg
}
}
244 changes: 244 additions & 0 deletions contracts/vesting-lp/schema/raw/execute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"description": "This structure describes the execute messages available in the contract.",
"oneOf": [
{
"description": "Claim claims vested tokens and sends them to a recipient",
"type": "object",
"required": [
"claim"
],
"properties": {
"claim": {
"type": "object",
"properties": {
"amount": {
"description": "The amount of tokens to claim",
"anyOf": [
{
"$ref": "#/definitions/Uint128"
},
{
"type": "null"
}
]
},
"recipient": {
"description": "The address that receives the vested tokens",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Receives a message of type [`Cw20ReceiveMsg`] and processes it depending on the received template",
"type": "object",
"required": [
"receive"
],
"properties": {
"receive": {
"$ref": "#/definitions/Cw20ReceiveMsg"
}
},
"additionalProperties": false
},
{
"description": "RegisterVestingAccounts registers vesting targets/accounts",
"type": "object",
"required": [
"register_vesting_accounts"
],
"properties": {
"register_vesting_accounts": {
"type": "object",
"required": [
"vesting_accounts"
],
"properties": {
"vesting_accounts": {
"type": "array",
"items": {
"$ref": "#/definitions/VestingAccount"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Creates a request to change contract ownership ## Executor Only the current owner can execute this",
"type": "object",
"required": [
"propose_new_owner"
],
"properties": {
"propose_new_owner": {
"type": "object",
"required": [
"expires_in",
"owner"
],
"properties": {
"expires_in": {
"description": "The validity period of the offer to change the owner",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"owner": {
"description": "The newly proposed owner",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Removes a request to change contract ownership ## Executor Only the current owner can execute this",
"type": "object",
"required": [
"drop_ownership_proposal"
],
"properties": {
"drop_ownership_proposal": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Claims contract ownership ## Executor Only the newly proposed owner can execute this",
"type": "object",
"required": [
"claim_ownership"
],
"properties": {
"claim_ownership": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
"Binary": {
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
},
"Cw20ReceiveMsg": {
"description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg",
"type": "object",
"required": [
"amount",
"msg",
"sender"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"msg": {
"$ref": "#/definitions/Binary"
},
"sender": {
"type": "string"
}
},
"additionalProperties": false
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
},
"VestingAccount": {
"description": "This structure stores vesting information for a specific address that is getting tokens.",
"type": "object",
"required": [
"address",
"schedules"
],
"properties": {
"address": {
"description": "The address that is getting tokens",
"type": "string"
},
"schedules": {
"description": "The vesting schedules targeted at the `address`",
"type": "array",
"items": {
"$ref": "#/definitions/VestingSchedule"
}
}
},
"additionalProperties": false
},
"VestingSchedule": {
"description": "This structure stores parameters for a specific vesting schedule",
"type": "object",
"required": [
"start_point"
],
"properties": {
"end_point": {
"description": "The end point for the vesting schedule",
"anyOf": [
{
"$ref": "#/definitions/VestingSchedulePoint"
},
{
"type": "null"
}
]
},
"start_point": {
"description": "The start date for the vesting schedule",
"allOf": [
{
"$ref": "#/definitions/VestingSchedulePoint"
}
]
}
},
"additionalProperties": false
},
"VestingSchedulePoint": {
"description": "This structure stores the parameters used to create a vesting schedule.",
"type": "object",
"required": [
"amount",
"time"
],
"properties": {
"amount": {
"description": "The amount of tokens being vested",
"allOf": [
{
"$ref": "#/definitions/Uint128"
}
]
},
"time": {
"description": "The start time for the vesting schedule",
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
}
}
}
Loading