ghost-portal/packages/apps-config/src/api/params/inflation.ts
Jaco 4929b1c6fd
Update headers for 2023 (#8665)
* Update headers for 2023

* Adjust env-config
2023-01-01 10:32:05 +02:00

45 lines
1.8 KiB
TypeScript

// Copyright 2017-2023 @polkadot/app-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiPromise } from '@polkadot/api';
import { DOCK_POS_TESTNET_GENESIS, KUSAMA_GENESIS, NEATCOIN_GENESIS, NFTMART_GENESIS, POLKADOT_GENESIS } from '../constants';
interface InflationParams {
auctionAdjust: number;
auctionMax: number;
falloff: number;
maxInflation: number;
minInflation: number;
stakeTarget: number;
}
const DEFAULT_PARAMS: InflationParams = {
auctionAdjust: 0,
auctionMax: 0,
// 5% for falloff, as per the defaults, see
// https://github.com/paritytech/polkadot/blob/816cb64ea16102c6c79f6be2a917d832d98df757/runtime/kusama/src/lib.rs#L534
falloff: 0.05,
// 10% max, 0.25% min, see
// https://github.com/paritytech/polkadot/blob/816cb64ea16102c6c79f6be2a917d832d98df757/runtime/kusama/src/lib.rs#L523
maxInflation: 0.1,
minInflation: 0.025,
stakeTarget: 0.5
};
const KNOWN_PARAMS: Record<string, InflationParams> = {
[DOCK_POS_TESTNET_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 },
// 30% for up to 60 slots, see
// https://github.com/paritytech/polkadot/blob/816cb64ea16102c6c79f6be2a917d832d98df757/runtime/kusama/src/lib.rs#L526-L527
// 75% ideal target, see
// https://github.com/paritytech/polkadot/blob/816cb64ea16102c6c79f6be2a917d832d98df757/runtime/kusama/src/lib.rs#L529-L531
[KUSAMA_GENESIS]: { ...DEFAULT_PARAMS, auctionAdjust: (0.3 / 60), auctionMax: 60, stakeTarget: 0.75 },
[NEATCOIN_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 },
[NFTMART_GENESIS]: { ...DEFAULT_PARAMS, falloff: 0.04, stakeTarget: 0.60 },
[POLKADOT_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 }
};
export function getInflationParams (api: ApiPromise): InflationParams {
return KNOWN_PARAMS[api.genesisHash.toHex()] || DEFAULT_PARAMS;
}