Skip to content

Commit

Permalink
chore: started implementation of funding with multiple coins
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Apr 26, 2024
1 parent f6ace3e commit fd52592
Show file tree
Hide file tree
Showing 15 changed files with 2,099 additions and 614 deletions.
564 changes: 471 additions & 93 deletions docs/static/openapi.yml

Large diffs are not rendered by default.

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

package kyve.funders.v1beta1;

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

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

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 that 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 amounts per coin per 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
65 changes: 58 additions & 7 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 "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";

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

Expand All @@ -22,6 +24,23 @@ message Funder {
string description = 6;
}

// TODO: do this because else we would have to check the following things:
// if amounts and amounts_per_bundle are given seperately as arrays we would have to check the following:
// - are those arrays of equal size
// - are there any coins which are not whitelisted in one of those arrays
// - is amounts_per_bundle a subset of amounts
message FundEntry {
// amount is amount of the coin which is funded
cosmos.base.v1beta1.Coin amount = 1 [
(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
uint64 amount_per_bundle = 2;
}

// Funding is the object which holds info about the current funding
// funder_address and pool_id (m2m) are unique together which means that
// a funder can only fund each pool once and a pool can only be funded
Expand All @@ -31,12 +50,25 @@ message Funding {
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 All @@ -46,3 +78,22 @@ message FundingState {
// active_funder_addresses is the list of all active fundings
repeated string active_funder_addresses = 2;
}

// 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
];
}
14 changes: 7 additions & 7 deletions proto/kyve/funders/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ package kyve.funders.v1beta1;

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

import "kyve/funders/v1beta1/funders.proto";

// 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;
}
37 changes: 27 additions & 10 deletions proto/kyve/funders/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ package kyve.funders.v1beta1;

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

Check failure on line 10 in proto/kyve/funders/v1beta1/tx.proto

View workflow job for this annotation

GitHub Actions / lint / buf

Import "kyve/funders/v1beta1/funders.proto" is unused.

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

Expand Down Expand Up @@ -67,14 +71,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;
// amount is the amount of a coin the creator wants to fund
cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
// amount_per_bundle is the amount of the coin the creator wants to distribute
// per finalized bundle
cosmos.base.v1beta1.Coin amount_per_bundle = 4 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
}

// MsgFundPoolResponse defines the Msg/DefundPool response type.
Expand All @@ -83,12 +96,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
52 changes: 40 additions & 12 deletions proto/kyve/query/v1beta1/funders.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package kyve.query.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";

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

Expand Down Expand Up @@ -53,27 +55,53 @@ 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;
}

// 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"
];
}

// FundingStatus ...
Expand Down
Loading

0 comments on commit fd52592

Please sign in to comment.