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

paraswap

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paraswap - npm Package Compare versions

Comparing version 1.1.8 to 1.2.1

3

lib/paraswap-feed.d.ts
import { Address, APIError, OptimalRates, PriceString } from "./types";
export declare class ParaswapFeed {
private network;
constructor(network: number);
web3Provider: any;
constructor(network: number, web3Provider: any);
getRate(srcToken: Address, destToken: Address, srcAmount: PriceString): Promise<OptimalRates | APIError>;
}

@@ -22,10 +22,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Web3 = require("web3");
const _ = require("lodash");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const PriceFeedAbi = __importStar(require("./abi/priceFeed.json"));
const PROVIDER_URL = process.env.PROVIDER_URL;
class ParaswapFeed {
constructor(network) {
constructor(network, web3Provider) {
this.network = network;
this.web3Provider = web3Provider;
}

@@ -35,5 +34,4 @@ getRate(srcToken, destToken, srcAmount) {

try {
const provider = new Web3(new Web3.providers.HttpProvider(PROVIDER_URL));
const { abi, address } = PriceFeedAbi[this.network];
const contract = new provider.eth.Contract(abi, address);
const contract = new this.web3Provider.eth.Contract(abi, address);
const result = yield contract.methods.getBestPrice(srcToken, destToken, srcAmount).call();

@@ -40,0 +38,0 @@ const amount = new bignumber_js_1.default(result.rate).toFixed();

import { AxiosError } from 'axios';
import Web3 = require("web3");
import { Address, APIError, APIQuery, NetworkID, OptimalRates, PriceString, Token, Transaction } from "./types";

@@ -7,7 +6,6 @@ export declare class ParaSwap {

private apiURL;
web3Provider?: Web3 | undefined;
constructor(network: number, apiURL: string, web3Provider?: Web3 | undefined);
web3Provider?: any;
constructor(network?: number, apiURL?: string, web3Provider?: any);
handleAPIError(e: AxiosError): APIError;
getTokens(): Promise<APIError | Token[]>;
getContractRate(srcToken: Address, destToken: Address, srcAmount: PriceString): Promise<OptimalRates | APIError>;
getRate(srcToken: Address, destToken: Address, srcAmount: PriceString, exchanges?: string): Promise<OptimalRates | APIError>;

@@ -14,0 +12,0 @@ buildTx(srcToken: Address, destToken: Address, srcAmount: PriceString, destAmount: PriceString, priceRoute: OptimalRates, userAddress: Address, referrer: string, payTo?: Address, options?: APIQuery): Promise<APIError | Transaction>;

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

const axios_1 = __importDefault(require("axios"));
const Web3 = require("web3");
const async = __importStar(require("async"));

@@ -29,7 +28,7 @@ const qs = __importStar(require("qs"));

const types_1 = require("./types");
const ERC20_ABI = require('./abi/erc20.json');
const ERC20_ABI = __importStar(require("./abi/erc20.json"));
const AUGUSTUS_ABI = __importStar(require("./abi/augustus.json"));
const paraswap_feed_1 = require("./paraswap-feed");
const API_URL = 'https://paraswap.io/api/v1';
class ParaSwap {
constructor(network, apiURL, web3Provider) {
constructor(network = 1, apiURL = API_URL, web3Provider) {
this.network = network;

@@ -58,7 +57,2 @@ this.apiURL = apiURL;

}
getContractRate(srcToken, destToken, srcAmount) {
return __awaiter(this, void 0, void 0, function* () {
return yield new paraswap_feed_1.ParaswapFeed(this.network).getRate(srcToken, destToken, srcAmount);
});
}
getRate(srcToken, destToken, srcAmount, exchanges = '') {

@@ -153,5 +147,4 @@ return __awaiter(this, void 0, void 0, function* () {

return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const provider = new Web3(web3.currentProvider);
const spender = yield this.getSpender(network, provider);
const contract = new provider.eth.Contract(ERC20_ABI, tokenAddress);
const spender = yield this.getSpender(network, this.web3Provider);
const contract = new this.web3Provider.eth.Contract(ERC20_ABI, tokenAddress);
return contract.methods.approve(spender, amount).send({ from: userAddress }, (err, txHash) => {

@@ -158,0 +151,0 @@ if (err)

{
"name": "paraswap",
"version": "1.1.8",
"version": "1.2.1",
"main": "lib/index.js",

@@ -12,16 +12,13 @@ "types": "lib/index.d.ts",

"engines": {
"node": "11.15.0"
"node": ">=10.15.0 <=12.16.1"
},
"dependencies": {
"@hapi/joi": "16.1.7",
"@types/async": "^3.0.3",
"async": "^3.1.0",
"axios": "0.18.1",
"bignumber.js": "8.1.1",
"dotenv": "7.0.0",
"lodash": "^4.17.15",
"qs": "^6.9.1",
"web3": "1.2.1"
"qs": "^6.9.1"
},
"devDependencies": {
"@types/async": "^3.0.3",
"@types/dotenv": "6.1.1",

@@ -31,3 +28,3 @@ "@types/jest": "24.0.18",

"@types/qs": "^6.9.0",
"@types/web3": "^1.0.20",
"dotenv": "7.0.0",
"jest": "24.9.0",

@@ -34,0 +31,0 @@ "ts-jest": "24.1.0",

# ParaSwap SDK
<img src="https://paraswap.io/public/images/800_200.png" width="400px" >
<img src="https://paraswap-achirecture.netlify.com/logo.png" width="400px" >

@@ -33,2 +33,3 @@ ---

const {ParaSwap} = require("paraswap");
const paraswap = new ParaSwap();
```

@@ -39,2 +40,3 @@ ES6 or TypeScript

import {ParaSwap} from "paraswap";
const paraswap = new ParaSwap();
```

@@ -41,0 +43,0 @@

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