New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.4.5 to 0.5.0

dist/nodejs/comet.d.ts

3

dist/nodejs/api.d.ts

@@ -20,4 +20,3 @@ /**

* const account = await Compound.api.account({
* "addresses": "0xB61C5971d9c0472befceFfbE662555B78284c307",
* "network": "ropsten"
* "addresses": "0xa0df350d2637096571F7A701CBc1C5fdE30dF76A",
* });

@@ -24,0 +23,0 @@ *

@@ -44,4 +44,3 @@ "use strict";

* const account = await Compound.api.account({
* "addresses": "0xB61C5971d9c0472befceFfbE662555B78284c307",
* "network": "ropsten"
* "addresses": "0xa0df350d2637096571F7A701CBc1C5fdE30dF76A",
* });

@@ -48,0 +47,0 @@ *

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

exports.createDelegateSignature = exports.delegateBySig = exports.delegate = exports.claimComp = exports.getCompAccrued = exports.getCompBalance = void 0;
var ethers_1 = require("ethers");
var eth = require("./eth");

@@ -62,29 +61,3 @@ var helpers_1 = require("./helpers");

var EIP712_1 = require("./EIP712");
var keccak256 = ethers_1.ethers.utils.keccak256;
/**
* Applies the EIP-55 checksum to an Ethereum address.
*
* @param {string} _address The Ethereum address to apply the checksum.
*
* @returns {string} Returns a string of the Ethereum address.
*/
function toChecksumAddress(_address) {
var chars = _address.toLowerCase().substring(2).split('');
var expanded = new Uint8Array(40);
for (var i = 0; i < 40; i++) {
expanded[i] = chars[i].charCodeAt(0);
}
var hash = keccak256(expanded);
var ret = '';
for (var i = 0; i < _address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += _address[i].toUpperCase();
}
else {
ret += _address[i];
}
}
return ret;
}
/**
* Get the balance of COMP tokens held by an address.

@@ -125,3 +98,3 @@ *

try {
_address = toChecksumAddress(_address);
_address = helpers_1.toChecksumAddress(_address);
}

@@ -182,3 +155,3 @@ catch (e) {

try {
_address = toChecksumAddress(_address);
_address = helpers_1.toChecksumAddress(_address);
}

@@ -301,3 +274,3 @@ catch (e) {

try {
_address = toChecksumAddress(_address);
_address = helpers_1.toChecksumAddress(_address);
}

@@ -370,3 +343,3 @@ catch (e) {

try {
_address = toChecksumAddress(_address);
_address = helpers_1.toChecksumAddress(_address);
}

@@ -373,0 +346,0 @@ catch (e) {

/**
* @file Comptroller
* @desc These methods facilitate interactions with the Comptroller smart
* contract.
* contract. Methods like `claimComp` are in the Governance/COMP section.
*/

@@ -6,0 +6,0 @@ import { CallOptions, TrxResponse } from './types';

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

* @desc These methods facilitate interactions with the Comptroller smart
* contract.
* contract. Methods like `claimComp` are in the Governance/COMP section.
*/

