-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ecocredit ORM proto definitions (#700)
* feat: ORM state proto defs * fix: index * chore: reorder * chore: address review & split marketplace * chore: create JOIN table for issuers * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * chore: review comments * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * feat: marketplace indexes * feat: user/basket credit balances and fixes * feat: batch sequence and batch supply * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * chore: move basket messages to own directory * chore: use batch id's to save space * chore: use batch id in basket balance * feat: add retired tracking to batch supply * chore: remove credit type sequence * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * chore: use project_id for batch seq, use bytes for addr in eco balance * Update proto/regen/ecocredit/v1beta1/state.proto Co-authored-by: Aaron Craelius <aaron@regen.network> * Update proto/regen/ecocredit/v1beta1/baskets/state.proto Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Cory <cjlevinson@gmail.com> * feat: add expiration and askdenom table * feat: add expiration index Co-authored-by: technicallyty <48813565+tytech3@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Cory <cjlevinson@gmail.com>
- Loading branch information
1 parent
26cb432
commit 6699a38
Showing
3 changed files
with
337 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
syntax = "proto3"; | ||
|
||
package regen.ecocredit.v1beta1.baskets; | ||
|
||
import "cosmos/orm/v1alpha1/orm.proto"; | ||
|
||
// BasketBalance stores the amount of credits from a batch in a basket | ||
message BasketBalance { | ||
option (cosmos.orm.v1alpha1.table) = { | ||
id: 1, | ||
primary_key: {fields: "basket_denom,batch_id"} | ||
}; | ||
|
||
// basket_denom is the denom of the basket | ||
string basket_denom = 1; | ||
|
||
// batch_id is the id of the credit batch | ||
uint64 batch_id = 2; | ||
|
||
// balance is the amount of ecocredits held in the basket | ||
string balance = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
syntax = "proto3"; | ||
|
||
package regen.ecocredit.v1beta1.marketplace; | ||
|
||
import "cosmos/orm/v1alpha1/orm.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
// SellOrder represents the information for a sell order. | ||
message SellOrder { | ||
|
||
option (cosmos.orm.v1alpha1.table) = { | ||
id: 1, | ||
primary_key: {fields: "order_id"} | ||
index: {id: 1 fields: "batch_denom"} | ||
index: {id: 2 fields: "owner"} | ||
index: {id: 3 fields: "expiration"} | ||
}; | ||
|
||
// order_id is the unique ID of sell order. | ||
uint64 order_id = 1; | ||
|
||
// owner is the address of the owner of the credits being sold. | ||
string owner = 2; | ||
|
||
// batch_denom is the credit batch being sold. | ||
string batch_denom = 3; | ||
|
||
// quantity is the quantity of credits being sold. | ||
string quantity = 4; | ||
|
||
// ask_price is the price the seller is asking for each unit of the | ||
// batch_denom. Each credit unit of the batch will be sold for at least the | ||
// ask_price or more. | ||
cosmos.base.v1beta1.Coin ask_price = 5; | ||
|
||
// disable_auto_retire disables auto-retirement of credits which allows a | ||
// buyer to disable auto-retirement in their buy order enabling them to | ||
// resell the credits to another buyer. | ||
bool disable_auto_retire = 6; | ||
|
||
// expiration is an optional timestamp when the sell order expires. When the | ||
// expiration time is reached, the sell order is removed from state. | ||
google.protobuf.Timestamp expiration = 7 [ (gogoproto.stdtime) = true ]; | ||
} | ||
|
||
// BuyOrder represents the information for a buy order. | ||
message BuyOrder { | ||
|
||
option (cosmos.orm.v1alpha1.table) = { | ||
id: 2, | ||
primary_key: {fields: "buy_order_id"} | ||
index: {id: 1 fields: "buyer"} | ||
index: {id: 2 fields: "expiration"} | ||
}; | ||
|
||
// Selection defines a buy order selection. | ||
message Selection { | ||
|
||
// sum defines the type of selection. | ||
oneof sum { | ||
// sell_order_id is the sell order ID against which the buyer is trying to buy. | ||
// When sell_order_id is set, this is known as a direct buy order because it | ||
// is placed directly against a specific sell order. | ||
uint64 sell_order_id = 1; | ||
|
||
// TODO: once we have filters defined for baskets, we can enable filtered | ||
// buy orders which will involve full double-sided batch order matching | ||
// | ||
// filter selects credits to buy based upon the specified filter criteria. | ||
// Filter filter = 2; | ||
} | ||
} | ||
|
||
// buy_order_id is the unique ID of buy order. | ||
uint64 buy_order_id = 1; | ||
|
||
// buyer is the address that created the buy order | ||
string buyer = 2; | ||
|
||
// selection is the buy order selection. | ||
Selection selection = 3; | ||
|
||
// quantity is the quantity of credits to buy. If the quantity of credits | ||
// available is less than this amount the order will be partially filled | ||
// unless disable_partial_fill is true. | ||
string quantity = 4; | ||
|
||
// bid price is the bid price for this buy order. A credit unit will be | ||
// settled at a purchase price that is no more than the bid price. The | ||
// buy order will fail if the buyer does not have enough funds available | ||
// to complete the purchase. | ||
cosmos.base.v1beta1.Coin bid_price = 5; | ||
|
||
// disable_auto_retire allows auto-retirement to be disabled. If it is set to true | ||
// the credits will not auto-retire and can be resold assuming that the | ||
// corresponding sell order has auto-retirement disabled. If the sell order | ||
// hasn't disabled auto-retirement and the buy order tries to disable it, | ||
// that buy order will fail. | ||
bool disable_auto_retire = 6; | ||
|
||
// disable_partial_fill disables the default behavior of partially filling | ||
// buy orders if the requested quantity is not available. | ||
bool disable_partial_fill = 7; | ||
|
||
// expiration is the optional timestamp when the buy order expires. When the | ||
// expiration time is reached, the buy order is removed from state. | ||
google.protobuf.Timestamp expiration = 8 [ (gogoproto.stdtime) = true ]; | ||
} | ||
|
||
// AskDenom represents the information for an ask denom. | ||
message AskDenom { | ||
|
||
option (cosmos.orm.v1alpha1.table) = { | ||
id: 3, | ||
primary_key: {fields: "denom"} | ||
index: {id: 1 fields: "display_denom"} | ||
}; | ||
|
||
// denom is the denom to allow (ex. ibc/GLKHDSG423SGS) | ||
string denom = 1; | ||
|
||
// display_denom is the denom to display to the user and is informational | ||
string display_denom = 2; | ||
|
||
// exponent is the exponent that relates the denom to the display_denom and is | ||
// informational | ||
uint32 exponent = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters