mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Executable
+13
@@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.module.v1;
|
||||
|
||||
import "cosmos/app/v1alpha1/module.proto";
|
||||
|
||||
// Module is the app config object of the module.
|
||||
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
||||
message Module {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import : "github.com/sonr-io/sonr"
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
## Overview
|
||||
Query endpoints for the DEX module provide read-only access to decentralized exchange state and operations.
|
||||
|
||||
## Request: {{.RequestType.Name}}
|
||||
|
||||
| Field ID | Name | Type | Description |
|
||||
| -------- | ---- | ---- | ----------- | {{range .RequestType.Fields}}
|
||||
| {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}
|
||||
|
||||
## Response: {{.ResponseType.Name}}
|
||||
|
||||
| Field ID | Name | Type | Description |
|
||||
| -------- | ---- | ---- | ----------- | {{range .ResponseType.Fields}}
|
||||
| {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}
|
||||
|
||||
## Query Details
|
||||
|
||||
{{if eq .MethodDescriptorProto.Name "Params"}}
|
||||
- Returns the current module parameters
|
||||
- Includes fee configurations and operational settings
|
||||
- No authentication required for parameter queries
|
||||
{{else if eq .MethodDescriptorProto.Name "Account"}}
|
||||
- Retrieves a specific DEX account by DID and connection
|
||||
- Returns ICA account details and status
|
||||
- Shows linked features and capabilities
|
||||
{{else if eq .MethodDescriptorProto.Name "Accounts"}}
|
||||
- Lists all DEX accounts for a given DID
|
||||
- Supports pagination for large result sets
|
||||
- Returns accounts across all connected chains
|
||||
{{else if eq .MethodDescriptorProto.Name "Balance"}}
|
||||
- Queries balance on remote chain through ICA
|
||||
- Can filter by specific denomination
|
||||
- Returns real-time balance information
|
||||
{{else if eq .MethodDescriptorProto.Name "Pool"}}
|
||||
- Retrieves detailed pool information
|
||||
- Shows current liquidity and swap fees
|
||||
- Returns asset composition and total shares
|
||||
{{else if eq .MethodDescriptorProto.Name "Orders"}}
|
||||
- Lists orders for a specific DID and connection
|
||||
- Supports filtering by order status
|
||||
- Returns paginated order history
|
||||
{{else if eq .MethodDescriptorProto.Name "History"}}
|
||||
- Provides transaction history across all DEX operations
|
||||
- Supports filtering by connection and operation type
|
||||
- Returns detailed transaction records with timestamps
|
||||
{{end}}
|
||||
|
||||
## Usage Examples
|
||||
|
||||
```bash
|
||||
# Query module parameters
|
||||
snrd query dex params
|
||||
|
||||
# Get specific DEX account
|
||||
snrd query dex account did:sonr:123 connection-0
|
||||
|
||||
# Check balance on remote chain
|
||||
snrd query dex balance did:sonr:123 connection-0 --denom uatom
|
||||
|
||||
# Query pool information
|
||||
snrd query dex pool connection-0 pool-1
|
||||
|
||||
# List orders
|
||||
snrd query dex orders did:sonr:123 connection-0
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
## Overview
|
||||
The DEX module enables decentralized exchange operations across multiple chains via IBC (Inter-Blockchain Communication).
|
||||
|
||||
## Request: {{.RequestType.Name}}
|
||||
|
||||
| Field ID | Name | Type | Description |
|
||||
| -------- | ---- | ---- | ----------- | {{range .RequestType.Fields}}
|
||||
| {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}
|
||||
|
||||
## Response: {{.ResponseType.Name}}
|
||||
|
||||
| Field ID | Name | Type | Description |
|
||||
| -------- | ---- | ---- | ----------- | {{range .ResponseType.Fields}}
|
||||
| {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
{{if eq .MethodDescriptorProto.Name "RegisterDEXAccount"}}
|
||||
- Creates an ICA (Interchain Account) for DEX operations on remote chains
|
||||
- Establishes secure cross-chain communication channels
|
||||
- Supports configurable feature sets for different DEX capabilities
|
||||
{{else if eq .MethodDescriptorProto.Name "ExecuteSwap"}}
|
||||
- Performs atomic token swaps on remote DEX platforms
|
||||
- Includes slippage protection via minimum output amount
|
||||
- Supports custom routing for optimal price execution
|
||||
- UCAN token authorization ensures secure delegation
|
||||
{{else if eq .MethodDescriptorProto.Name "ProvideLiquidity"}}
|
||||
- Adds liquidity to AMM (Automated Market Maker) pools
|
||||
- Returns LP (Liquidity Provider) tokens as proof of deposit
|
||||
- Protects against slippage during liquidity provision
|
||||
{{else if eq .MethodDescriptorProto.Name "RemoveLiquidity"}}
|
||||
- Withdraws liquidity from pools using LP tokens
|
||||
- Ensures minimum asset amounts to protect against losses
|
||||
- Supports partial and full liquidity removal
|
||||
{{else if eq .MethodDescriptorProto.Name "CreateLimitOrder"}}
|
||||
- Places limit orders on remote orderbook DEXs
|
||||
- Supports time-based expiration for orders
|
||||
- Automatically executes when price conditions are met
|
||||
{{else if eq .MethodDescriptorProto.Name "CancelOrder"}}
|
||||
- Cancels pending limit orders before execution
|
||||
- Returns unfilled assets to user's account
|
||||
- Requires proper authorization via UCAN token
|
||||
{{end}}
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- All operations require UCAN authorization tokens for delegation
|
||||
- IBC packet timeouts prevent stuck transactions
|
||||
- Connection IDs must reference valid, established IBC channels
|
||||
- DID-based authentication ensures identity verification
|
||||
@@ -0,0 +1,179 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.v1;
|
||||
|
||||
option go_package = "github.com/sonr-io/sonr/x/dex/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// EventDEXAccountRegistered is emitted when a new DEX account is registered
|
||||
message EventDEXAccountRegistered {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Generated port ID
|
||||
string port_id = 3;
|
||||
|
||||
// Remote account address (when available)
|
||||
string account_address = 4;
|
||||
}
|
||||
|
||||
// EventSwapExecuted is emitted when a swap is executed
|
||||
message EventSwapExecuted {
|
||||
// DID of the trader
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Source token and amount
|
||||
cosmos.base.v1beta1.Coin source = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
// Target token and amount received
|
||||
cosmos.base.v1beta1.Coin target = 4 [(gogoproto.nullable) = false];
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 5;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 6;
|
||||
}
|
||||
|
||||
// EventLiquidityProvided is emitted when liquidity is added
|
||||
message EventLiquidityProvided {
|
||||
// DID of the liquidity provider
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Pool ID
|
||||
string pool_id = 3;
|
||||
|
||||
// Assets provided
|
||||
repeated cosmos.base.v1beta1.Coin assets = 4
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// Shares received
|
||||
string shares_received = 5;
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 6;
|
||||
}
|
||||
|
||||
// EventLiquidityRemoved is emitted when liquidity is removed
|
||||
message EventLiquidityRemoved {
|
||||
// DID of the liquidity provider
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Pool ID
|
||||
string pool_id = 3;
|
||||
|
||||
// Shares removed
|
||||
string shares_removed = 4;
|
||||
|
||||
// Assets received
|
||||
repeated cosmos.base.v1beta1.Coin assets = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 6;
|
||||
}
|
||||
|
||||
// EventOrderCreated is emitted when a limit order is created
|
||||
message EventOrderCreated {
|
||||
// DID of the trader
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Order ID on remote chain
|
||||
string order_id = 3;
|
||||
|
||||
// Order details
|
||||
string sell_denom = 4;
|
||||
string buy_denom = 5;
|
||||
string amount = 6;
|
||||
string price = 7;
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 8;
|
||||
}
|
||||
|
||||
// EventOrderCancelled is emitted when an order is cancelled
|
||||
message EventOrderCancelled {
|
||||
// DID of the trader
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Order ID that was cancelled
|
||||
string order_id = 3;
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 4;
|
||||
}
|
||||
|
||||
// EventOrderFilled is emitted when an order is filled
|
||||
message EventOrderFilled {
|
||||
// DID of the trader
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Order ID that was filled
|
||||
string order_id = 3;
|
||||
|
||||
// Fill details
|
||||
string fill_amount = 4;
|
||||
string fill_price = 5;
|
||||
|
||||
// Transaction hash on remote chain
|
||||
string tx_hash = 6;
|
||||
}
|
||||
|
||||
// EventICAPacketSent is emitted when an ICA packet is sent
|
||||
message EventICAPacketSent {
|
||||
// DID of the sender
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Packet type (swap, liquidity, order, etc.)
|
||||
string packet_type = 3;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 4;
|
||||
}
|
||||
|
||||
// EventICAPacketAcknowledged is emitted when an ICA packet is acknowledged
|
||||
message EventICAPacketAcknowledged {
|
||||
// DID of the sender
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Packet type
|
||||
string packet_type = 3;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 4;
|
||||
|
||||
// Success status
|
||||
bool success = 5;
|
||||
|
||||
// Error message if failed
|
||||
string error = 6;
|
||||
}
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.v1;
|
||||
|
||||
option go_package = "github.com/sonr-io/sonr/x/dex/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "dex/v1/ica.proto";
|
||||
|
||||
// GenesisState defines the DEX module's genesis state
|
||||
message GenesisState {
|
||||
// Module parameters
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
|
||||
// IBC port ID for the module
|
||||
string port_id = 2;
|
||||
|
||||
// Registered DEX accounts
|
||||
repeated InterchainDEXAccount accounts = 3;
|
||||
|
||||
// Account sequence counter
|
||||
uint64 account_sequence = 4;
|
||||
}
|
||||
|
||||
// Params defines the parameters for the DEX module
|
||||
message Params {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Enable/disable the module
|
||||
bool enabled = 1;
|
||||
|
||||
// Maximum accounts per DID
|
||||
uint32 max_accounts_per_did = 2;
|
||||
|
||||
// Default timeout for ICA operations (in seconds)
|
||||
uint64 default_timeout_seconds = 3;
|
||||
|
||||
// Allowed DEX connections
|
||||
repeated string allowed_connections = 4;
|
||||
|
||||
// Minimum swap amount (in base denom)
|
||||
string min_swap_amount = 5;
|
||||
|
||||
// Maximum daily volume per DID (in USD equivalent)
|
||||
string max_daily_volume = 6;
|
||||
|
||||
// Rate limit parameters
|
||||
RateLimitParams rate_limits = 7 [(gogoproto.nullable) = false];
|
||||
|
||||
// Fee parameters
|
||||
FeeParams fees = 8 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// RateLimitParams defines rate limiting parameters
|
||||
message RateLimitParams {
|
||||
// Maximum operations per block
|
||||
uint32 max_ops_per_block = 1;
|
||||
|
||||
// Maximum operations per DID per day
|
||||
uint32 max_ops_per_did_per_day = 2;
|
||||
|
||||
// Cooldown period between operations (in blocks)
|
||||
uint32 cooldown_blocks = 3;
|
||||
}
|
||||
|
||||
// FeeParams defines fee parameters for DEX operations
|
||||
message FeeParams {
|
||||
// Platform fee for swaps (basis points, e.g., 30 = 0.3%)
|
||||
uint32 swap_fee_bps = 1;
|
||||
|
||||
// Platform fee for liquidity operations
|
||||
uint32 liquidity_fee_bps = 2;
|
||||
|
||||
// Platform fee for orders
|
||||
uint32 order_fee_bps = 3;
|
||||
|
||||
// Fee collector address
|
||||
string fee_collector = 4;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.v1;
|
||||
|
||||
option go_package = "github.com/sonr-io/sonr/x/dex/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// InterchainDEXAccount represents a DEX account on a remote chain
|
||||
message InterchainDEXAccount {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID controller of this account
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to the remote chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Remote chain ID (e.g., osmosis-1)
|
||||
string host_chain_id = 3;
|
||||
|
||||
// Account address on the remote chain
|
||||
string account_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// ICA port ID for this account
|
||||
string port_id = 5;
|
||||
|
||||
// Account creation timestamp
|
||||
google.protobuf.Timestamp created_at = 6
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
|
||||
// Enabled features for this account
|
||||
repeated string enabled_features = 7;
|
||||
|
||||
// Account status
|
||||
AccountStatus status = 8;
|
||||
}
|
||||
|
||||
// AccountStatus defines the status of an ICA account
|
||||
enum AccountStatus {
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
// Account is pending creation
|
||||
ACCOUNT_STATUS_PENDING = 0;
|
||||
|
||||
// Account is active and ready
|
||||
ACCOUNT_STATUS_ACTIVE = 1;
|
||||
|
||||
// Account is temporarily disabled
|
||||
ACCOUNT_STATUS_DISABLED = 2;
|
||||
|
||||
// Account creation failed
|
||||
ACCOUNT_STATUS_FAILED = 3;
|
||||
}
|
||||
|
||||
// DEXFeatures defines available features for DEX accounts
|
||||
enum DEXFeatures {
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
// Basic swap functionality
|
||||
DEX_FEATURE_SWAP = 0;
|
||||
|
||||
// Liquidity provision
|
||||
DEX_FEATURE_LIQUIDITY = 1;
|
||||
|
||||
// Limit orders
|
||||
DEX_FEATURE_ORDERS = 2;
|
||||
|
||||
// Staking operations
|
||||
DEX_FEATURE_STAKING = 3;
|
||||
|
||||
// Governance participation
|
||||
DEX_FEATURE_GOVERNANCE = 4;
|
||||
}
|
||||
|
||||
// DEXActivity represents a DEX operation activity record
|
||||
message DEXActivity {
|
||||
// Type of activity (swap, provide_liquidity, remove_liquidity, create_order, cancel_order)
|
||||
string type = 1;
|
||||
|
||||
// DID that performed the activity
|
||||
string did = 2;
|
||||
|
||||
// Connection ID where the activity occurred
|
||||
string connection_id = 3;
|
||||
|
||||
// Transaction hash of the activity
|
||||
string tx_hash = 4;
|
||||
|
||||
// Block height when the activity occurred
|
||||
int64 block_height = 5;
|
||||
|
||||
// Timestamp of the activity
|
||||
google.protobuf.Timestamp timestamp = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
|
||||
// Activity-specific details (JSON encoded)
|
||||
string details = 7;
|
||||
|
||||
// Status of the activity (pending, success, failed)
|
||||
string status = 8;
|
||||
|
||||
// Amount involved in the activity (if applicable)
|
||||
repeated cosmos.base.v1beta1.Coin amount = 9 [
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Gas used for the activity
|
||||
uint64 gas_used = 10;
|
||||
}
|
||||
Executable
+273
@@ -0,0 +1,273 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.v1;
|
||||
|
||||
option go_package = "github.com/sonr-io/sonr/x/dex/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
import "dex/v1/genesis.proto";
|
||||
import "dex/v1/ica.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
|
||||
// Query defines the DEX Query service
|
||||
service Query {
|
||||
// Params queries the parameters of the module
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/params";
|
||||
}
|
||||
|
||||
// Account queries a DEX account by DID and connection
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Account(QueryAccountRequest) returns (QueryAccountResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/account/{did}/{connection_id}";
|
||||
}
|
||||
|
||||
// Accounts queries all DEX accounts for a DID
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/accounts/{did}";
|
||||
}
|
||||
|
||||
// Balance queries remote chain balance
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/balance/{did}/{connection_id}";
|
||||
}
|
||||
|
||||
// Pool queries pool information
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/pool/{connection_id}/{pool_id}";
|
||||
}
|
||||
|
||||
// Orders queries orders for a DID
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc Orders(QueryOrdersRequest) returns (QueryOrdersResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/orders/{did}/{connection_id}";
|
||||
}
|
||||
|
||||
// History queries transaction history
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_query_docs.md"}}
|
||||
rpc History(QueryHistoryRequest) returns (QueryHistoryResponse) {
|
||||
option (google.api.http).get = "/sonr/dex/v1/history/{did}";
|
||||
}
|
||||
}
|
||||
|
||||
// QueryParamsRequest is request type for Query/Params RPC method
|
||||
message QueryParamsRequest {}
|
||||
|
||||
// QueryParamsResponse is response type for Query/Params RPC method
|
||||
message QueryParamsResponse {
|
||||
// params holds all the parameters of this module
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// QueryAccountRequest is request type for Query/Account RPC method
|
||||
message QueryAccountRequest {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
}
|
||||
|
||||
// QueryAccountResponse is response type for Query/Account RPC method
|
||||
message QueryAccountResponse {
|
||||
// The DEX account
|
||||
InterchainDEXAccount account = 1;
|
||||
}
|
||||
|
||||
// QueryAccountsRequest is request type for Query/Accounts RPC method
|
||||
message QueryAccountsRequest {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// pagination defines optional pagination
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 2;
|
||||
}
|
||||
|
||||
// QueryAccountsResponse is response type for Query/Accounts RPC method
|
||||
message QueryAccountsResponse {
|
||||
// List of DEX accounts
|
||||
repeated InterchainDEXAccount accounts = 1;
|
||||
|
||||
// pagination defines the pagination in the response
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryBalanceRequest is request type for Query/Balance RPC method
|
||||
message QueryBalanceRequest {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Optional specific denom to query
|
||||
string denom = 3;
|
||||
}
|
||||
|
||||
// QueryBalanceResponse is response type for Query/Balance RPC method
|
||||
message QueryBalanceResponse {
|
||||
// Balances on the remote chain
|
||||
repeated cosmos.base.v1beta1.Coin balances = 1
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// QueryPoolRequest is request type for Query/Pool RPC method
|
||||
message QueryPoolRequest {
|
||||
// IBC connection ID
|
||||
string connection_id = 1;
|
||||
|
||||
// Pool ID to query
|
||||
string pool_id = 2;
|
||||
}
|
||||
|
||||
// QueryPoolResponse is response type for Query/Pool RPC method
|
||||
message QueryPoolResponse {
|
||||
// Pool information
|
||||
PoolInfo pool = 1;
|
||||
}
|
||||
|
||||
// PoolInfo contains pool information
|
||||
message PoolInfo {
|
||||
// Pool ID
|
||||
string pool_id = 1;
|
||||
|
||||
// Pool assets
|
||||
repeated cosmos.base.v1beta1.Coin assets = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// Total shares
|
||||
string total_shares = 3;
|
||||
|
||||
// Swap fee
|
||||
string swap_fee = 4;
|
||||
}
|
||||
|
||||
// QueryOrdersRequest is request type for Query/Orders RPC method
|
||||
message QueryOrdersRequest {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// IBC connection ID
|
||||
string connection_id = 2;
|
||||
|
||||
// Filter by status (optional)
|
||||
string status = 3;
|
||||
|
||||
// pagination defines optional pagination
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 4;
|
||||
}
|
||||
|
||||
// QueryOrdersResponse is response type for Query/Orders RPC method
|
||||
message QueryOrdersResponse {
|
||||
// List of orders
|
||||
repeated Order orders = 1;
|
||||
|
||||
// pagination defines the pagination in the response
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// Order represents a DEX order
|
||||
message Order {
|
||||
// Order ID
|
||||
string order_id = 1;
|
||||
|
||||
// Order type
|
||||
string order_type = 2;
|
||||
|
||||
// Sell token
|
||||
string sell_denom = 3;
|
||||
|
||||
// Buy token
|
||||
string buy_denom = 4;
|
||||
|
||||
// Amount
|
||||
string amount = 5;
|
||||
|
||||
// Price
|
||||
string price = 6;
|
||||
|
||||
// Status
|
||||
string status = 7;
|
||||
|
||||
// Creation time
|
||||
string created_at = 8;
|
||||
}
|
||||
|
||||
// QueryHistoryRequest is request type for Query/History RPC method
|
||||
message QueryHistoryRequest {
|
||||
// DID of the account owner
|
||||
string did = 1;
|
||||
|
||||
// Optional connection filter
|
||||
string connection_id = 2;
|
||||
|
||||
// Optional operation type filter
|
||||
string operation_type = 3;
|
||||
|
||||
// pagination defines optional pagination
|
||||
cosmos.base.query.v1beta1.PageRequest pagination = 4;
|
||||
}
|
||||
|
||||
// QueryHistoryResponse is response type for Query/History RPC method
|
||||
message QueryHistoryResponse {
|
||||
// List of historical transactions
|
||||
repeated Transaction transactions = 1;
|
||||
|
||||
// pagination defines the pagination in the response
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// Transaction represents a historical transaction
|
||||
message Transaction {
|
||||
// Transaction ID
|
||||
string tx_id = 1;
|
||||
|
||||
// Operation type (swap, provide_liquidity, etc.)
|
||||
string operation_type = 2;
|
||||
|
||||
// Connection ID
|
||||
string connection_id = 3;
|
||||
|
||||
// Transaction details (JSON)
|
||||
string details = 4;
|
||||
|
||||
// Status
|
||||
string status = 5;
|
||||
|
||||
// Timestamp
|
||||
string timestamp = 6;
|
||||
}
|
||||
Executable
+326
@@ -0,0 +1,326 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package dex.v1;
|
||||
|
||||
option go_package = "github.com/sonr-io/sonr/x/dex/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/msg/v1/msg.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
// Msg defines the DEX Msg service
|
||||
service Msg {
|
||||
option (cosmos.msg.v1.service) = true;
|
||||
|
||||
// RegisterDEXAccount creates a new ICA account for DEX operations
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc RegisterDEXAccount(MsgRegisterDEXAccount) returns (MsgRegisterDEXAccountResponse);
|
||||
|
||||
// ExecuteSwap performs a token swap on a remote chain
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc ExecuteSwap(MsgExecuteSwap) returns (MsgExecuteSwapResponse);
|
||||
|
||||
// ProvideLiquidity adds liquidity to a pool
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc ProvideLiquidity(MsgProvideLiquidity) returns (MsgProvideLiquidityResponse);
|
||||
|
||||
// RemoveLiquidity removes liquidity from a pool
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc RemoveLiquidity(MsgRemoveLiquidity) returns (MsgRemoveLiquidityResponse);
|
||||
|
||||
// CreateLimitOrder creates a limit order
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc CreateLimitOrder(MsgCreateLimitOrder) returns (MsgCreateLimitOrderResponse);
|
||||
|
||||
// CancelOrder cancels an existing order
|
||||
//
|
||||
// {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
|
||||
// It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
|
||||
//
|
||||
// {{import "dex_tx_docs.md"}}
|
||||
rpc CancelOrder(MsgCancelOrder) returns (MsgCancelOrderResponse);
|
||||
}
|
||||
|
||||
// MsgRegisterDEXAccount registers a new ICA account for DEX operations
|
||||
message MsgRegisterDEXAccount {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID controller requesting the account
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to target chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Requested features for this account
|
||||
repeated string features = 3;
|
||||
|
||||
// Optional metadata
|
||||
string metadata = 4;
|
||||
}
|
||||
|
||||
// MsgRegisterDEXAccountResponse defines the response
|
||||
message MsgRegisterDEXAccountResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Generated port ID for the account
|
||||
string port_id = 1;
|
||||
|
||||
// Account address on remote chain (once available)
|
||||
string account_address = 2;
|
||||
}
|
||||
|
||||
// MsgExecuteSwap executes a token swap on a remote chain
|
||||
message MsgExecuteSwap {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID initiating the swap
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to DEX chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Token to swap from
|
||||
string source_denom = 3;
|
||||
|
||||
// Token to swap to
|
||||
string target_denom = 4;
|
||||
|
||||
// Amount to swap
|
||||
string amount = 5 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Minimum amount out (slippage protection)
|
||||
string min_amount_out = 6 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Optional specific route
|
||||
string route = 7;
|
||||
|
||||
// UCAN authorization token
|
||||
string ucan_token = 8;
|
||||
|
||||
// Timeout for the swap
|
||||
google.protobuf.Timestamp timeout = 9
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
}
|
||||
|
||||
// MsgExecuteSwapResponse defines the response
|
||||
message MsgExecuteSwapResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Transaction ID on remote chain
|
||||
string tx_hash = 1;
|
||||
|
||||
// Actual amount received
|
||||
string amount_received = 2;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// MsgProvideLiquidity adds liquidity to a pool
|
||||
message MsgProvideLiquidity {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID providing liquidity
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to DEX chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Pool ID to add liquidity to
|
||||
string pool_id = 3;
|
||||
|
||||
// Assets to provide
|
||||
repeated cosmos.base.v1beta1.Coin assets = 4
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// Minimum shares to receive (slippage protection)
|
||||
string min_shares = 5 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// UCAN authorization token
|
||||
string ucan_token = 6;
|
||||
|
||||
// Timeout for the operation
|
||||
google.protobuf.Timestamp timeout = 7
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
}
|
||||
|
||||
// MsgProvideLiquidityResponse defines the response
|
||||
message MsgProvideLiquidityResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Transaction ID on remote chain
|
||||
string tx_hash = 1;
|
||||
|
||||
// LP tokens received
|
||||
string shares_received = 2;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// MsgRemoveLiquidity removes liquidity from a pool
|
||||
message MsgRemoveLiquidity {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID removing liquidity
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to DEX chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Pool ID to remove liquidity from
|
||||
string pool_id = 3;
|
||||
|
||||
// Amount of shares to remove
|
||||
string shares = 4 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Minimum assets to receive
|
||||
repeated cosmos.base.v1beta1.Coin min_amounts = 5
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// UCAN authorization token
|
||||
string ucan_token = 6;
|
||||
|
||||
// Timeout for the operation
|
||||
google.protobuf.Timestamp timeout = 7
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
}
|
||||
|
||||
// MsgRemoveLiquidityResponse defines the response
|
||||
message MsgRemoveLiquidityResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Transaction ID on remote chain
|
||||
string tx_hash = 1;
|
||||
|
||||
// Assets received
|
||||
repeated cosmos.base.v1beta1.Coin assets_received = 2
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// MsgCreateLimitOrder creates a limit order
|
||||
message MsgCreateLimitOrder {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID creating the order
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to DEX chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Token to sell
|
||||
string sell_denom = 3;
|
||||
|
||||
// Token to buy
|
||||
string buy_denom = 4;
|
||||
|
||||
// Amount to sell
|
||||
string amount = 5 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.Int",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Price per unit
|
||||
string price = 6 [
|
||||
(cosmos_proto.scalar) = "cosmos.Dec",
|
||||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
|
||||
// Order expiration
|
||||
google.protobuf.Timestamp expiration = 7
|
||||
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
|
||||
// UCAN authorization token
|
||||
string ucan_token = 8;
|
||||
}
|
||||
|
||||
// MsgCreateLimitOrderResponse defines the response
|
||||
message MsgCreateLimitOrderResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Order ID on remote chain
|
||||
string order_id = 1;
|
||||
|
||||
// Transaction ID
|
||||
string tx_hash = 2;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// MsgCancelOrder cancels an existing order
|
||||
message MsgCancelOrder {
|
||||
option (cosmos.msg.v1.signer) = "did";
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// DID canceling the order
|
||||
string did = 1;
|
||||
|
||||
// IBC connection to DEX chain
|
||||
string connection_id = 2;
|
||||
|
||||
// Order ID to cancel
|
||||
string order_id = 3;
|
||||
|
||||
// UCAN authorization token
|
||||
string ucan_token = 4;
|
||||
}
|
||||
|
||||
// MsgCancelOrderResponse defines the response
|
||||
message MsgCancelOrderResponse {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// Transaction ID
|
||||
string tx_hash = 1;
|
||||
|
||||
// IBC packet sequence
|
||||
uint64 sequence = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user