Skip to content

Commit

Permalink
feat: implement FundPool
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Sep 21, 2023
1 parent ff87089 commit d188ed3
Show file tree
Hide file tree
Showing 37 changed files with 6,240 additions and 2,058 deletions.
48 changes: 0 additions & 48 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4785,30 +4785,6 @@ paths:
description: |-
disabled is true when the pool is disabled.
Can only be done via governance.
funders:
type: array
items:
type: object
properties:
address:
type: string
title: address is the address of the funder
amount:
type: string
format: uint64
title: >-
amount is the current amount of funds in ukyve
the funder has
still funded the pool with
title: >-
Funder is the object which holds info about a single
pool funder
description: funders ...
total_funds:
type: string
format: uint64
description: total_funds ...
protocol:
description: protocol ...
type: object
Expand Down Expand Up @@ -5301,30 +5277,6 @@ paths:
description: |-
disabled is true when the pool is disabled.
Can only be done via governance.
funders:
type: array
items:
type: object
properties:
address:
type: string
title: address is the address of the funder
amount:
type: string
format: uint64
title: >-
amount is the current amount of funds in ukyve
the funder has
still funded the pool with
title: >-
Funder is the object which holds info about a
single pool funder
description: funders ...
total_funds:
type: string
format: uint64
description: total_funds ...
protocol:
description: protocol ...
type: object
Expand Down
62 changes: 62 additions & 0 deletions proto/kyve/funders/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,65 @@ package kyve.funders.v1beta1;
//import "kyve/funders/v1beta1/params.proto";

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

// EventCreateFunder is an event emitted when a funder is created.
// emitted_by: MsgCreateFunder
message EventCreateFunder {
// address is the account address of the funder.
string address = 1;
// moniker ...
string moniker = 2;
// identity is the 64 bit keybase.io identity string
string identity = 3;
// logo ...
string logo = 4;
// website ...
string website = 5;
// contact ...
string contact = 6;
// details are some additional notes the funder finds important
string details = 7;
}

// EventUpdateFunder is an event emitted when a funder is created.
// emitted_by: MsgCreateFunder
message EventUpdateFunder {
// address is the account address of the funder.
string address = 1;
// moniker ...
string moniker = 2;
// identity is the 64 bit keybase.io identity string
string identity = 3;
// logo ...
string logo = 4;
// website ...
string website = 5;
// contact ...
string contact = 6;
// details are some additional notes the funder finds important
string details = 7;
}

// EventFundPool is an event emitted when a pool is funded.
// emitted_by: MsgFundPool
message EventFundPool {
// pool_id is the unique ID of the pool.
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;
}

// EventDefundPool is an event emitted when a pool is defunded.
// emitted_by: MsgDefundPool
message EventDefundPool {
// pool_id is the unique ID of the pool.
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;
}
47 changes: 47 additions & 0 deletions proto/kyve/funders/v1beta1/funders.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,50 @@ package kyve.funders.v1beta1;
//import "gogoproto/gogo.proto";

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

// Funder is the object which holds info about a single pool funder
message Funder {
// address ...
string address = 1;
// moniker ...
string moniker = 2;
// identity is the 64 bit keybase.io identity string
string identity = 3;
// logo ...
string logo = 4;
// website ...
string website = 5;
// contact ...
string contact = 6;
// details are some additional notes the funder finds important
string details = 7;
}

// 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
// by each funder once. However, a funder can update the amount of funds.
message Funding {
// funder_id is the id 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;
}

// FundingState is the object which holds info about the funding state
message FundingState {
// pool_id is the id of the pool this funding is for
uint64 pool_id = 1;
// active_fundings is the list of all active fundings
repeated Funding active_fundings = 2;
// inactive_fundings is the list of all inactive fundings that have been used up
repeated Funding inactive_fundings = 3;
// total_amount is the total amount of funds in ukyve the pool has from all fundings
uint64 total_amount = 4;
}
84 changes: 80 additions & 4 deletions proto/kyve/funders/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,86 @@ syntax = "proto3";

package kyve.funders.v1beta1;

//import "cosmos_proto/cosmos.proto";
//import "gogoproto/gogo.proto";

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

// Msg defines the Msg service.
service Msg {}
service Msg {
// CreateFunder ...
rpc CreateFunder(MsgCreateFunder) returns (MsgCreateFunderResponse);
// UpdateFunder ...
// rpc UpdateFunder(MsgUpdateFunder) returns (MsgUpdateFunderResponse);
// FundPool ...
rpc FundPool(MsgFundPool) returns (MsgFundPoolResponse);
// DefundPool ...
rpc DefundPool(MsgDefundPool) returns (MsgDefundPoolResponse);
}

// MsgCreateFunder defines a SDK message for creating a funder.
message MsgCreateFunder {
// creator ...
string creator = 1;
// moniker
string moniker = 2;
// identity is the 64 bit keybase.io identity string
string identity = 3;
// logo
string logo = 4;
// website
string website = 5;
// contact
string contact = 6;
// details are some additional notes the funder finds important
string details = 7;
}

