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

@compound-finance/compound-js

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compound-finance/compound-js - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

dist/nodejs/openPriceFeed.d.ts

34

dist/nodejs/priceFeed.js

@@ -56,2 +56,4 @@ "use strict";

var underlyingDecimals = constants_1.decimals[underlyingName];
// The open price feed only reveals the BTC price
underlyingName = underlyingName === 'WBTC' ? 'BTC' : underlyingName;
return [assetIsCToken, cTokenName, cTokenAddress, underlyingName, underlyingAddress, underlyingDecimals];

@@ -96,3 +98,3 @@ }

return __awaiter(this, void 0, void 0, function () {
var errorPrefix, _a, assetIsCToken, cTokenName, cTokenAddress, underlyingName, underlyingAddress, underlyingDecimals, _b, inAssetIsCToken, inAssetCTokenName, inAssetCTokenAddress, inAssetUnderlyingName, inAssetUnderlyingAddress, inAssetUnderlyingDecimals, priceFeedAddress, trxOptions, priceMantissa, inAssetPriceMantissa, assetUnderlyingPrice, inAssetUnderlyingPrice, assetCTokensInUnderlying, inAssetCTokensInUnderlying, result, assetInOther, assetInOther, assetInOther, cTokensInUnderlying;
var errorPrefix, _a, assetIsCToken, cTokenName, cTokenAddress, underlyingName, underlyingAddress, underlyingDecimals, _b, inAssetIsCToken, inAssetCTokenName, inAssetCTokenAddress, inAssetUnderlyingName, inAssetUnderlyingAddress, inAssetUnderlyingDecimals, priceFeedAddress, trxOptions, assetUnderlyingPrice, inAssetUnderlyingPrice, assetCTokensInUnderlying, inAssetCTokensInUnderlying, result, assetInOther, assetInOther, assetInOther, cTokensInUnderlying;
return __generator(this, function (_c) {

@@ -111,26 +113,20 @@ switch (_c.label) {

};
return [4 /*yield*/, eth.read(priceFeedAddress, 'getUnderlyingPrice', [cTokenAddress], trxOptions)];
return [4 /*yield*/, eth.read(priceFeedAddress, 'price', [underlyingName], trxOptions)];
case 2:
priceMantissa = _c.sent();
inAssetPriceMantissa = 1e18;
if (!(inAssetUnderlyingName !== constants_1.constants.ETH)) return [3 /*break*/, 4];
return [4 /*yield*/, eth.read(priceFeedAddress, 'getUnderlyingPrice', [inAssetCTokenAddress], trxOptions)];
assetUnderlyingPrice = _c.sent();
return [4 /*yield*/, eth.read(priceFeedAddress, 'price', [inAssetUnderlyingName], trxOptions)];
case 3:
inAssetPriceMantissa = _c.sent();
_c.label = 4;
inAssetUnderlyingPrice = _c.sent();
if (!assetIsCToken) return [3 /*break*/, 5];
return [4 /*yield*/, cTokenExchangeRate.bind(this)(cTokenAddress, cTokenName, underlyingDecimals)];
case 4:
assetUnderlyingPrice = priceMantissa / (1e18 / (Math.pow(10, underlyingDecimals - 18)));
inAssetUnderlyingPrice = inAssetPriceMantissa / (1e18 / (Math.pow(10, inAssetUnderlyingDecimals - 18)));
if (!assetIsCToken) return [3 /*break*/, 6];
return [4 /*yield*/, cTokenExchangeRate.bind(this)(cTokenAddress, cTokenName, underlyingDecimals)];
assetCTokensInUnderlying = _c.sent();
_c.label = 5;
case 5:
assetCTokensInUnderlying = _c.sent();
_c.label = 6;
if (!inAssetIsCToken) return [3 /*break*/, 7];
return [4 /*yield*/, cTokenExchangeRate.bind(this)(inAssetCTokenAddress, inAssetCTokenName, inAssetUnderlyingDecimals)];
case 6:
if (!inAssetIsCToken) return [3 /*break*/, 8];
return [4 /*yield*/, cTokenExchangeRate.bind(this)(inAssetCTokenAddress, inAssetCTokenName, inAssetUnderlyingDecimals)];
inAssetCTokensInUnderlying = _c.sent();
_c.label = 7;
case 7:
inAssetCTokensInUnderlying = _c.sent();
_c.label = 8;
case 8:
if (!assetIsCToken && !inAssetIsCToken) {

@@ -137,0 +133,0 @@ result = assetUnderlyingPrice / inAssetUnderlyingPrice;

{
"name": "@compound-finance/compound-js",
"browser": "dist/browser/compound.min.js",
"version": "0.0.9",
"version": "0.0.10",
"description": "A JavaScript SDK for Ethereum and the Compound Protocol.",

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

@@ -16,3 +16,3 @@ import { ethers } from 'ethers';

const underlyingName = assetIsCToken ? asset.slice(1, asset.length) : asset;
let underlyingName = assetIsCToken ? asset.slice(1, asset.length) : asset;
const underlyingAddress = address[this._network.name][underlyingName];

@@ -26,2 +26,5 @@

// The open price feed only reveals the BTC price
underlyingName = underlyingName === 'WBTC' ? 'BTC' : underlyingName;
return [assetIsCToken, cTokenName, cTokenAddress, underlyingName, underlyingAddress, underlyingDecimals];

@@ -74,12 +77,5 @@ }

const priceMantissa = await eth.read(priceFeedAddress, 'getUnderlyingPrice', [ cTokenAddress ], trxOptions);
const assetUnderlyingPrice = await eth.read(priceFeedAddress, 'price', [ underlyingName ], trxOptions);
const inAssetUnderlyingPrice = await eth.read(priceFeedAddress, 'price', [ inAssetUnderlyingName ], trxOptions);
let inAssetPriceMantissa = 1e18;
if (inAssetUnderlyingName !== constants.ETH) {
inAssetPriceMantissa = await eth.read(priceFeedAddress, 'getUnderlyingPrice', [ inAssetCTokenAddress ], trxOptions);
}
const assetUnderlyingPrice = priceMantissa / (1e18 / (Math.pow(10, underlyingDecimals - 18)));
const inAssetUnderlyingPrice = inAssetPriceMantissa / (1e18 / (Math.pow(10, inAssetUnderlyingDecimals - 18)));
let assetCTokensInUnderlying, inAssetCTokensInUnderlying;

@@ -86,0 +82,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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