UNPKG

@lidofinance/lido-ethereum-sdk

Version:

<div style="display: flex;" align="center"> <h1 align="center">Lido Ethereum SDK</h1> </div>

20 lines 951 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requestWithBlockStep = exports.sharesToSteth = exports.calcShareRate = void 0; const calcShareRate = (totalEther, totalShares, precision) => Number((totalEther * precision) / totalShares) / Number(precision); exports.calcShareRate = calcShareRate; const sharesToSteth = (shares, totalEther, totalShares, precision) => (shares * totalEther * precision) / (totalShares * precision); exports.sharesToSteth = sharesToSteth; const requestWithBlockStep = async (step, fromBlock, toBlock, request) => { let from = fromBlock; const result = []; while (from <= toBlock) { const to = from + BigInt(step); const nextResult = await request(from, to > toBlock ? toBlock : to); result.push(...nextResult); from = to + 1n; } return result; }; exports.requestWithBlockStep = requestWithBlockStep; //# sourceMappingURL=utils.js.map