getAmountAt function

This commit is contained in:
Kirill Litvinov
2024-03-12 12:13:40 +03:00
parent 2c26af4e36
commit 5cb1bfb9d9
3 changed files with 14 additions and 3 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.66-rc2",
"version": "0.20.69",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@orionprotocol/sdk",
"version": "0.20.66-rc2",
"version": "0.20.69",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.68",
"version": "0.20.69",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -94,6 +94,7 @@ class IndexerService {
this.veORNInfo = this.veORNInfo.bind(this);
this.listAmount = this.listAmount.bind(this);
this.getAmountByORN = this.getAmountByORN.bind(this);
this.getAmountAt = this.getAmountAt.bind(this);
this.getAmountAtCurrent = this.getAmountAtCurrent.bind(this);
this.getVotingInfo = this.getVotingInfo.bind(this);
}
@@ -117,6 +118,16 @@ class IndexerService {
});
};
readonly getAmountAt = (amount: number, timestamp?: number): BigNumber => {
const currentTime = Date.now() / 1000;
// sqrt
return BigNumber(amount).dividedBy(this.getK(timestamp ?? currentTime));
};
/**
* @deprecated In favor of getAmountAt
*/
readonly getAmountAtCurrent = (amount: number): BigNumber => {
const timestamp = Date.now() / 1000;