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: add special asset pairs #2150

Merged
merged 47 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2f1b8bd
feat: add special asset pairs
toteki Jul 17, 2023
cb484f9
Update proto/umee/leverage/v1/leverage.proto
toteki Jul 17, 2023
02b5edf
Merge branch 'main' into adam/special
toteki Jul 18, 2023
07acee1
Merge branch 'main' into adam/special
toteki Jul 20, 2023
9f0f9fe
Merge branch 'main' into adam/special
toteki Jul 21, 2023
286fa0e
line length lint
toteki Jul 21, 2023
e05b997
Merge branch 'main' into adam/special
toteki Jul 21, 2023
5eb3d88
Merge branch 'main' into adam/special
toteki Jul 21, 2023
ea72c67
Update x/leverage/keeper/token.go
toteki Jul 21, 2023
545ee88
Update x/leverage/keeper/token.go
toteki Jul 21, 2023
b3270a8
Update proto/umee/leverage/v1/leverage.proto
toteki Jul 21, 2023
d1819fa
Update proto/umee/leverage/v1/leverage.proto
toteki Jul 21, 2023
73c4b30
Merge branch 'main' into adam/special
toteki Jul 21, 2023
5b7b02d
make proto-all
toteki Jul 21, 2023
55f8153
make proto-all
toteki Jul 21, 2023
97efc7f
fix
toteki Jul 21, 2023
48a9900
Merge branch 'main' into adam/special
toteki Jul 25, 2023
c9c0cdb
remove title + description
toteki Jul 25, 2023
5817edd
group legacy msg interface
toteki Jul 25, 2023
153037e
proposal.go
toteki Jul 25, 2023
c3d39b2
legacy++
toteki Jul 25, 2023
9a22f72
special asset sets in gov message
toteki Jul 26, 2023
11ffd99
pair deletion logic
toteki Jul 26, 2023
5e08485
can query for specific asset
toteki Jul 26, 2023
004a5d5
Update proto/umee/leverage/v1/tx.proto
toteki Jul 26, 2023
0c3440d
make proto-all
toteki Jul 26, 2023
f8cb27f
changelog
toteki Jul 26, 2023
19d5a06
Merge branch 'main' into adam/special
toteki Jul 27, 2023
206c769
lint
toteki Jul 27, 2023
b9b522c
Update proto/umee/leverage/v1/tx.proto
toteki Jul 28, 2023
0075b58
Update proto/umee/leverage/v1/tx.proto
toteki Jul 28, 2023
53b7e4f
proto changes
toteki Jul 28, 2023
7944aae
collateral weight zero deletes sets ad pairs
toteki Jul 28, 2023
fcda085
fix CLI
toteki Jul 28, 2023
ef36cda
test++
toteki Jul 28, 2023
0e46e1a
combine validate functions in genesis
toteki Jul 28, 2023
6f75ab6
Merge branch 'main' into adam/special
toteki Jul 28, 2023
daa5e0a
fix
toteki Jul 28, 2023
f83ab08
fix
toteki Jul 28, 2023
78cd2e7
proto changes
toteki Jul 30, 2023
e48b35c
fix names
toteki Jul 30, 2023
8804ed4
fix names
toteki Jul 30, 2023
31402c5
validation allows empty pairs if sets present instead
toteki Jul 30, 2023
03dcd74
optional arg doc
toteki Jul 30, 2023
cbd2178
Add liquidation threshold to pairs
toteki Jul 30, 2023
39a9994
revert proposal.go
toteki Jul 30, 2023
5e2e948
change stringer
toteki Jul 30, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [2129](https://github.com/umee-network/umee/pull/2129) Emergency Group x/ugov proto.
- [2146](https://github.com/umee-network/umee/pull/2146) Add store `GetTimeMs` and `SetTimeMs`.
- [2157](https://github.com/umee-network/umee/pull/2157) Add `x/metoken` module.
- [2150](https://github.com/umee-network/umee/pull/2150) Add gov message to create Special Asset Pairs
- [2145](https://github.com/umee-network/umee/pull/2145) Add New `Inflation Parms` to x/ugov proto and added `inflation rate` change logic to umint
- [2159](https://github.com/umee-network/umee/pull/2159) Add hard market cap for token emission.
- [2155](https://github.com/umee-network/umee/pull/2155) `bpmath`: basis points math package.
Expand Down
1 change: 1 addition & 0 deletions proto/umee/leverage/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ message GenesisState {
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated SpecialAssetPair special_pairs = 10 [(gogoproto.nullable) = false];
}

// AdjustedBorrow is a borrow struct used in the leverage module's genesis
Expand Down
55 changes: 55 additions & 0 deletions proto/umee/leverage/v1/leverage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,58 @@ message Token {
(gogoproto.moretags) = "yaml:\"historic_medians\""
];
}

// SpecialAssetPair defines a special (increased) CollateralWeight used when a specified Collateral is used
// to collateralize a specified Borrow. This association is one-way (so it does not work in reverse).
message SpecialAssetPair {
option (gogoproto.equal) = true;

// Collateral base token denom.
string collateral = 1;

// Borrow base token denom.
string borrow = 2;
toteki marked this conversation as resolved.
Show resolved Hide resolved

// Collateral Weight defines what portion of the total value of the asset
// can contribute to a users borrowing power. For special asset pairs, this
// also overrides the borrowed asset's collateral weight when evaluating borrow
// factor. Valid values: 0-1.
string collateral_weight = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Liquidation threshold defines what portion of the total value of the assets
// can contribute to a users liquidation threshold, when borrowing within the pair.
// Valid values in range [collateral_weight,1]
string liquidation_threshold = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// SpecialAssetSet defines a special (increased) CollateralWeight used when any of a set
// of assets are used to borrow each other (except for looping). It is used in gov proposals
// to create all the pairs that make up a set at once.
message SpecialAssetSet {
option (gogoproto.equal) = true;

// Collateral or borrowed base token denoms.
repeated string assets = 1;

// Collateral Weight defines what portion of the total value of the assets
// can contribute to a users borrowing power, when borrowing within the set.
toteki marked this conversation as resolved.
Show resolved Hide resolved
// Valid values: 0-1.
string collateral_weight = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Liquidation threshold defines what portion of the total value of the assets
// can contribute to a users liquidation threshold, when borrowing within the set.
// Valid values in range [collateral_weight,1]
string liquidation_threshold = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
19 changes: 19 additions & 0 deletions proto/umee/leverage/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ service Query {
option (google.api.http).get = "/umee/leverage/v1/registered_tokens";
}

// SpecialAssets queries for all special asset pairs.
rpc SpecialAssets(QuerySpecialAssets)
returns (QuerySpecialAssetsResponse) {
option (google.api.http).get = "/umee/leverage/v1/special_assets";
}

// MarketSummary queries a base asset's current borrowing and supplying conditions.
rpc MarketSummary(QueryMarketSummary)
returns (QueryMarketSummaryResponse) {
Expand Down Expand Up @@ -100,6 +106,19 @@ message QueryRegisteredTokensResponse {
repeated Token registry = 1 [(gogoproto.nullable) = false];
}

// QuerySpecialAssets defines the request structure for the SpecialAssets
// gRPC service handler.
message QuerySpecialAssets {
// denom can be used to query only pairs affecting a specific asset
string denom = 1;
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// QuerySpecialAssetsResponse defines the response structure for the
// SpecialAssets gRPC service handler.
message QuerySpecialAssetsResponse {
repeated SpecialAssetPair pairs = 1 [(gogoproto.nullable) = false];
}

// QueryMarketSummary defines the request structure for the MarketSummary gRPC service handler.
message QueryMarketSummary {
string denom = 1;
Expand Down
33 changes: 33 additions & 0 deletions proto/umee/leverage/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ service Msg {
// GovUpdateRegistry adds new tokens to the token registry or
// updates existing tokens with new settings.
rpc GovUpdateRegistry(MsgGovUpdateRegistry) returns (MsgGovUpdateRegistryResponse);

// GovUpdateSpecialAssets adds, updates, or removes special asset pairs. Note that a special asset
// pair can be removed by setting its special collateral weight to negative one. Also allows for the creation
// of sets of assets, where each asset in the set forms a special asset pair with all of the others.
rpc GovUpdateSpecialAssets(MsgGovUpdateSpecialAssets) returns (MsgGovUpdateSpecialAssetsResponse);
}

// MsgSupply represents a user's request to supply assets to the module.
Expand Down Expand Up @@ -266,3 +271,31 @@ message MsgGovUpdateRegistry {

// MsgGovUpdateRegistryResponse defines the Msg/GovUpdateRegistry response type.
message MsgGovUpdateRegistryResponse {}

// MsgGovUpdateSpecialAssets defines the Msg/GovUpdateSpecialAssets request type.
message MsgGovUpdateSpecialAssets {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// sets are bidirectional groups of special asset pairs. Creating a special asset
// set causes all assets in the set to have a certain collateral weight when borrowing
// against each other (but not looping with themselves). Overrides any existing
// special asset pairs between assets in the set. Using both collateral weight
// and liquidation theshold of zero will clear all existing special pairs in the set instead.
repeated SpecialAssetSet sets = 2 [(gogoproto.nullable) = false];

// pairs are new or updated special asset pairs. Updating both a special asset pair's
// collateral weight and liquidation threshold to zero deletes the pair instead.
// These pairs will be applied after any sets above when passing a proposal,
// so they can be used to override certain set elements, set directional relationships,
// or set an asset's relation to itself (looping).
repeated SpecialAssetPair pairs = 3 [(gogoproto.nullable) = false];
toteki marked this conversation as resolved.
Show resolved Hide resolved
}

// MsgGovUpdateSpecialAssetsResponse defines the Msg/GovUpdateSpecialAssets response type.
message MsgGovUpdateSpecialAssetsResponse {}
Loading