-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: epoch rewards now includes the pool id of the pool that genera…
…ted the reward BREAKING CHANGE: EpochRewards renamed to Reward - The pool the stake address was delegated to when the reward is earned is now included in the EpochRewards (Will be null for payments from the treasury or the reserves) - Reward no longer coalesce rewards from the same epoch
- Loading branch information
1 parent
8ece0b9
commit 96fd72b
Showing
14 changed files
with
72 additions
and
48 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
13 changes: 9 additions & 4 deletions
13
packages/cardano-services/src/Rewards/DbSyncRewardProvider/mappers.ts
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 |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import { Cardano, EpochRewards } from '@cardano-sdk/core'; | ||
import { Cardano, Reward } from '@cardano-sdk/core'; | ||
import { RewardEpochModel } from './types'; | ||
|
||
export const rewardsToCore = (rewards: RewardEpochModel[]): Map<Cardano.RewardAccount, EpochRewards[]> => | ||
export const rewardsToCore = (rewards: RewardEpochModel[]): Map<Cardano.RewardAccount, Reward[]> => | ||
rewards.reduce((_rewards, current) => { | ||
const coreReward = current.address as unknown as Cardano.RewardAccount; | ||
const poolId = current.pool_id ? (current.pool_id as unknown as Cardano.PoolId) : undefined; | ||
const epochRewards = _rewards.get(coreReward); | ||
const currentEpochReward = { epoch: Cardano.EpochNo(current.epoch), rewards: BigInt(current.quantity) }; | ||
const currentEpochReward = { | ||
epoch: Cardano.EpochNo(current.epoch), | ||
poolId, | ||
rewards: BigInt(current.quantity) | ||
}; | ||
if (epochRewards) { | ||
_rewards.set(coreReward, [...epochRewards, currentEpochReward]); | ||
} else { | ||
_rewards.set(coreReward, [currentEpochReward]); | ||
} | ||
return _rewards; | ||
}, new Map<Cardano.RewardAccount, EpochRewards[]>()); | ||
}, new Map<Cardano.RewardAccount, Reward[]>()); |
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ export interface RewardEpochModel { | |
quantity: string; | ||
address: string; | ||
epoch: number; | ||
pool_id?: string; | ||
} |
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
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