Skip to content

Commit

Permalink
feat: ecocredit direct buy/sell proto definitions (#560)
Browse files Browse the repository at this point in the history
* feat: credit store proto definition

* fix proto file

* change CancelSellOrder to UpdatedSellOrder and add AllowAskDenom

* update comments

* updates

* add bid price

* Update proto/regen/ecocredit/v1alpha1/tx.proto

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>

* rename dont_auto_retire to disable_auto_retire

* Update proto/regen/ecocredit/v1alpha1/tx.proto

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>

Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 28, 2021
1 parent 53b6f00 commit 68178f5
Showing 1 changed file with 153 additions and 1 deletion.
154 changes: 153 additions & 1 deletion proto/regen/ecocredit/v1alpha1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package regen.ecocredit.v1alpha1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/regen-network/regen-ledger/x/ecocredit";

Expand Down Expand Up @@ -39,6 +40,18 @@ service Msg {

// UpdateClassMetadata updates the credit class metadata
rpc UpdateClassMetadata(MsgUpdateClassMetadata) returns (MsgUpdateClassMetadataResponse);

// Sell creates new sell orders.
rpc Sell(MsgSell) returns (MsgSellResponse);

// UpdateSellOrders updates existing sell orders.
rpc UpdateSellOrders(MsgUpdateSellOrders) returns (MsgUpdateSellOrdersResponse);

// BuyDirect creates buy orders directly against sell orders.
rpc BuyDirect (MsgBuyDirect) returns (MsgBuyDirectResponse);

// AllowAskDenom is a governance operation which authorizes a new ask denom to be used in sell orders
rpc AllowAskDenom (MsgAllowAskDenom) returns (MsgAllowAskDenomResponse);
}

// MsgCreateClass is the Msg/CreateClass request type.
Expand Down Expand Up @@ -274,4 +287,143 @@ message MsgUpdateClassMetadata {
}

// MsgUpdateClassMetadataResponse is the MsgUpdateClassMetadata response type.
message MsgUpdateClassMetadataResponse {}
message MsgUpdateClassMetadataResponse {}

// MsgSell is the Msg/Sell request type.
message MsgSell {

// owner is the address of the owner of the credits being sold.
string owner = 1;

// orders are the sell orders being created.
repeated Order orders = 2;

// Order is the content of a new sell order.
message Order {

// batch_denom is the credit batch being sold.
string batch_denom = 1;

// quantity is the quantity of credits being sold from this batch. If it is
// less then the balance of credits the owner has available at the time this
// sell order is matched, the quantity will be adjusted downwards to the
// owner's balance. However, if the balance of credits is less than this
// quantity at the time the sell order is created, the operation will fail.
string quantity = 2;

// 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 = 3;

// 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 = 4;
}
}

// MsgSellResponse is the Msg/Sell response type.
message MsgSellResponse {

// sell_order_ids are the sell order IDs of the newly created sell orders.
repeated uint64 sell_order_ids = 1;
}

// MsgUpdateSellOrders is the Msg/UpdateSellOrders request type.
message MsgUpdateSellOrders {

// owner is the owner of the sell orders.
string owner = 1;

// updates are updates to existing sell orders.
repeated Update updates = 2;

// Update is an update to an existing sell order.
message Update {

// sell_order_id is the ID of an existing sell order.
uint64 sell_order_id = 1;

// new_quantity is the updated quantity of credits available to sell, if it
// is set to zero then the order is cancelled.
string new_quantity = 2;

// new_ask_price is the new ask price for this sell order
cosmos.base.v1beta1.Coin new_ask_price = 3;

// disable_auto_retire updates the disable_auto_retire field in the sell order.
bool disable_auto_retire = 4;
}
}

// MsgUpdateSellOrdersResponse is the Msg/UpdateSellOrders response type.
message MsgUpdateSellOrdersResponse {}

// MsgBuyDirect is the Msg/BuyDirect request type.
message MsgBuyDirect {

// buyer is the address of the credit buyer.
string buyer = 1;

// orders are the new buy orders.
repeated Order orders = 2;

// Order is a direct buy order.
message Order {

// sell_order_id is the sell order ID against which the buyer is trying to buy.
uint64 sell_order_id = 1;

// 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 = 2;

// 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 = 3;

// 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 = 4;

// disable_partial_fill disables the default behavior of partially filling
// buy orders if the requested quantity is not available.
bool disable_partial_fill = 5;
}
}

// MsgBuyDirectResponse is the Msg/BuyDirect response type.
message MsgBuyDirectResponse {

// buy_order_ids are the buy order IDs of the newly created buy orders. Buy
// orders may not settle instantaneously, but rather in batches at specified
// batch epoch times.
repeated uint64 buy_order_ids = 1;
}


// MsgAllowAskDenom is the Msg/AllowAskDenom request type.
message MsgAllowAskDenom {
// root_address is the address of the governance account which can authorize ask denoms
string root_address = 1;

// denom is the denom to allow (ex. ibc/GLKHDSG423SGS)
string denom = 2;

// display_denom is the denom to display to the user and is informational
string display_denom = 3;

// exponent is the exponent that relates the denom to the display_denom and is
// informational
uint32 exponent = 4;
}

// MsgAllowAskDenomResponse is the Msg/AllowAskDenom response type.
message MsgAllowAskDenomResponse {}

0 comments on commit 68178f5

Please sign in to comment.