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

Change lockup to vault #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
root: ./target/wasm32-unknown-unknown/release
paths:
- mesh_consumer.wasm
- mesh_lockup.wasm
- mesh_vault.wasm
- mesh_provider.wasm
- mesh_slasher.wasm
- meta_staking.wasm
Expand Down
38 changes: 19 additions & 19 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
Expand Up @@ -43,7 +43,7 @@ test-case = "2.2.0"
codegen-units = 1
incremental = false

[profile.release.package.mesh-lockup]
[profile.release.package.mesh-vault]
codegen-units = 1
incremental = false

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ to get view of the various flows involved.

* `meta-staking` - a bridge between the rest of the contracts and the x/staking module to
provide a consistent, friendly interface for our use case
* `mesh-lockup` - a contract that locks tokens and allows lockers to issue multiple claims
* `mesh-vault` - a contract that locks tokens and allows lockers to issue multiple claims
to other consumers, who can all slash that stake and eventually release their claim
* `mesh-provider` - an IBC-enabled contract that issues claims on an ILP and speaks IBC to a consumer. It
is responsible for submitting slashes it receives from the `slasher` to the `ilp` contract.
Expand All @@ -36,18 +36,18 @@ You can also connect each chain as a provider to N chains and a consumer from N
Let's analyze the Osmosis side of this. Osmosis is the provider of security to Juno.
Once the contracts have been deployed, a user can interact with this as follows.

#### Cross-staking:
#### Cross-staking

1. User stakes their tokens in the `mesh-lockup` contract on Osmosis
2. User can cross-stake those tokens to a Juno `mesh-provider` contract (on Osmosis), specifying how many of their
1. User stakes their tokens in the `mesh-vault` contract on Osmosis
2. User can cross-stake those tokens to a Juno `mesh-provider` contract (on Osmosis), specifying how many of their
tokens to cross-stake and to which validator
3. The Osmosis `mesh-consumer` contract (on Juno) receives a message from the counterparty `mesh-provider` contract
and updates the stake in the `meta-staking` contract (on Juno).
4. The `meta-staking` contract checks the values and updates it's delegations to `x/staking` accordingly. (The
meta-staking contract is assumed to have enough JUNO tokens to do the delegations. How it gets that JUNO is
out of scope.)

#### Claiming Rewards:
#### Claiming Rewards

1. Anyone can trigger the Osmosis consumer contract to claim rewards from the `meta-staking` contract
2. The `mesh-consumer` contract (on JUNO) sends tokens to the `mesh-provider` contract (on Osmosis) via ics20
Expand All @@ -56,7 +56,7 @@ Once the contracts have been deployed, a user can interact with this as follows.
4. The `mesh-provider` (on Osmosis) contract updates distribution info to all stakers, allowing them to claim
their share of the $JUNO rewards on Osmosis.

#### Unstaking:
#### Unstaking

1. A user submits a request to unstake their tokens from the `mesh-provider` contract (on Osmosis)
2. We update the local distribution info to reflect the new amount of tokens staked
Expand All @@ -65,24 +65,24 @@ Once the contracts have been deployed, a user can interact with this as follows.
4. The `mesh-provider` contract (on Osmosis) gets the unbonding period for this cross stake by querying
the `slasher` contract
5. After the unbonding period has passed (eg. 2 weeks, 4 weeks) the `mesh-provider` contract
informs the `mesh-lockup` contract that it removes its claim.
6. If the user's stake in the `mesh-lockup` contract has not more claims on it, they can withdraw their stake.
informs the `mesh-vault` contract that it removes its claim.
6. If the user's stake in the `mesh-vault` contract has not more claims on it, they can withdraw their stake.

#### Slashing:
#### Slashing

1. Someone calls a method to submit evidence of Juno misbehavior on the `meta-slasher` contract (on Osmosis).
2. The `meta-slasher` contract verifies that a slashing event has indeed occurred and makes a contract call to the
`mesh-provider` contract with the amount to slash.
3. The `mesh-provider` updates the `mesh-lockup` stakes of everyone delegating to the offending validator. Tokens are unbonded
3. The `mesh-provider` updates the `mesh-vault` stakes of everyone delegating to the offending validator. Tokens are unbonded
and scheduled to be burned.
4. `mesh-provider` sends IBC packet updates to the `mesh-consumer`s on all other chains about the new voting power.

#### Claiming tokens:
#### Claiming tokens

A user can stake any number of tokens to the `mesh-lockup` contract, and use them in multiple provider contracts.
The `mesh-lockup` contract ensures that the user has balance >= the max claim at all times.
A user can stake any number of tokens to the `mesh-vault` contract, and use them in multiple provider contracts.
The `mesh-vault` contract ensures that the user has balance >= the max claim at all times.
If you put in eg 1000 OSMO, but then provide 700, 500, and 300 to various providers,
you can pull out 300 OSMO from the `mesh-lockup` contract. Once you successfully release the claim on the
you can pull out 300 OSMO from the `mesh-vault` contract. Once you successfully release the claim on the
provider with 700, then you can pull out another 200 OSMO.

## Overview for Installing
Expand All @@ -101,7 +101,7 @@ provider with 700, then you can pull out another 200 OSMO.

These are well-defined but removed from the MVP for simplicity. We can add them later.

* `mesh-lockup` must also allow local staking, and tie into the meta-staking contract to use that
* `mesh-vault` must also allow local staking, and tie into the meta-staking contract to use that
same stake to provide security on the home chain.

## Open Questions
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "mesh-lockup"
name = "mesh-vault"
authors = ["Ethan Frey <[email protected]>"]

edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use mesh_lockup::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use mesh_vault::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::state::{Config, BALANCES, CONFIG};
use mesh_apis::ClaimReceiverMsg;

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:mesh-lockup";
const CONTRACT_NAME: &str = "crates.io:mesh-vault";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions scripts/create_clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ cosmwasm-ts-codegen generate \
--name MeshConsumer \
--no-bundle

#Create client for mesh-lockup
#Create client for mesh-vault
cosmwasm-ts-codegen generate \
--plugin client \
--schema ls ../contracts/mesh-lockup/schema \
--schema ls ../contracts/mesh-vault/schema \
--out ./src/bindings \
--name MeshLockup \
--name MeshVault \
--no-bundle

#Create client for mesh-provider
Expand Down
30 changes: 15 additions & 15 deletions tests/src/cosmwasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.before(async (t) => {

console.debug("Upload contracts to osmosis...");
const osmosisContracts = {
mesh_lockup: "./internal/mesh_lockup.wasm",
mesh_vault: "./internal/mesh_vault.wasm",
mesh_provider: "./internal/mesh_provider.wasm",
mesh_slasher: "./internal/mesh_slasher.wasm",
};
Expand All @@ -59,7 +59,7 @@ interface SetupInfo {
wasmMetaStaking: string;
osmoMeshProvider: string;
osmoMeshSlasher: string;
osmoMeshLockup: string;
osmoMeshVault: string;
meshConsumerPort: string;
meshProviderPort: string;
link: Link;
Expand All @@ -81,13 +81,13 @@ async function demoSetup(): Promise<SetupInfo> {
const osmoStargateClient = await setupOsmoStargateClient();
const wasmStargateClient = await setupWasmStargateClient();

// instantiate mesh_lockup on osmosis
const initMeshLockup = { denom: osmosis.denomStaking };
const { contractAddress: osmoMeshLockup } = await osmoClient.sign.instantiate(
// instantiate mesh_vault on osmosis
const initMeshVault = { denom: osmosis.denomStaking };
const { contractAddress: osmoMeshVault } = await osmoClient.sign.instantiate(
osmoClient.senderAddress,
osmosisIds.mesh_lockup,
initMeshLockup,
"mesh_lockup contract",
osmosisIds.mesh_vault,
initMeshVault,
"mesh_vault contract",
"auto"
);

Expand All @@ -114,7 +114,7 @@ async function demoSetup(): Promise<SetupInfo> {
owner: osmoClient.senderAddress,
}),
},
lockup: osmoMeshLockup,
lockup: osmoMeshVault,
// 0 second unbonding here so we can test it
unbonding_period: 0,
rewards_ibc_denom: ibcDenom,
Expand Down Expand Up @@ -172,7 +172,7 @@ async function demoSetup(): Promise<SetupInfo> {
wasmStargateClient,
wasmMeshConsumer,
osmoMeshProvider,
osmoMeshLockup,
osmoMeshVault,
osmoMeshSlasher,
wasmMetaStaking,
meshConsumerPort,
Expand Down Expand Up @@ -273,7 +273,7 @@ test.serial("Happy Path (cross-stake / cross-unstake)", async (t) => {
osmoStargateClient,
wasmMeshConsumer,
osmoMeshProvider,
osmoMeshLockup,
osmoMeshVault,
wasmMetaStaking,
link,
ics20,
Expand Down Expand Up @@ -313,7 +313,7 @@ test.serial("Happy Path (cross-stake / cross-unstake)", async (t) => {
const lockedTokens = { amount: "500000", denom: "uosmo" };
const lockupRes = await osmoClient.sign.execute(
osmoClient.senderAddress,
osmoMeshLockup,
osmoMeshVault,
{ bond: {} },
"auto",
"memo",
Expand All @@ -333,7 +333,7 @@ test.serial("Happy Path (cross-stake / cross-unstake)", async (t) => {
// Grant claim, cross stake 100 tokens to validator on wasmd
const grantClaimRes = await osmoClient.sign.execute(
osmoClient.senderAddress,
osmoMeshLockup,
osmoMeshVault,
{
grant_claim: { leinholder: osmoMeshProvider, amount: "500000", validator: validatorAddr },
},
Expand Down Expand Up @@ -446,12 +446,12 @@ test.serial("Happy Path (cross-stake / cross-unstake)", async (t) => {
t.is(senderBalance.amount, rewardsTosend.amount);

// Make another tx to advanace the block
await osmoClient.sign.execute(osmoClient.senderAddress, osmoMeshLockup, { bond: {} }, "auto", "memo", [lockedTokens]);
await osmoClient.sign.execute(osmoClient.senderAddress, osmoMeshVault, { bond: {} }, "auto", "memo", [lockedTokens]);

// Unbond 100 tokens from wasmd now that a block has passed
const unbondRes = await osmoClient.sign.execute(
osmoClient.senderAddress,
osmoMeshLockup,
osmoMeshVault,
{ unbond: { amount: "100" } },
"auto"
);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const osmoConfig = {
meshLockupAddr: "osmo1kf88a6ftgt57t2hg48jfc9679l50tq6jqwsdheuld6467jls2hxstnvnal",
meshVaultAddr: "osmo1kf88a6ftgt57t2hg48jfc9679l50tq6jqwsdheuld6467jls2hxstnvnal",
meshProviderAddr: "osmo19kx57u0nrhqas34qvyhu2ydt4a9rlj6n37l88jqwfc2eesuk9tuq6c6ywj",
meshProviderPort: "wasm.osmo19kx57u0nrhqas34qvyhu2ydt4a9rlj6n37l88jqwfc2eesuk9tuq6c6ywj",
meshSlasherAddr: "osmo1fewayl23e89rkejx932ljxf0ylsmtqc49r4myzzsvxcpweptmu0szshpkv",
Expand Down
Loading