Skip to content

Commit

Permalink
feat: support multiple coins for funding (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler authored May 3, 2024
1 parent cee3a98 commit 6e0aba8
Show file tree
Hide file tree
Showing 72 changed files with 4,714 additions and 1,663 deletions.
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
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

0 comments on commit 6e0aba8

Please sign in to comment.