-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkusama.ts
72 lines (61 loc) · 2.88 KB
/
kusama.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import {SubstrateEvent} from "@subql/types";
import {handleNewEra, handleNewSession, POOLED_STAKING_TYPE} from "./common";
import {RelaychainRewardCalculator} from "./rewards/Relaychain";
import {NominationPoolRewardCalculator} from "./rewards/NominationPoolRewardCalculator";
import {ValidatorEraInfoDataSource} from "./era/ValidatorEraInfoDataSource";
import {Codec} from "@polkadot/types/types";
import {INumber} from "@polkadot/types-codec/types/interfaces";
import {handleRelaychainStakingReward, handleRelaychainStakingSlash} from "./rewards/history/relaychain";
import {
handleRelaychainPooledStakingReward,
handleRelaychainPooledStakingBondedSlash,
handleRelaychainPooledStakingUnbondingSlash
} from "./rewards/history/nomination_pools";
const KUSAMA_GENESIS = "0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe"
const DIRECT_STAKING_TYPE = "relaychain"
export async function handleKusamaNewEra(_: SubstrateEvent): Promise<void> {
let validatorEraInfoDataSource = new ValidatorEraInfoDataSource();
await handleNewEra(
validatorEraInfoDataSource,
await RelaychainRewardCalculator(validatorEraInfoDataSource),
KUSAMA_GENESIS,
DIRECT_STAKING_TYPE
)
}
export async function handleKusamaNewSession(_: SubstrateEvent): Promise<void> {
let validatorEraInfoDataSource = new ValidatorEraInfoDataSource();
let mainRewardCalculator = await RelaychainRewardCalculator(validatorEraInfoDataSource)
let poolRewardCalculator = new NominationPoolRewardCalculator(validatorEraInfoDataSource, mainRewardCalculator)
await handleNewSession(
validatorEraInfoDataSource,
mainRewardCalculator,
KUSAMA_GENESIS,
DIRECT_STAKING_TYPE,
poolRewardCalculator
)
}
export async function handleKusamaStakingReward(
event: SubstrateEvent<[accountId: Codec, reward: INumber]>,
): Promise<void> {
await handleRelaychainStakingReward(event, KUSAMA_GENESIS, DIRECT_STAKING_TYPE)
}
export async function handleKusamaStakingSlash(
event: SubstrateEvent<[account: Codec, slash: INumber]>,
): Promise<void> {
await handleRelaychainStakingSlash(event, KUSAMA_GENESIS, DIRECT_STAKING_TYPE)
}
export async function handleKusamaPoolStakingReward(
event: SubstrateEvent<[accountId: Codec, poolId: INumber, reward: INumber]>,
): Promise<void> {
await handleRelaychainPooledStakingReward(event, KUSAMA_GENESIS, POOLED_STAKING_TYPE)
}
export async function handleKusamaPoolStakingBondedSlash(
event: SubstrateEvent<[poolId: INumber, slash: INumber]>,
): Promise<void> {
await handleRelaychainPooledStakingBondedSlash(event, KUSAMA_GENESIS, POOLED_STAKING_TYPE)
}
export async function handleKusamaPoolStakingUnbondingSlash(
event: SubstrateEvent<[era: INumber, poolId: INumber, slash: INumber]>,
): Promise<void> {
await handleRelaychainPooledStakingUnbondingSlash(event, KUSAMA_GENESIS, POOLED_STAKING_TYPE)
}