// MsgCreateFunderResponse defines the Msg/CreateFunder response type.
message MsgCreateFunderResponse {}

// MsgUpdateFunder defines a SDK message for updating a funder.
message MsgUpdateFunder {
// creator ...
string creator = 1;
// moniker
string moniker = 2;
// identity is the 64 bit keybase.io identity string
string identity = 3;
// logo
string logo = 4;
// website
string website = 5;
// contact
string contact = 6;
// details are some additional notes the funder finds important
string details = 7;
}

// MsgUpdateFunderResponse defines the Msg/UpdateFunder response type.
message MsgUpdateFunderResponse {}

// MsgFundPool defines a SDK message for funding a pool.
message MsgFundPool {
// creator ...
string creator = 1;
// id ...
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;
}

// MsgFundPoolResponse defines the Msg/DefundPool response type.
message MsgFundPoolResponse {}

// MsgDefundPool defines a SDK message for defunding a pool.
message MsgDefundPool {
// creator ...
string creator = 1;
// id ...
uint64 pool_id = 2;
// amount ...
uint64 amount = 3;
}

// MsgDefundPoolResponse defines the Msg/DefundPool response type.
message MsgDefundPoolResponse {}
22 changes: 0 additions & 22 deletions proto/kyve/pool/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,6 @@ message EventPoolUpdated {
uint32 compression_id = 12;
}

// EventFundPool is an event emitted when a pool is funded.
// emitted_by: MsgFundPool
message EventFundPool {
// pool_id is the unique ID of the pool.
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;
}

// EventDefundPool is an event emitted when a pool is defunded.
// emitted_by: MsgDefundPool
message EventDefundPool {
// pool_id is the unique ID of the pool.
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;
}

// EventDefundPool is an event emitted when a pool is defunded.
// emitted_by: MsgSubmitBundleProposal
message EventPoolFundsSlashed {
Expand Down
15 changes: 2 additions & 13 deletions proto/kyve/pool/v1beta1/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ message UpgradePlan {
uint64 duration = 4;
}

// Funder is the object which holds info about a single pool funder
message Funder {
// address is the address of the funder
string address = 1;
// amount is the current amount of funds in ukyve the funder has
// still funded the pool with
uint64 amount = 2;
}

// Pool ...
message Pool {
// id - unique identifier of the pool, can not be changed
Expand Down Expand Up @@ -99,10 +90,8 @@ message Pool {
// Can only be done via governance.
bool disabled = 15;

// funders ...
repeated Funder funders = 16;
// total_funds ...
uint64 total_funds = 17;
// old funders and total_funds fields
reserved 16, 17;

// protocol ...
Protocol protocol = 18;
Expand Down
31 changes: 0 additions & 31 deletions proto/kyve/pool/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ option go_package = "github.com/KYVENetwork/chain/x/pool/types";

// Msg defines the Msg service.
service Msg {
// FundPool ...
rpc FundPool(MsgFundPool) returns (MsgFundPoolResponse);
// DefundPool ...
rpc DefundPool(MsgDefundPool) returns (MsgDefundPoolResponse);

// CreatePool defines a governance operation for creating a new pool.
// The authority is hard-coded to the x/gov module account.
rpc CreatePool(MsgCreatePool) returns (MsgCreatePoolResponse);
Expand All @@ -36,32 +31,6 @@ service Msg {
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgFundPool defines a SDK message for funding a pool.
message MsgFundPool {
// creator ...
string creator = 1;
// id ...
uint64 id = 2;
// amount ...
uint64 amount = 3;
}

// MsgFundPoolResponse defines the Msg/DefundPool response type.
message MsgFundPoolResponse {}

// MsgDefundPool defines a SDK message for defunding a pool.
message MsgDefundPool {
// creator ...
string creator = 1;
// id ...
uint64 id = 2;
// amount ...
uint64 amount = 3;
}

// MsgDefundPoolResponse defines the Msg/DefundPool response type.
message MsgDefundPoolResponse {}

// MsgCreatePool defines a SDK message for creating a new pool.
message MsgCreatePool {
// authority is the address of the governance account.
Expand Down
2 changes: 1 addition & 1 deletion x/bundles/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type PoolKeeper interface {
IncrementBundleInformation(ctx sdk.Context, poolId uint64, currentHeight uint64, currentKey string, currentValue string)

GetAllPools(ctx sdk.Context) (list []pooltypes.Pool)
ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error)
//ChargeFundersOfPool(ctx sdk.Context, poolId uint64, amount uint64) (payout uint64, err error) //TODO(rapha): remove
ChargeInflationPool(ctx sdk.Context, poolId uint64) (payout uint64, err error)
}

Expand Down
Loading

0 comments on commit d188ed3

Please sign in to comment.