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: fswap module's basic functionality(MsgSwap, MsgSwapAll, Query, Proposal) #1345

Merged
merged 49 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c4ff578
refactor: fswap module's proto
170210 Apr 26, 2024
93a97a6
refactor: remove config&params and modify genesis
170210 Apr 26, 2024
5a8dd65
refactor: use gov/proposal to change fswapInit
170210 Apr 26, 2024
df7355d
chore: fix simulation
170210 Apr 26, 2024
4c8a928
chore: correct query cli
170210 Apr 26, 2024
015c224
chore: add query for test
170210 Apr 26, 2024
4701f3e
chore: lint fix
jaeseung-bae Apr 26, 2024
a139b67
chore: fix for tx cli
jaeseung-bae Apr 28, 2024
60d0112
chore: update proto
jaeseung-bae Apr 29, 2024
f1e6811
chore: update genesis logic
jaeseung-bae Apr 29, 2024
427da10
chore: add basic tx and queries
jaeseung-bae Apr 30, 2024
9b26d2f
chore: rename fswap to swap
jaeseung-bae Apr 30, 2024
6aecac6
chore: change old/new to from/to
jaeseung-bae Apr 30, 2024
5195f88
chore: clean-up
jaeseung-bae Apr 30, 2024
6151a0c
chore: clean errors and rename
jaeseung-bae Apr 30, 2024
be5f723
chore: update proto
jaeseung-bae Apr 30, 2024
e2ac84c
chore: clean unnecessary member variables
jaeseung-bae Apr 30, 2024
8b1afaf
chore: update proto, introduce config, clean code
jaeseung-bae May 2, 2024
edc1df6
chore: remove redundant denom validation
jaeseung-bae May 2, 2024
f59a2c3
chore: remove cache-like operation, rename swap proposal in proto, er…
jaeseung-bae May 2, 2024
8e3e634
chore: apply feedbacks
jaeseung-bae May 2, 2024
17eeffd
chore: fix some
jaeseung-bae May 2, 2024
cb736ad
chore: fix for initGenesis
jaeseung-bae May 2, 2024
f48ffbc
chore: apply feedbacks
jaeseung-bae May 2, 2024
ea9c027
Merge remote-tracking branch 'origin/pjdp1' into fswap_refactor
jaeseung-bae May 2, 2024
44caeee
chore: update changelog
jaeseung-bae May 2, 2024
15ed1c9
chore: remove redundant logic
jaeseung-bae May 2, 2024
607d94a
chore: update error doc
jaeseung-bae May 2, 2024
a0ca4d3
chore: update proto and logic to accept bank.Metadata
jaeseung-bae May 2, 2024
0f5de19
chore: add query to get all the swaps
jaeseung-bae May 2, 2024
4847746
chore: change swap_multiple to swap_rate
jaeseung-bae May 2, 2024
badefa5
chore: disallow updating existing denom metadata with different values
jaeseung-bae May 2, 2024
1d1a0ce
chore: fix for calcSwap logic
jaeseung-bae May 3, 2024
c4996b3
chore: extract CalcSwap to function
jaeseung-bae May 3, 2024
4cdde22
chore: add missing query cmd
jaeseung-bae May 3, 2024
d00a3d1
chore: fix for proposal cli
jaeseung-bae May 3, 2024
47d684f
chore: fix for init timing
jaeseung-bae May 3, 2024
d15f3e5
chore: fix query cli
jaeseung-bae May 3, 2024
54cce5a
chore: fix to prevent generating swap more than MaxSwaps
jaeseung-bae May 3, 2024
c0950b6
fix: add missing call validateBasic for proposal
jaeseung-bae May 3, 2024
4b49115
fix:
jaeseung-bae May 3, 2024
7ef5b3f
chore: change error type for temporal test-pass
jaeseung-bae May 3, 2024
f3d7632
chore: fix for make-swap-proposal update
jaeseung-bae May 3, 2024
9854cf3
chore: fix to check swap count after increase in order not to make mo…
jaeseung-bae May 3, 2024
472d5b4
chore: prevent any proposal with different denom
jaeseung-bae May 3, 2024
3ac87ab
Merge remote-tracking branch 'origin/pjdp1' into fswap_refactor
jaeseung-bae May 3, 2024
70f9499
chore: change amount cap type
jaeseung-bae May 3, 2024
ebefc77
chore: fix codec-related parts
jaeseung-bae May 3, 2024
99f9193
chore: minor change for convert to-coin-amount-cap
jaeseung-bae May 3, 2024
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 @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/fswap) [\#1339](https://github.com/Finschia/finschia-sdk/pull/1339) Implement fswap module's genesis
* (x/fbridge) [\#1340](https://github.com/Finschia/finschia-sdk/pull/1340) Initialize fbridge module
* (x/fbridge) [\#1347](https://github.com/Finschia/finschia-sdk/pull/1347) Implement bridge transfer feature (sending side)
* (x/fswap) [\#1345](https://github.com/Finschia/finschia-sdk/pull/1345) Implement fswap's basic functionality(MsgSwap, MsgSwapAll, Query, Proposal)

### Improvements
* (docs) [\#1120](https://github.com/Finschia/finschia-sdk/pull/1120) Update links in x/foundation README.md
Expand Down
164 changes: 117 additions & 47 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,26 +941,28 @@
- [EventSwapCoins](#lbm.fswap.v1.EventSwapCoins)

- [lbm/fswap/v1/fswap.proto](#lbm/fswap/v1/fswap.proto)
- [MakeSwapProposal](#lbm.fswap.v1.MakeSwapProposal)
- [Swap](#lbm.fswap.v1.Swap)
- [SwapStats](#lbm.fswap.v1.SwapStats)
- [Swapped](#lbm.fswap.v1.Swapped)

- [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)
- [QuerySwapsRequest](#lbm.fswap.v1.QuerySwapsRequest)
- [QuerySwapsResponse](#lbm.fswap.v1.QuerySwapsResponse)
- [QueryTotalSwappableToCoinAmountRequest](#lbm.fswap.v1.QueryTotalSwappableToCoinAmountRequest)
- [QueryTotalSwappableToCoinAmountResponse](#lbm.fswap.v1.QueryTotalSwappableToCoinAmountResponse)

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

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

- [Msg](#lbm.fswap.v1.Msg)
Expand Down Expand Up @@ -13895,8 +13897,8 @@ Msg defines the foundation Msg service.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | holder's address |
| `old_coin` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the old currency |
| `new_coin` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the new currency |
| `from_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | from-coin amount |
| `to_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | to-coin amount |



Expand All @@ -13919,47 +13921,67 @@ Msg defines the foundation Msg service.



<a name="lbm.fswap.v1.Swapped"></a>
<a name="lbm.fswap.v1.MakeSwapProposal"></a>

### Swapped
### MakeSwapProposal
From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk based on 0.45.10


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | |
| `description` | [string](#string) | | |
| `swap` | [Swap](#lbm.fswap.v1.Swap) | | |
| `to_denom_metadata` | [cosmos.bank.v1beta1.Metadata](#cosmos.bank.v1beta1.Metadata) | | |






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

### Swap



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `old_coin_amount` | [string](#string) | | |
| `new_coin_amount` | [string](#string) | | |
| `from_denom` | [string](#string) | | |
| `to_denom` | [string](#string) | | |
| `amount_cap_for_to_denom` | [string](#string) | | |
| `swap_rate` | [string](#string) | | |





<!-- end messages -->

<!-- end enums -->
<a name="lbm.fswap.v1.SwapStats"></a>

<!-- end HasExtensions -->
### SwapStats

<!-- end services -->


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `swap_count` | [int32](#int32) | | |

<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.
<a name="lbm.fswap.v1.Swapped"></a>

### Swapped



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



Expand Down Expand Up @@ -13990,8 +14012,9 @@ GenesisState defines the fswap module's genesis state.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#lbm.fswap.v1.Params) | | |
| `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | | |
| `swaps` | [Swap](#lbm.fswap.v1.Swap) | repeated | |
| `swap_stats` | [SwapStats](#lbm.fswap.v1.SwapStats) | | |
| `swappeds` | [Swapped](#lbm.fswap.v1.Swapped) | repeated | |



Expand Down Expand Up @@ -14020,6 +14043,12 @@ GenesisState defines the fswap module's genesis state.



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fromDenom` | [string](#string) | | |
| `toDenom` | [string](#string) | | |





Expand All @@ -14032,33 +14061,70 @@ GenesisState defines the fswap module's genesis state.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `old_coin` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `new_coin` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `from_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `to_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |






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

### QuerySwapsRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | |






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

### QuerySwapsResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `swaps` | [Swap](#lbm.fswap.v1.Swap) | repeated | |
| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | |






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

### QueryTotalSwappableAmountRequest
### QueryTotalSwappableToCoinAmountRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fromDenom` | [string](#string) | | |
| `toDenom` | [string](#string) | | |





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

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

### QueryTotalSwappableToCoinAmountResponse



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



Expand All @@ -14078,8 +14144,9 @@ GenesisState defines the fswap module's genesis state.

| 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|
| `Swapped` | [QuerySwappedRequest](#lbm.fswap.v1.QuerySwappedRequest) | [QuerySwappedResponse](#lbm.fswap.v1.QuerySwappedResponse) | Swapped queries the current swapped status that includes a burnt amount of from-coin and a minted amount of to-coin. | GET|/lbm/fswap/v1/swapped|
| `TotalSwappableToCoinAmount` | [QueryTotalSwappableToCoinAmountRequest](#lbm.fswap.v1.QueryTotalSwappableToCoinAmountRequest) | [QueryTotalSwappableToCoinAmountResponse](#lbm.fswap.v1.QueryTotalSwappableToCoinAmountResponse) | TotalSwappableToCoinAmount queries the current swappable amount for to-coin. | GET|/lbm/fswap/v1/total_swappable_to_coin_amount|
| `Swaps` | [QuerySwapsRequest](#lbm.fswap.v1.QuerySwapsRequest) | [QuerySwapsResponse](#lbm.fswap.v1.QuerySwapsResponse) | Swaps queries all the swap that registered | GET|/lbm/fswap/v1/swaps|

<!-- end services -->

Expand All @@ -14092,41 +14159,44 @@ GenesisState defines the fswap module's genesis state.



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

### MsgSwapAllRequest
### MsgSwap



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `from_address` | [string](#string) | | holder's address |
| `from_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | from-coin amount |
| `to_denom` | [string](#string) | | |






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

### MsgSwapAllResponse
### MsgSwapAll



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




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

### MsgSwapRequest

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

### MsgSwapAllResponse

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



Expand Down Expand Up @@ -14156,8 +14226,8 @@ GenesisState defines the fswap module's genesis state.

| 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) | | |
| `Swap` | [MsgSwap](#lbm.fswap.v1.MsgSwap) | [MsgSwapResponse](#lbm.fswap.v1.MsgSwapResponse) | | |
| `SwapAll` | [MsgSwapAll](#lbm.fswap.v1.MsgSwapAll) | [MsgSwapAllResponse](#lbm.fswap.v1.MsgSwapAllResponse) | | |

<!-- end services -->

Expand Down
8 changes: 4 additions & 4 deletions proto/lbm/fswap/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ 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 = 2
// from-coin amount
cosmos.base.v1beta1.Coin from_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 = 3
// to-coin amount
cosmos.base.v1beta1.Coin to_coin_amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"];
}
40 changes: 37 additions & 3 deletions proto/lbm/fswap/v1/fswap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,43 @@ package lbm.fswap.v1;
option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";

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

message Swapped {
message Swap {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
string old_coin_amount = 1 [(gogoproto.customtype) = "github.com/Finschia/finschia-sdk/types.Int", (gogoproto.nullable) = false];
string new_coin_amount = 2 [(gogoproto.customtype) = "github.com/Finschia/finschia-sdk/types.Int", (gogoproto.nullable) = false];

string from_denom = 1;
string to_denom = 2;
string amount_cap_for_to_denom = 3
[(gogoproto.customtype) = "github.com/Finschia/finschia-sdk/types.Int", (gogoproto.nullable) = false];
string swap_rate = 4
[(gogoproto.customtype) = "github.com/Finschia/finschia-sdk/types.Dec", (gogoproto.nullable) = false];
}

message SwapStats {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

int32 swap_count = 1;
zemyblue marked this conversation as resolved.
Show resolved Hide resolved
}

// From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk based on 0.45.10
message MakeSwapProposal {
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;
Swap swap = 3 [(gogoproto.nullable) = false];
cosmos.bank.v1beta1.Metadata to_denom_metadata = 4
[(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false];
}

message Swapped {
option (gogoproto.goproto_stringer) = false;
cosmos.base.v1beta1.Coin from_coin_amount = 1
[(gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin", (gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin to_coin_amount = 2
[(gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin", (gogoproto.nullable) = false];
}
6 changes: 3 additions & 3 deletions proto/lbm/fswap/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types";

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

// GenesisState defines the fswap module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
Swapped swapped = 2 [(gogoproto.nullable) = false];
repeated Swap swaps = 1 [(gogoproto.nullable) = false];
SwapStats swap_stats = 2 [(gogoproto.nullable) = false];
repeated Swapped swappeds = 3 [(gogoproto.nullable) = false];
}
Loading
Loading