From 2abb2ce606ae17a4f8bb8062e4c144c70418a6e9 Mon Sep 17 00:00:00 2001 From: Ruaridh Date: Mon, 7 Nov 2022 22:07:19 +0000 Subject: [PATCH] Add source adapter interface definition (#1377) * add source adapter interface definition * add more context to method names * return a map to reduce chance of wrong order --- x/incentive/types/adapter.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 x/incentive/types/adapter.go diff --git a/x/incentive/types/adapter.go b/x/incentive/types/adapter.go new file mode 100644 index 00000000..7f9d5075 --- /dev/null +++ b/x/incentive/types/adapter.go @@ -0,0 +1,18 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +// SourceAdapter queries source shares from an external module. +type SourceAdapter interface { + // OwnerSharesBySource returns source shares owned by one address. + // + // For example, the shares a user owns in the kava:usdx and bnb:usdx swap pools. + // It returns the shares for several sources at once, in a map of sourceIDs to shares. Specifying no sourceIDS will return no shares. + // Note the returned map does not have a deterministic order. + OwnerSharesBySource(ctx sdk.Context, owner sdk.AccAddress, sourceIDs []string) map[string]sdk.Dec + + // TotalSharesBySource returns the sum of all shares for a source (across all users). + // + // For example, the total number of shares in the kava:usdx swap pool for all users. + TotalSharesBySource(ctx sdk.Context, sourceID string) sdk.Dec +}