-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds selector for getRewardsFn (#1638)
- Loading branch information
1 parent
6990d61
commit 045f535
Showing
5 changed files
with
45 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AppConfig } from "src/appconfig/AppConfig"; | ||
import { rewardFunctions } from "src/rewards/rewards"; | ||
import { RewardsResolver } from "src/rewards/types"; | ||
import { YieldSourceId } from "src/yieldSources/types"; | ||
|
||
/** | ||
* Find the rewards resolver for a given yield source. This will return | ||
* `undefined` if no rewards function exists for this yield source. | ||
*/ | ||
export function getRewardsFn({ | ||
yieldSourceId, | ||
appConfig, | ||
}: { | ||
// TODO: change this type to YieldSourceId once YieldSourceId can be used outside | ||
// of the appconfig package.k | ||
yieldSourceId: string; | ||
appConfig: AppConfig; | ||
}): RewardsResolver | undefined { | ||
// casting this for now because YieldSourceId doesn't work outside of the appconfig package | ||
const yieldSource = appConfig.yieldSources[yieldSourceId as YieldSourceId]; | ||
if (!yieldSource.rewardsFn) { | ||
return; | ||
} | ||
return rewardFunctions[yieldSource.rewardsFn]; | ||
} |