Skip to content

Commit

Permalink
Merge pull request #88 from tinymanorg/fix/lock-duration
Browse files Browse the repository at this point in the history
Add `isFloor` param to get the correct timestamp
  • Loading branch information
gulcinuras authored Jul 31, 2024
2 parents 312c268 + 3acac55 commit d8a2032
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/governance/vault/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare function getStartTimestampOfWeek(value: number): number;
declare function getStartTimestampOfWeek(timestamp: number, isFloor?: boolean): number;
declare function getNewTotalPowerTimestamps(oldTimeStamp: number, newTimeStamp: number): number[];
declare function getSlope(lockedAmount: number): number;
export { getNewTotalPowerTimestamps, getStartTimestampOfWeek, getSlope };
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tinymanorg/tinyman-js-sdk",
"version": "4.0.0",
"version": "4.0.1",
"description": "Tinyman JS SDK",
"author": "Tinyman Core Team",
"license": "MIT",
Expand Down
6 changes: 4 additions & 2 deletions src/governance/vault/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {WEEK} from "../constants";
import {MAX_LOCK_TIME, TWO_TO_THE_64} from "./constants";

function getStartTimestampOfWeek(value: number) {
return Math.floor(value / WEEK) * WEEK;
function getStartTimestampOfWeek(timestamp: number, isFloor = false) {
const numberOfWeeks = timestamp / WEEK;

return (isFloor ? Math.floor(numberOfWeeks) : Math.ceil(numberOfWeeks)) * WEEK;
}

function getNewTotalPowerTimestamps(oldTimeStamp: number, newTimeStamp: number) {
Expand Down

0 comments on commit d8a2032

Please sign in to comment.