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: support multiple coins for funding #179

Merged
merged 31 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fd52592
chore: started implementation of funding with multiple coins
troykessler Apr 26, 2024
75d80f0
chore: further implemented sdk.Coins
troykessler Apr 29, 2024
bd272c9
chore: finished logic with funding a single coin
troykessler Apr 29, 2024
8941a06
chore: finished multiple coins implementation for x/funders
troykessler Apr 29, 2024
e8d44e0
chore: implemented multiple coin funding
troykessler Apr 29, 2024
a5dc9dc
test: started first multiple coin unit tests
troykessler Apr 29, 2024
89b071a
test: refactored fund_pool_test for coins
troykessler Apr 29, 2024
d108389
test: finished tests so they compile
troykessler Apr 29, 2024
69f6d67
test: repaired existing funding tests
troykessler Apr 29, 2024
68fe337
test: further implemented unit tests
troykessler Apr 30, 2024
afd49f9
test: completed funding tests
troykessler Apr 30, 2024
6936d03
test: further completed funders tests
troykessler Apr 30, 2024
336a0c0
chore: implemented default kyve whitelist logic
troykessler May 2, 2024
0cfe839
chore: wrote spec files for funders module
troykessler May 2, 2024
dccbfc6
chore: added funding score to x/query
troykessler May 2, 2024
c91039b
chore: synced with main
troykessler May 2, 2024
18a69d4
test: fixed unit tests of x/delegation and x/bundles
troykessler May 2, 2024
5ccc1ad
test: fixed remaining unit tests
troykessler May 2, 2024
a7cb087
chore: run make all
troykessler May 2, 2024
8a62742
Merge branch 'main' into troy/funding-multiple-coins
troykessler May 2, 2024
c0d9bb3
fix: unit tests
troykessler May 2, 2024
f3ff042
chore: implemented review feedback
troykessler May 3, 2024
ccf91fd
chore: clean amounts per bundle
troykessler May 3, 2024
b3aa6e2
chore: implemented feedback
troykessler May 3, 2024
46773f2
Merge branch 'main' into troy/funding-multiple-coins
troykessler May 3, 2024
5f180ab
WIP: sync with main
troykessler May 3, 2024
4253e6e
chore: added recipient address for ChargeFundersOfPool
troykessler May 3, 2024
2e5f59f
test: resolve conflicts
mbreithecker May 3, 2024
7de4ce3
chore: removed duplicate helpers
troykessler May 3, 2024
5bd9a9f
chore: implemented final feedback
troykessler May 3, 2024
9ab9dc2
chore: implemented final feedback
troykessler 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
2 changes: 2 additions & 0 deletions app/upgrades/v1_5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,

// TODO: migrate gov params

// TODO: migrate fundings

// TODO: migrate delegation outstanding rewards

return mm.RunMigrations(ctx, configurator, fromVM)
Expand Down
774 changes: 663 additions & 111 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

26 changes: 20 additions & 6 deletions proto/kyve/funders/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.funders.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "kyve/funders/v1beta1/params.proto";

Expand Down Expand Up @@ -59,10 +61,18 @@ message EventFundPool {
uint64 pool_id = 1;
// address is the account address of the pool funder.
string address = 2;
// amount is the amount in ukyve the funder has funded
uint64 amount = 3;
// amount_per_bundle is the amount in ukyve the funder has funded per bundle
uint64 amount_per_bundle = 4;
// amounts is a list of coins the funder has funded
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// amounts_per_bundle is a list of coins the funder wants to distribute per finalized bundle
repeated cosmos.base.v1beta1.Coin amounts_per_bundle = 4 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// EventDefundPool is an event emitted when a pool is defunded.
Expand All @@ -72,8 +82,12 @@ message EventDefundPool {
uint64 pool_id = 1;
// address is the account address of the pool funder.
string address = 2;
// amount is the amount in ukyve the funder has defunded
uint64 amount = 3;
// amounts is a list of coins that the funder wants to defund
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// EventPoolOutOfFunds is an event emitted when a pool has run out of funds
Expand Down
31 changes: 23 additions & 8 deletions proto/kyve/funders/v1beta1/funders.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ syntax = "proto3";

package kyve.funders.v1beta1;

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

option go_package = "github.com/KYVENetwork/chain/x/funders/types";

Expand All @@ -27,16 +29,29 @@ message Funder {
// a funder can only fund each pool once and a pool can only be funded
// by each funder once. However, a funder can update the amount of funds.
message Funding {
// funder_id is the id of the funder
// funder_address is the address of the funder
string funder_address = 1;
// pool_id is the id of the pool this funding is for
uint64 pool_id = 2;
// amount is the amount of funds in ukyve the funder has left
uint64 amount = 3;
// amount_per_bundle is the amount of funds in ukyve the funder pays per bundle
uint64 amount_per_bundle = 4;
// total_funded is the total amount of funds in ukyve the funder has funded
uint64 total_funded = 5;
// amounts is a list of coins the funder wants to fund the pool with
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// amounts_per_bundle defines the amount of each coin that are distributed
// per finalized bundle
repeated cosmos.base.v1beta1.Coin amounts_per_bundle = 4 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// total_funded is the total amount of coins that the funder has funded
repeated cosmos.base.v1beta1.Coin total_funded = 5 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// FundingState is the object which holds info about the funding state of a pool
Expand Down
33 changes: 26 additions & 7 deletions proto/kyve/funders/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@ syntax = "proto3";

package kyve.funders.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "github.com/KYVENetwork/chain/x/funders/types";

// WhitelistCoinEntry is an object containing information around a coin which
// is allowed to be funded in pools
message WhitelistCoinEntry {
// coin_denom is the denom of a coin which is allowed to be funded, this value
// needs to be unique
string coin_denom = 1;
// min_funding_amount is the minimum required amount of this denom that needs
// to be funded
uint64 min_funding_amount = 2;
// min_funding_amount_per_bundle is the minimum required amount of this denom
// that needs to be funded per bundle
uint64 min_funding_amount_per_bundle = 3;
// coin_weight is a factor used to sort funders after their funding amounts
string coin_weight = 4 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

// Params defines the funders module parameters.
message Params {
// Minimum amount of tokens that can be funded.
uint64 min_funding_amount = 1;
// Minimum amount of tokens that can be funded per bundle.
uint64 min_funding_amount_per_bundle = 2;
// coin_whitelist is a list of coins that are allowed to fund a pool
repeated WhitelistCoinEntry coin_whitelist = 1;
// Minimum ratio between the funded amount and the amount_per_bundle.
// In other words this param ensures, that a funder provides at least funding for
// `min_funding_multiple` bundles.
uint64 min_funding_multiple = 3;
// In other words this param ensures, that a funder provides at least
// funding for `min_funding_multiple` bundles.
uint64 min_funding_multiple = 2;
}
36 changes: 26 additions & 10 deletions proto/kyve/funders/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ syntax = "proto3";

package kyve.funders.v1beta1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/KYVENetwork/chain/x/funders/types";

Expand Down Expand Up @@ -67,14 +70,23 @@ message MsgUpdateFunderResponse {}
// MsgFundPool defines a SDK message for funding a pool.
message MsgFundPool {
option (cosmos.msg.v1.signer) = "creator";
// creator ...
// creator is the funder of the pool
string creator = 1;
// id ...
// pool_id is the identifier of the pool
uint64 pool_id = 2;
// amount is the total amount available for distribution
uint64 amount = 3;
// amount_per_bundle defines the amount of tokens that are distributed per submitted bundle
uint64 amount_per_bundle = 4;
// amounts is a list of coins the creator wants to fund
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// amounts_per_bundle is a list of coins the creator wants to distribute
// per finalized bundle
repeated cosmos.base.v1beta1.Coin amounts_per_bundle = 4 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgFundPoolResponse defines the Msg/DefundPool response type.
Expand All @@ -83,12 +95,16 @@ message MsgFundPoolResponse {}
// MsgDefundPool defines a SDK message for defunding a pool.
message MsgDefundPool {
option (cosmos.msg.v1.signer) = "creator";
// creator ...
// creator is the funder of the pool who wants to defund now
string creator = 1;
// id ...
// pool_id is the identifier of the pool
uint64 pool_id = 2;
// amount ...
uint64 amount = 3;
// amounts is a list of coins the creator wants to defund from the pool
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgDefundPoolResponse defines the Msg/DefundPool response type.
Expand Down
18 changes: 13 additions & 5 deletions proto/kyve/query/v1beta1/account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ message QueryAccountAssetsResponse {
uint64 balance = 1;
// protocol_staking ...
uint64 protocol_self_delegation = 2;
// protocol_staking_unbonding
// protocol_staking_unbonding ...
uint64 protocol_self_delegation_unbonding = 3;
// protocol_delegation ...
uint64 protocol_delegation = 4;
// protocol_delegation_unbonding
// protocol_delegation_unbonding ...
uint64 protocol_delegation_unbonding = 5;
// protocol_rewards ...
repeated cosmos.base.v1beta1.Coin protocol_rewards = 6 [
Expand All @@ -63,7 +63,11 @@ message QueryAccountAssetsResponse {
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// protocol_funding ...
uint64 protocol_funding = 7;
repeated cosmos.base.v1beta1.Coin protocol_funding = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// =======================================
Expand Down Expand Up @@ -118,8 +122,12 @@ message QueryAccountFundedListResponse {

// Funded ...
message Funded {
// amount ...
uint64 amount = 1;
// amounts ...
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// pool ...
BasicPool pool = 2;
}
Expand Down
58 changes: 46 additions & 12 deletions proto/kyve/query/v1beta1/funders.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ syntax = "proto3";

package kyve.query.v1beta1;

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

Expand Down Expand Up @@ -53,27 +55,59 @@ message Funder {
// FundingStats ...
message FundingStats {
// total_used_funds are the total funds that have been distributed by the funder.
uint64 total_used_funds = 1;
// total_allocated_funds are the total funds that have been allocated by the funder. They can either get distributed or refunded.
uint64 total_allocated_funds = 2;
repeated cosmos.base.v1beta1.Coin total_used_funds = 1 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// total_allocated_funds are the total funds that have been allocated by the funder.
// They can either get distributed or refunded.
repeated cosmos.base.v1beta1.Coin total_allocated_funds = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// total_amount_per_bundle is the total amount per bundle of all fundings of the funder.
uint64 total_amount_per_bundle = 3;
repeated cosmos.base.v1beta1.Coin total_amount_per_bundle = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// pools_funded are the ids of the pools that have been funded by the funder.
repeated uint64 pools_funded = 4;
// score is the result of all coins of the funder currently allocated times the coin weight
// specified in the params
uint64 score = 5;
}

// Funding ...
message Funding {
// funder_address
// funder_id is the id of the funder
troykessler marked this conversation as resolved.
Show resolved Hide resolved
string funder_address = 1;
// pool_id ...
// pool_id is the id of the pool this funding is for
uint64 pool_id = 2;
// amount ...
uint64 amount = 3;
// amount_per_bundle ...
uint64 amount_per_bundle = 4;
// total_funded ...
uint64 total_funded = 5;
// amounts is a list of coins the funder wants to fund the pool with
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// amounts_per_bundle defines the amount of each coin that are distributed
// per finalized bundle
repeated cosmos.base.v1beta1.Coin amounts_per_bundle = 4 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// total_funded is the total amount of coins that the funder has funded
repeated cosmos.base.v1beta1.Coin total_funded = 5 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// score is the result of all coins allocated to this pool times the coin weight specified
// by the params
uint64 score = 6;
}

// FundingStatus ...
Expand Down
8 changes: 7 additions & 1 deletion proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package kyve.query.v1beta1;

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

Expand Down Expand Up @@ -46,7 +48,11 @@ message BasicPool {

// total_funds of the pool. If the pool runs
// out of funds no more bundles will be produced
uint64 total_funds = 7;
repeated cosmos.base.v1beta1.Coin total_funds = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

// total_delegation of the pool
uint64 total_delegation = 8;
Expand Down
Loading
Loading