mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
fixed getAmountAt
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.20.70",
|
||||
"version": "0.20.71",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.20.70",
|
||||
"version": "0.20.71",
|
||||
"hasInstallScript": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.20.70",
|
||||
"version": "0.20.71",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
PoolV2InfoResponseSchema,
|
||||
testIncrementorSchema,
|
||||
veORNInfoResponseSchema,
|
||||
votingInfoResponseSchema
|
||||
votingInfoResponseSchema,
|
||||
} from './schemas';
|
||||
import { fetchWithValidation } from 'simple-typed-fetch';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
@@ -118,16 +118,23 @@ class IndexerService {
|
||||
});
|
||||
};
|
||||
|
||||
readonly getAmountAt = (amount: number, timestamp?: number): BigNumber => {
|
||||
const finalTimestamp = timestamp !== undefined ? timestamp / 1000 : Date.now() / 1000;
|
||||
/**
|
||||
* @param {number} amount - amount
|
||||
* @param {number} [timestamp = Date.now()] - timestamp, defaults to current time
|
||||
*/
|
||||
readonly getAmountAt = (
|
||||
amount: number,
|
||||
timestamp = Date.now()
|
||||
): BigNumber => {
|
||||
const finalTimestamp = timestamp / 1000;
|
||||
|
||||
// sqrt
|
||||
return BigNumber(amount).dividedBy(this.getK(finalTimestamp));
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated In favor of getAmountAt
|
||||
*/
|
||||
* @deprecated since version 69 in favor of getAmountAt
|
||||
*/
|
||||
readonly getAmountAtCurrent = (amount: number): BigNumber => {
|
||||
const timestamp = Date.now() / 1000;
|
||||
|
||||
@@ -145,8 +152,7 @@ class IndexerService {
|
||||
const multSQRT = deltaDaysBN.dividedBy(WEEK_DAYS).sqrt();
|
||||
const multCUBE = deltaDaysBN.dividedBy(alpha).pow(3);
|
||||
|
||||
return BigNumber(amountToken)
|
||||
.multipliedBy(multSQRT.plus(multCUBE));
|
||||
return BigNumber(amountToken).multipliedBy(multSQRT.plus(multCUBE));
|
||||
};
|
||||
|
||||
readonly getVotingInfo = (userAddress?: string) => {
|
||||
@@ -219,7 +225,11 @@ class IndexerService {
|
||||
});
|
||||
};
|
||||
|
||||
readonly poolV2Info = (token0: string, token1: string, address: string | undefined) => {
|
||||
readonly poolV2Info = (
|
||||
token0: string,
|
||||
token1: string,
|
||||
address: string | undefined
|
||||
) => {
|
||||
return fetchWithValidation(this.apiUrl, PoolV2InfoResponseSchema, {
|
||||
method: 'POST',
|
||||
body: this.makeRPCPayload({
|
||||
|
||||
Reference in New Issue
Block a user