@@ -8,0 +8,0 @@ var __assign = (this && this.__assign) || function () {

@@ -0,1 +1,291 @@

export declare const cometConstants: {
moveToParentClass: {
Comet: string;
COMP: string;
WBTC: string;
WETH: string;
UNI: string;
LINK: string;
USDC: string;
WBTC_e: string;
WAVAX: string;
};
address: {
mainnet: {
COMP: {
contract: string;
priceFeed: string;
};
WBTC: {
contract: string;
priceFeed: string;
};
WETH: {
contract: string;
priceFeed: string;
};
UNI: {
contract: string;
priceFeed: string;
};
LINK: {
contract: string;
priceFeed: string;
};
USDC: {
contract: string;
priceFeed: string;
};
Comet: string;
};
kovan: {
COMP: {
contract: string;
priceFeed: string;
};
WBTC: {
contract: string;
priceFeed: string;
};
WETH: {
contract: string;
priceFeed: string;
};
UNI: {
contract: string;
priceFeed: string;
};
LINK: {
contract: string;
priceFeed: string;
};
USDC: {
contract: string;
priceFeed: string;
};
Comet: string;
};
fuji: {
WBTC_e: {
contract: string;
priceFeed: string;
};
WAVAX: {
contract: string;
priceFeed: string;
};
USDC: {
contract: string;
priceFeed: string;
};
Comet: string;
};
};
abi: {
mainnet: {
Comet: ({
inputs: any[];
name: string;
type: string;
anonymous?: undefined;
outputs?: undefined;
stateMutability?: undefined;
} | {
anonymous: boolean;
inputs: {
indexed: boolean;
internalType: string;
name: string;
type: string;
}[];
name: string;
type: string;
outputs?: undefined;
stateMutability?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
components: {
internalType: string;
name: string;
type: string;
}[];
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
})[];
};
kovan: {
Comet: ({
inputs: any[];
name: string;
type: string;
anonymous?: undefined;
outputs?: undefined;
stateMutability?: undefined;
} | {
anonymous: boolean;
inputs: {
indexed: boolean;
internalType: string;
name: string;
type: string;
}[];
name: string;
type: string;
outputs?: undefined;
stateMutability?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
components: {
internalType: string;
name: string;
type: string;
}[];
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
})[];
};
fuji: {
Comet: ({
inputs: any[];
name: string;
type: string;
anonymous?: undefined;
outputs?: undefined;
stateMutability?: undefined;
} | {
anonymous: boolean;
inputs: {
indexed: boolean;
internalType: string;
name: string;
type: string;
}[];
name: string;
type: string;
outputs?: undefined;
stateMutability?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
} | {
inputs: {
internalType: string;
name: string;
type: string;
}[];
name: string;
outputs: {
components: {
internalType: string;
name: string;
type: string;
}[];
internalType: string;
name: string;
type: string;
}[];
stateMutability: string;
type: string;
anonymous?: undefined;
})[];
};
};
decimals: {
mainnet: {
COMP: number;
WBTC: number;
WETH: number;
UNI: number;
LINK: number;
USDC: number;
};
kovan: {
COMP: number;
WBTC: number;
WETH: number;
UNI: number;
LINK: number;
USDC: number;
};
fuji: {
WBTC_e: number;
WAVAX: number;
USDC: number;
};
};
collaterals: {
mainnet: string[];
kovan: string[];
fuji: string[];
};
base: {
mainnet: string;
kovan: string;
fuji: string;
};
};
export declare const constants: {

@@ -6,2 +296,3 @@ PriceFeed: string;

GovernorBravo: string;
Comet: string;
Comptroller: string;

@@ -8,0 +299,0 @@ Reservoir: string;

/**
* @file cToken
* @file Compound.js cToken
* @desc These methods facilitate interactions with the cToken smart

@@ -4,0 +4,0 @@ * contracts.

"use strict";
/**
* @file cToken
* @file Compound.js cToken
* @desc These methods facilitate interactions with the cToken smart

@@ -5,0 +5,0 @@ * contracts.

@@ -45,2 +45,3 @@ "use strict";

var ethers_1 = require("ethers");
var util_1 = require("./util");
var JsonRpc;

@@ -259,3 +260,3 @@ (function (JsonRpc) {

return __awaiter(this, void 0, void 0, function () {
var _provider, networkId, network;
var _provider, networkId, unknown, network;
return __generator(this, function (_a) {

@@ -280,3 +281,7 @@ switch (_a.label) {

networkId = isNaN(networkId) ? 0 : +networkId;
network = ethers_1.ethers.providers.getNetwork(networkId) || { name: 'unknown' };
unknown = { chainId: 0, name: 'unknown' };
network = ethers_1.ethers.providers.getNetwork(networkId) || unknown;
if (network.name === unknown.name) {
network.name = util_1.getNetNameWithChainId(network.chainId) || unknown.name;
}
return [2 /*return*/, {

@@ -283,0 +288,0 @@ id: networkId,

@@ -15,1 +15,11 @@ import { CompoundInstance } from './types';

export declare function netId(_compound: CompoundInstance): Promise<void>;
/**
* Applies the EIP-55 checksum to an Ethereum address.
*
* @hidden
*
* @param {string} _address The Ethereum address to apply the checksum.
*
* @returns {string} Returns a string of the Ethereum address.
*/
export declare function toChecksumAddress(_address: string): string;

@@ -39,3 +39,4 @@ "use strict";

exports.__esModule = true;
exports.netId = void 0;
exports.toChecksumAddress = exports.netId = void 0;
var ethers_1 = require("ethers");
/**

@@ -69,2 +70,31 @@ * This function acts like a decorator for all methods that interact with the

exports.netId = netId;
var keccak256 = ethers_1.ethers.utils.keccak256;
/**
* Applies the EIP-55 checksum to an Ethereum address.
*
* @hidden
*
* @param {string} _address The Ethereum address to apply the checksum.
*
* @returns {string} Returns a string of the Ethereum address.
*/
function toChecksumAddress(_address) {
var chars = _address.toLowerCase().substring(2).split('');
var expanded = new Uint8Array(40);
for (var i = 0; i < 40; i++) {
expanded[i] = chars[i].charCodeAt(0);
}
var hash = keccak256(expanded);
var ret = '';
for (var i = 0; i < _address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += _address[i].toUpperCase();
}
else {
ret += _address[i];
}
}
return ret;
}
exports.toChecksumAddress = toChecksumAddress;
//# sourceMappingURL=helpers.js.map

@@ -7,6 +7,7 @@ /**

import { ethers } from 'ethers';
import * as api from './api';
import * as comet from './comet';
import * as comp from './comp';
import * as eth from './eth';
import * as util from './util';
import * as comp from './comp';
import * as api from './api';
import { Provider, CompoundOptions, CompoundInstance } from './types';

@@ -21,2 +22,3 @@ /**

* @example
*
* ```

@@ -29,3 +31,3 @@ * var compound = new Compound(window.ethereum); // web browser

*
* var compound = new Compound('ropsten'); // Uses Ethers.js fallback (for testing only)
* var compound = new Compound('goerli'); // Uses Ethers.js fallback (for testing only)
*

@@ -93,6 +95,25 @@ * // Init with private key (server side)

comp: {
getCompAccrued: typeof comp.getCompAccrued;
getCompBalance: typeof comp.getCompBalance;
getCompAccrued: typeof comp.getCompAccrued;
};
comet: {
borrowBalanceOf: typeof comet.borrowBalanceOf;
collateralBalanceOf: typeof comet.collateralBalanceOf;
getAssetInfo: typeof comet.getAssetInfo;
getAssetInfoByAddress: typeof comet.getAssetInfoByAddress;
getAssetInfoBySymbol: typeof comet.getAssetInfoBySymbol;
getBaseAssetName: typeof comet.getBaseAssetName;
getBorrowRate: typeof comet.getBorrowRate;
getPrice: typeof comet.getPrice;
getReserves: typeof comet.getReserves;
getSupplyRate: typeof comet.getSupplyRate;
getSupportedCollaterals: typeof comet.getSupportedCollaterals;
getSupportedNetworkNames: typeof comet.getSupportedNetworkNames;
getUtilization: typeof comet.getUtilization;
isBorrowCollateralized: typeof comet.isBorrowCollateralized;
isLiquidatable: typeof comet.isLiquidatable;
quoteCollateral: typeof comet.quoteCollateral;
targetReserves: typeof comet.targetReserves;
};
};
export = Compound;

@@ -19,10 +19,11 @@ "use strict";

var ethers_1 = require("ethers");
var eth = require("./eth");
var util = require("./util");
var api = require("./api");
var comet = require("./comet");
var comp = require("./comp");
var comptroller = require("./comptroller");
var cToken = require("./cToken");
var eth = require("./eth");
var gov = require("./gov");
var priceFeed = require("./priceFeed");
var comp = require("./comp");
var gov = require("./gov");
var api = require("./api");
var util = require("./util");
var constants_1 = require("./constants");

@@ -39,2 +40,3 @@ // Turn off Ethers.js warnings

* @example
*
* ```

@@ -47,3 +49,3 @@ * var compound = new Compound(window.ethereum); // web browser

*
* var compound = new Compound('ropsten'); // Uses Ethers.js fallback (for testing only)
* var compound = new Compound('goerli'); // Uses Ethers.js fallback (for testing only)
*

@@ -70,3 +72,3 @@ * // Init with private key (server side)

// eslint-disable-next-line @typescript-eslint/no-explicit-any
var instance = __assign(__assign(__assign(__assign(__assign({ _originalProvider: originalProvider, _provider: provider }, comptroller), cToken), priceFeed), gov), { claimComp: comp.claimComp, delegate: comp.delegate, delegateBySig: comp.delegateBySig, createDelegateSignature: comp.createDelegateSignature });
var instance = __assign(__assign(__assign(__assign(__assign({ _originalProvider: originalProvider, _provider: provider }, comptroller), cToken), gov), priceFeed), { claimComp: comp.claimComp, delegate: comp.delegate, delegateBySig: comp.delegateBySig, createDelegateSignature: comp.createDelegateSignature });
// Instance needs to know which network the provider connects to, so it can

@@ -78,2 +80,15 @@ // use the correct contract addresses.

});
instance.comet = {
_compoundInstance: instance,
absorb: comet.absorb,
allow: comet.allow,
allowBySig: comet.allowBySig,
buyCollateral: comet.buyCollateral,
createAllowSignature: comet.createAllowSignature,
supply: comet.supply,
transfer: comet.transfer,
withdraw: comet.withdraw,
withdrawFrom: comet.withdrawFrom,
withdrawTo: comet.withdrawTo
};
return instance;

@@ -87,7 +102,26 @@ };

Compound.comp = {
getCompBalance: comp.getCompBalance,
getCompAccrued: comp.getCompAccrued
getCompAccrued: comp.getCompAccrued,
getCompBalance: comp.getCompBalance
};
Compound.comet = {
borrowBalanceOf: comet.borrowBalanceOf,
collateralBalanceOf: comet.collateralBalanceOf,
getAssetInfo: comet.getAssetInfo,
getAssetInfoByAddress: comet.getAssetInfoByAddress,
getAssetInfoBySymbol: comet.getAssetInfoBySymbol,
getBaseAssetName: comet.getBaseAssetName,
getBorrowRate: comet.getBorrowRate,
getPrice: comet.getPrice,
getReserves: comet.getReserves,
getSupplyRate: comet.getSupplyRate,
getSupportedCollaterals: comet.getSupportedCollaterals,
getSupportedNetworkNames: comet.getSupportedNetworkNames,
getUtilization: comet.getUtilization,
isBorrowCollateralized: comet.isBorrowCollateralized,
isLiquidatable: comet.isLiquidatable,
quoteCollateral: comet.quoteCollateral,
targetReserves: comet.targetReserves
};
Object.assign(Compound, constants_1.constants);
module.exports = Compound;
//# sourceMappingURL=index.js.map

@@ -140,2 +140,3 @@ import { Signer as AbstractSigner } from '@ethersproject/abstract-signer/lib/index';

name: string;
version?: string;
chainId: number;

@@ -152,3 +153,7 @@ verifyingContract: string;

}
export declare type EIP712Types = VoteTypes | DelegateTypes;
export interface AllowTypes {
EIP712Domain: EIP712Type[];
Authorization: EIP712Type[];
}
export declare type EIP712Types = VoteTypes | DelegateTypes | AllowTypes;
export interface DelegateSignatureMessage {

@@ -163,3 +168,10 @@ delegatee: string;

}
export declare type EIP712Message = DelegateSignatureMessage | VoteSignatureMessage;
export interface AllowSignatureMessage {
owner: string;
manager: string;
isAllowed: boolean;
nonce: number;
expiry: number;
}
export declare type EIP712Message = DelegateSignatureMessage | VoteSignatureMessage | AllowSignatureMessage;
interface SimpleEthersProvider {

@@ -173,2 +185,12 @@ jsonRpcFetchFunc(method: string, parameters: any[]): any;

}
export interface AssetInfo {
offset: number;
asset: string;
priceFeed: string;
scale: BigNumber;
borrowCollateralFactor: BigNumber;
liquidateCollateralFactor: BigNumber;
liquidationFactor: BigNumber;
supplyCap: BigNumber;
}
export {};

@@ -57,5 +57,5 @@ /**

* ```
* console.log('Ropsten : ', Compound.util.getNetNameWithChainId(3));
* console.log('Goerli : ', Compound.util.getNetNameWithChainId(5));
* ```
*/
export declare function getNetNameWithChainId(chainId: number): string;

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

* ```
* console.log('Ropsten : ', Compound.util.getNetNameWithChainId(3));
* console.log('Goerli : ', Compound.util.getNetNameWithChainId(5));
* ```

@@ -201,3 +201,5 @@ */

5: 'goerli',
42: 'kovan'
42: 'kovan',
43113: 'fuji',
43114: 'ava-mainnet'
};

@@ -204,0 +206,0 @@ return networks[chainId];

{
"name": "@compound-finance/compound-js",
"version": "0.4.5",
"version": "0.5.0",
"author": "Compound Labs, Inc.",

@@ -5,0 +5,0 @@ "description": "A JavaScript SDK for Ethereum and the Compound Protocol.",

@@ -8,3 +8,3 @@ # Compound.js

[Compound.js Documentation](https://compound.finance/docs/compound-js)
[Compound.js Documentation](https://docs.compound.finance/compound-js/)

@@ -93,3 +93,3 @@ This SDK is in **open beta**, and is constantly under development. **USE AT YOUR OWN RISK**.

```
npm install @compound-finance/compound-js
npm install ethers @compound-finance/compound-js
```

@@ -107,3 +107,3 @@

See the docblock comments above each function definition or the official [Compound.js Documentation](https://compound.finance/docs/compound-js).
See the docblock comments above each function definition or the official [Compound.js Documentation](https://docs.compound.finance/compound-js/).

@@ -121,3 +121,3 @@ ## Instance Creation

var compound = new Compound('ropsten'); // Uses Ethers.js fallback (for testing only)
var compound = new Compound('goerli'); // Uses Ethers.js fallback (for testing only)

@@ -144,3 +144,3 @@ // Init with private key (server side)

const cUsdtAddress = Compound.util.getAddress(Compound.cUSDT);
// Mainnet cUSDT address. Second parameter can be a network like 'ropsten'.
// Mainnet cUSDT address. Second parameter can be a network like 'goerli'.
```

@@ -184,3 +184,3 @@

The [Compound API](https://compound.finance/docs/api) is accessible from Compound.js. The corresponding services are defined in the `api` namespace on the class.
The [Compound API](https://docs.compound.finance/v2/api) is accessible from Compound.js. The corresponding services are defined in the `api` namespace on the class.

@@ -192,3 +192,3 @@ - `Compound.api.account`

The governance method requires a second parameter (string) for the corresponding endpoint shown in the [documentation](https://compound.finance/docs/api#GovernanceService).
The governance method requires a second parameter (string) for the corresponding endpoint shown in the [documentation](https://docs.compound.finance/v2/api/#GovernanceService).

@@ -204,4 +204,3 @@ - `proposals`

const account = await Compound.api.account({
"addresses": "0xB61C5971d9c0472befceFfbE662555B78284c307",
"network": "ropsten"
"addresses": "0xB61C5971d9c0472befceFfbE662555B78284c307"
});

@@ -208,0 +207,0 @@

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

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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