Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@indexed-finance/indexed.js

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@indexed-finance/indexed.js - npm Package Compare versions

Comparing version 1.0.44 to 1.0.45

2

dist/initializer-helper.js

@@ -122,3 +122,3 @@ "use strict";

var timestamp = Math.floor(+new Date() / 1000);
return timestamp - this.lastUpdate > 600;
return timestamp - this.lastUpdate > 120;
},

@@ -125,0 +125,0 @@ enumerable: false,

@@ -98,3 +98,3 @@ "use strict";

get: function () {
return this.timestamp - this.lastUpdateTime > 60;
return this.timestamp - this.lastUpdateTime > 120;
},

@@ -101,0 +101,0 @@ enumerable: false,

@@ -67,2 +67,3 @@ import { Provider } from "@ethersproject/providers";

updateUserData(): Promise<void>;
updateSnapshotAndPrices(): Promise<void>;
update(): Promise<void>;

@@ -69,0 +70,0 @@ getTokenBySymbol(symbol: string): PoolToken;

@@ -236,3 +236,3 @@ "use strict";

var timestamp = Math.floor(+new Date() / 1000);
return timestamp - this.lastUpdate > 600;
return (timestamp - this.lastUpdate) > 120;
},

@@ -341,2 +341,29 @@ enumerable: false,

};
PoolHelper.prototype.updateSnapshotAndPrices = function () {
return __awaiter(this, void 0, void 0, function () {
var url, _a, snapshot, tokenPrices, lastSnapshot;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = (this.chainID == 1) ? subgraph_1.INDEXED_SUBGRAPH_URL : subgraph_1.INDEXED_RINKEBY_SUBGRAPH_URL;
return [4 /*yield*/, subgraph_1.getPoolUpdate(url, this.address)];
case 1:
_a = _b.sent(), snapshot = _a.snapshot, tokenPrices = _a.tokenPrices;
lastSnapshot = this.pool.snapshots[this.pool.snapshots.length - 1];
if (lastSnapshot.date == snapshot.date) {
this.pool.snapshots[this.pool.snapshots.length - 1] = snapshot;
}
else {
this.pool.snapshots.push(lastSnapshot);
}
Object.keys(tokenPrices).map(function (address) {
var token = _this.getTokenByAddress(address);
token.priceUSD = tokenPrices[address];
});
return [2 /*return*/];
}
});
});
};
PoolHelper.prototype.update = function () {

@@ -348,3 +375,3 @@ return __awaiter(this, void 0, void 0, function () {

this.lastUpdate = Math.floor(+new Date() / 1000);
return [4 /*yield*/, Promise.all([this.updatePool(), this.updateUserData()])];
return [4 /*yield*/, Promise.all([this.updatePool(), this.updateUserData(), this.updateSnapshotAndPrices()])];
case 1:

@@ -351,0 +378,0 @@ _a.sent();

@@ -78,3 +78,3 @@ "use strict";

var timestamp = Math.floor(+new Date() / 1000);
return timestamp - this.lastUpdate > 300;
return timestamp - this.lastUpdate > 120;
},

@@ -81,0 +81,0 @@ enumerable: false,

@@ -15,1 +15,9 @@ import { Pool, PoolDailySnapshot, StakingPool } from './types';

export declare const parseStakingPool: (data: any) => StakingPool;
declare type PoolUpdate = {
snapshot: PoolDailySnapshot;
tokenPrices: {
[address: string]: number;
};
};
export declare function getPoolUpdate(url: string, address: string): Promise<PoolUpdate>;
export {};

@@ -72,3 +72,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseStakingPool = exports.getStakingPools = exports.parsePoolSnapshots = exports.getPoolSnapshots = exports.getTokenPrice = exports.parsePoolData = exports.getPool = exports.getPools = exports.UNISWAP_SUBGRAPH_URL_RINKEBY = exports.UNISWAP_SUBGRAPH_URL = exports.INDEXED_RINKEBY_SUBGRAPH_URL = exports.INDEXED_SUBGRAPH_URL = void 0;
exports.getPoolUpdate = exports.parseStakingPool = exports.getStakingPools = exports.parsePoolSnapshots = exports.getPoolSnapshots = exports.getTokenPrice = exports.parsePoolData = exports.getPool = exports.getPools = exports.UNISWAP_SUBGRAPH_URL_RINKEBY = exports.UNISWAP_SUBGRAPH_URL = exports.INDEXED_RINKEBY_SUBGRAPH_URL = exports.INDEXED_SUBGRAPH_URL = void 0;
var isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));

@@ -309,2 +309,3 @@ var bmath = __importStar(require("./bmath"));

}
retArr.sort(function (a, b) { return a.date - b.date; });
return retArr;

@@ -350,1 +351,26 @@ };

};
var poolUpdateQuery = function (address) { return "\n{\n indexPool(id: \"" + address + "\") {\n dailySnapshots(orderBy: date, orderDirection: desc, first: 1) {\n id\n date\n value\n totalSupply\n feesTotalUSD\n totalValueLockedUSD\n totalSwapVolumeUSD\n totalVolumeUSD\n }\n tokens {\n token {\n id\n priceUSD\n }\n }\n }\n}\n"; };
function getPoolUpdate(url, address) {
return __awaiter(this, void 0, void 0, function () {
var query, _a, dailySnapshots, tokens, snapshot, tokenPrices;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
query = poolUpdateQuery(address.toLowerCase());
return [4 /*yield*/, executeQuery(query, url)];
case 1:
_a = (_b.sent()).indexPool, dailySnapshots = _a.dailySnapshots, tokens = _a.tokens;
snapshot = exports.parsePoolSnapshots(dailySnapshots)[0];
tokenPrices = tokens.reduce(function (obj, t) {
var _a;
return (__assign(__assign({}, obj), (_a = {}, _a[t.token.id] = +(t.token.priceUSD), _a)));
}, {});
return [2 /*return*/, {
snapshot: snapshot,
tokenPrices: tokenPrices
}];
}
});
});
}
exports.getPoolUpdate = getPoolUpdate;

@@ -67,3 +67,3 @@ "use strict";

var timestamp = Math.floor(+new Date() / 1000);
return timestamp - this.lastUpdate > 600;
return timestamp - this.lastUpdate > 120;
},

@@ -70,0 +70,0 @@ enumerable: false,

{
"name": "@indexed-finance/indexed.js",
"version": "1.0.44",
"version": "1.0.45",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,3 +10,3 @@ # @indexed-finance/indexed.js

```js
const { getAllHelpers, toWei, fromWei } = require('@indexed-finance/indexed-sdk');
const { getAllHelpers, toWei, fromWei } = require('@indexed-finance/indexed.js');

@@ -13,0 +13,0 @@ const helpers = await getAllHelpers(web3);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc