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: initialize fswap module #1336

Merged
merged 17 commits into from
Apr 18, 2024
284 changes: 284 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,31 @@

- [Msg](#lbm.foundation.v1.Msg)

- [lbm/fswap/v1/event.proto](#lbm/fswap/v1/event.proto)
- [EventSwapCoins](#lbm.fswap.v1.EventSwapCoins)

- [lbm/fswap/v1/params.proto](#lbm/fswap/v1/params.proto)
- [Params](#lbm.fswap.v1.Params)

- [lbm/fswap/v1/genesis.proto](#lbm/fswap/v1/genesis.proto)
- [GenesisState](#lbm.fswap.v1.GenesisState)

- [lbm/fswap/v1/query.proto](#lbm/fswap/v1/query.proto)
- [QuerySwappedRequest](#lbm.fswap.v1.QuerySwappedRequest)
- [QuerySwappedResponse](#lbm.fswap.v1.QuerySwappedResponse)
- [QueryTotalSwappableAmountRequest](#lbm.fswap.v1.QueryTotalSwappableAmountRequest)
- [QueryTotalSwappableAmountResponse](#lbm.fswap.v1.QueryTotalSwappableAmountResponse)

- [Query](#lbm.fswap.v1.Query)

- [lbm/fswap/v1/tx.proto](#lbm/fswap/v1/tx.proto)
- [MsgSwapAllRequest](#lbm.fswap.v1.MsgSwapAllRequest)
- [MsgSwapAllResponse](#lbm.fswap.v1.MsgSwapAllResponse)
- [MsgSwapRequest](#lbm.fswap.v1.MsgSwapRequest)
- [MsgSwapResponse](#lbm.fswap.v1.MsgSwapResponse)

- [Msg](#lbm.fswap.v1.Msg)

- [lbm/stakingplus/v1/authz.proto](#lbm/stakingplus/v1/authz.proto)
- [CreateValidatorAuthorization](#lbm.stakingplus.v1.CreateValidatorAuthorization)

Expand Down Expand Up @@ -12683,6 +12708,265 @@ Msg defines the foundation Msg service.



<a name="lbm/fswap/v1/event.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lbm/fswap/v1/event.proto



<a name="lbm.fswap.v1.EventSwapCoins"></a>

### EventSwapCoins



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | holder's address |
| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the old currency |
| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the new currency |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lbm/fswap/v1/params.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lbm/fswap/v1/params.proto



<a name="lbm.fswap.v1.Params"></a>

### Params
Params defines the parameters for the module.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `new_coin_swap_total_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | upper limit in new coin that this module can swap |
| `swap_rate` | [uint64](#uint64) | | constant value representing the exchange rate, without decimal (148079656) |
| `swap_rate_decimals` | [int32](#int32) | | The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power |
| `new_coin_denom` | [string](#string) | | new denomination for new coin after swap |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lbm/fswap/v1/genesis.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lbm/fswap/v1/genesis.proto



<a name="lbm.fswap.v1.GenesisState"></a>

### GenesisState
GenesisState defines the fswap module's genesis state.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#lbm.fswap.v1.Params) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="lbm/fswap/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lbm/fswap/v1/query.proto



<a name="lbm.fswap.v1.QuerySwappedRequest"></a>

### QuerySwappedRequest







<a name="lbm.fswap.v1.QuerySwappedResponse"></a>

### QuerySwappedResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |






<a name="lbm.fswap.v1.QueryTotalSwappableAmountRequest"></a>

### QueryTotalSwappableAmountRequest







<a name="lbm.fswap.v1.QueryTotalSwappableAmountResponse"></a>

### QueryTotalSwappableAmountResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `swappable_new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="lbm.fswap.v1.Query"></a>

### Query


| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Swapped` | [QuerySwappedRequest](#lbm.fswap.v1.QuerySwappedRequest) | [QuerySwappedResponse](#lbm.fswap.v1.QuerySwappedResponse) | | GET|/lbm/fswap/v1/swapped|
| `TotalNewCurrencySwapLimit` | [QueryTotalSwappableAmountRequest](#lbm.fswap.v1.QueryTotalSwappableAmountRequest) | [QueryTotalSwappableAmountResponse](#lbm.fswap.v1.QueryTotalSwappableAmountResponse) | | GET|/lbm/fswap/v1/swappable_new_coin_amount|

<!-- end services -->



<a name="lbm/fswap/v1/tx.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## lbm/fswap/v1/tx.proto



<a name="lbm.fswap.v1.MsgSwapAllRequest"></a>

### MsgSwapAllRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | holder's address |






<a name="lbm.fswap.v1.MsgSwapAllResponse"></a>

### MsgSwapAllResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of swapped in new currency |






<a name="lbm.fswap.v1.MsgSwapRequest"></a>

### MsgSwapRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | holder's address |
| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of old currency |






<a name="lbm.fswap.v1.MsgSwapResponse"></a>

### MsgSwapResponse






<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="lbm.fswap.v1.Msg"></a>

### Msg


| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Swap` | [MsgSwapRequest](#lbm.fswap.v1.MsgSwapRequest) | [MsgSwapResponse](#lbm.fswap.v1.MsgSwapResponse) | | |
| `SwapAll` | [MsgSwapAllRequest](#lbm.fswap.v1.MsgSwapAllRequest) | [MsgSwapAllResponse](#lbm.fswap.v1.MsgSwapAllResponse) | | |

<!-- end services -->



<a name="lbm/stakingplus/v1/authz.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y=
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps=
github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA=
github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
Expand Down
18 changes: 18 additions & 0 deletions proto/lbm/fswap/v1/event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package lbm.fswap.v1;

option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";
jaeseung-bae marked this conversation as resolved.
Show resolved Hide resolved

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

message EventSwapCoins {
// holder's address
string address = 1;
// amount of the old currency
cosmos.base.v1beta1.Coin old_coin_amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
// amount of the new currency
cosmos.base.v1beta1.Coin new_coin_amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
}
12 changes: 12 additions & 0 deletions proto/lbm/fswap/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package lbm.fswap.v1;

option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";
jaeseung-bae marked this conversation as resolved.
Show resolved Hide resolved

import "gogoproto/gogo.proto";
import "lbm/fswap/v1/params.proto";

// GenesisState defines the fswap module's genesis state.
message GenesisState {
170210 marked this conversation as resolved.
Show resolved Hide resolved
Params params = 1 [(gogoproto.nullable) = false];
}
22 changes: 22 additions & 0 deletions proto/lbm/fswap/v1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

syntax = "proto3";
package lbm.fswap.v1;

option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";
jaeseung-bae marked this conversation as resolved.
Show resolved Hide resolved

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

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;
// upper limit in new coin that this module can swap
cosmos.base.v1beta1.Coin new_coin_swap_total_limit = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
// constant value representing the exchange rate, without decimal (148079656)
uint64 swap_rate = 2;
170210 marked this conversation as resolved.
Show resolved Hide resolved
// The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power
int32 swap_rate_decimals = 3;
170210 marked this conversation as resolved.
Show resolved Hide resolved
// new denomination for new coin after swap
string new_coin_denom = 4;
}
170210 marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 31 additions & 0 deletions proto/lbm/fswap/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
syntax = "proto3";
package lbm.fswap.v1;

option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";
jaeseung-bae marked this conversation as resolved.
Show resolved Hide resolved

import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

service Query {
rpc Swapped(QuerySwappedRequest) returns (QuerySwappedResponse) {
option (google.api.http).get = "/lbm/fswap/v1/swapped";
}
rpc TotalNewCurrencySwapLimit(QueryTotalSwappableAmountRequest) returns (QueryTotalSwappableAmountResponse) {
option (google.api.http).get = "/lbm/fswap/v1/swappable_new_coin_amount";
}
}

message QuerySwappedRequest {}
message QuerySwappedResponse {
cosmos.base.v1beta1.Coin old_coin_amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
cosmos.base.v1beta1.Coin new_coin_amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
}

message QueryTotalSwappableAmountRequest {}
message QueryTotalSwappableAmountResponse {
cosmos.base.v1beta1.Coin swappable_new_coin_amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
}
Loading
Loading