Skip to content

A Little Bit Deviation from BlockNumber to TimeStamp Duration, is this Acceptable? #235

@aurexav

Description

@aurexav
// now: BlockNumber
// item.start_time: BlockNumber
// item.expire_time: BlockNumber

let kton_slash = {
	let passed_duration = (now - item.start_time).saturated_into::<TimeStamp>() * BLOCK_NUMBER_IN_SECONDS / MONTH_IN_MILLISECONDS;
	let plan_duration = (item.expire_time - item.start_time).saturated_into::<TimeStamp>() * BLOCK_NUMBER_IN_SECONDS / MONTH_IN_MILLISECONDS;

	(
		inflation::compute_kton_return::<T>(item.value, plan_duration)
		-
		inflation::compute_kton_return::<T>(item.value, passed_duration)
	).max(1.into()) * 3.into()
};

BLOCK_NUMBER_IN_SECONDS is not always 3 in reality

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions