@edgeandnode/common
Advanced tools
Comparing version 4.11.0 to 4.11.1
@@ -1041,3 +1041,52 @@ import { gql } from 'graphql-tag'; | ||
export { AllocationStatus, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, GRTBufferedMaxUint256, GrtUsdcUniswapPair, MAX_WEIGHT, NETWORKS, NetworkEnum, PPM, Revocability, SECONDS_IN_DAY, SIGNAL_PER_MINIMUM_DEPOSIT, SubgraphIndexHealth, TenTrillion, TransactionType, ZERO, addrShortener, appendEth, appendQueryParam, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, buildSubgraphId, checkAllowance, connectProvider, convertSubgraphId, convertSubgraphIdtoBase58, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, ensNameBuilder, formatDayHourMin, formatDays, formatDuration, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, generateExampleQueryForField, generateExampleQueryForFieldWithNamedType, generateExampleQueryForFieldWithType, generateExampleQueryForType, getContract, getDate, getERC20Balance, getEventInterface, getEventTypeFromTypename, getGnosisTxLink, getNetworkId, getNetworkName, getTxLink, increaseGas, isV1SubgraphId, nSignalToTokens, nSignalToVSignal, overrides, pickExampleFields, pickExampleTypes, purchaseTargetAmount, saleTargetAmount, signalToTokens, toCamelCase, toGRT, toPlural, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
var UniV2PairAbi = [ | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'getReserves', | ||
outputs: [ | ||
{ internalType: 'uint112', name: '_reserve0', type: 'uint112' }, | ||
{ internalType: 'uint112', name: '_reserve1', type: 'uint112' }, | ||
{ internalType: 'uint32', name: '_blockTimestampLast', type: 'uint32' } | ||
], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'token0', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'token1', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
} | ||
]; | ||
/** | ||
* Get current GRT price in USD | ||
* @param provider Ethers provider | ||
* @returns Current GRT price in USD | ||
*/ | ||
const getGrtPriceUsd = async (provider) => { | ||
const pairContract = new Contract(GrtUsdcUniswapPair, UniV2PairAbi, provider); | ||
const reserves = await pairContract.getReserves(); | ||
const usdc = reserves._reserve0; | ||
const usdcFormatted = Number(utils.formatUnits(usdc, 6)); | ||
const grt = reserves._reserve1; | ||
const grtFormatted = Number(utils.formatEther(grt)); | ||
return usdcFormatted / grtFormatted; | ||
}; | ||
export { AllocationStatus, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, GRTBufferedMaxUint256, GrtUsdcUniswapPair, MAX_WEIGHT, NETWORKS, NetworkEnum, PPM, Revocability, SECONDS_IN_DAY, SIGNAL_PER_MINIMUM_DEPOSIT, SubgraphIndexHealth, TenTrillion, TransactionType, ZERO, addrShortener, appendEth, appendQueryParam, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, buildSubgraphId, checkAllowance, connectProvider, convertSubgraphId, convertSubgraphIdtoBase58, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, ensNameBuilder, formatDayHourMin, formatDays, formatDuration, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, generateExampleQueryForField, generateExampleQueryForFieldWithNamedType, generateExampleQueryForFieldWithType, generateExampleQueryForType, getContract, getDate, getERC20Balance, getEventInterface, getEventTypeFromTypename, getGnosisTxLink, getGrtPriceUsd, getNetworkId, getNetworkName, getTxLink, increaseGas, isV1SubgraphId, nSignalToTokens, nSignalToVSignal, overrides, pickExampleFields, pickExampleTypes, purchaseTargetAmount, saleTargetAmount, signalToTokens, toCamelCase, toGRT, toPlural, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1054,2 +1054,51 @@ 'use strict'; | ||
var UniV2PairAbi = [ | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'getReserves', | ||
outputs: [ | ||
{ internalType: 'uint112', name: '_reserve0', type: 'uint112' }, | ||
{ internalType: 'uint112', name: '_reserve1', type: 'uint112' }, | ||
{ internalType: 'uint32', name: '_blockTimestampLast', type: 'uint32' } | ||
], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'token0', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: 'token1', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
payable: false, | ||
stateMutability: 'view', | ||
type: 'function' | ||
} | ||
]; | ||
/** | ||
* Get current GRT price in USD | ||
* @param provider Ethers provider | ||
* @returns Current GRT price in USD | ||
*/ | ||
const getGrtPriceUsd = async (provider) => { | ||
const pairContract = new ethers.Contract(GrtUsdcUniswapPair, UniV2PairAbi, provider); | ||
const reserves = await pairContract.getReserves(); | ||
const usdc = reserves._reserve0; | ||
const usdcFormatted = Number(ethers.utils.formatUnits(usdc, 6)); | ||
const grt = reserves._reserve1; | ||
const grtFormatted = Number(ethers.utils.formatEther(grt)); | ||
return usdcFormatted / grtFormatted; | ||
}; | ||
exports.ETHEREUM_BLOCK_TIME = ETHEREUM_BLOCK_TIME; | ||
@@ -1104,2 +1153,3 @@ exports.GRTBufferedMaxUint256 = GRTBufferedMaxUint256; | ||
exports.getGnosisTxLink = getGnosisTxLink; | ||
exports.getGrtPriceUsd = getGrtPriceUsd; | ||
exports.getNetworkId = getNetworkId; | ||
@@ -1106,0 +1156,0 @@ exports.getNetworkName = getNetworkName; |
@@ -12,1 +12,2 @@ export * from './graphql.utils'; | ||
export * from './string.utils'; | ||
export * from './grt.utils'; |
{ | ||
"name": "@edgeandnode/common", | ||
"version": "4.11.0", | ||
"version": "4.11.1", | ||
"description": "Common Edge & Node utils and types", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
187037
3535