Comparing version 1.1.8 to 1.2.1
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5
121
0
69179
9
1619
- Removed@hapi/joi@16.1.7
- Removed@types/async@^3.0.3
- Removeddotenv@7.0.0
- Removedweb3@1.2.1
- Removed@hapi/address@2.1.4(transitive)
- Removed@hapi/formula@1.2.0(transitive)
- Removed@hapi/hoek@8.5.1(transitive)
- Removed@hapi/joi@16.1.7(transitive)
- Removed@hapi/pinpoint@1.0.2(transitive)
- Removed@hapi/topo@3.1.6(transitive)
- Removed@sindresorhus/is@0.14.0(transitive)
- Removed@szmarczak/http-timer@1.1.2(transitive)
- Removed@types/async@3.2.24(transitive)
- Removed@types/node@10.17.60(transitive)
- Removedaccepts@1.3.8(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedajv@6.12.6(transitive)
- Removedany-promise@1.3.0(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedasn1@0.2.6(transitive)
- Removedasn1.js@4.10.1(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasync-limiter@1.0.1(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbl@1.2.3(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedbn.js@4.11.64.11.84.12.15.2.1(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbrowserify-aes@1.2.0(transitive)
- Removedbrowserify-cipher@1.0.1(transitive)
- Removedbrowserify-des@1.0.2(transitive)
- Removedbrowserify-rsa@4.1.1(transitive)
- Removedbrowserify-sign@4.2.3(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedbuffer-alloc@1.2.0(transitive)
- Removedbuffer-alloc-unsafe@1.1.0(transitive)
- Removedbuffer-crc32@0.2.13(transitive)
- Removedbuffer-fill@1.0.0(transitive)
- Removedbuffer-to-arraybuffer@0.0.5(transitive)
- Removedbuffer-xor@1.0.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcacheable-request@6.1.0(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchownr@1.1.4(transitive)
- Removedcipher-base@1.0.6(transitive)
- Removedclone-response@1.0.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removedcookiejar@2.1.4(transitive)
- Removedcore-util-is@1.0.21.0.3(transitive)
- Removedcors@2.8.5(transitive)
- Removedcreate-ecdh@4.0.4(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedcreate-hmac@1.1.7(transitive)
- Removedcrypto-browserify@3.12.0(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddecompress@4.2.1(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removeddecompress-tar@4.1.1(transitive)
- Removeddecompress-tarbz2@4.1.1(transitive)
- Removeddecompress-targz@4.1.1(transitive)
- Removeddecompress-unzip@4.0.1(transitive)
- Removeddefer-to-connect@1.1.3(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddes.js@1.1.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddiffie-hellman@5.0.3(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removeddotenv@7.0.0(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedee-first@1.1.1(transitive)
- Removedelliptic@6.3.36.6.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedeth-ens-namehash@2.0.8(transitive)
- Removedeth-lib@0.1.290.2.7(transitive)
- Removedethers@4.0.0-beta.3(transitive)
- Removedethjs-unit@0.1.6(transitive)
- Removedeventemitter3@3.1.2(transitive)
- Removedevp_bytestokey@1.0.3(transitive)
- Removedexpress@4.21.1(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfd-slicer@1.1.0(transitive)
- Removedfile-type@3.9.05.2.06.2.0(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfs-constants@1.0.0(transitive)
- Removedfs-extra@4.0.3(transitive)
- Removedfs-minipass@1.2.7(transitive)
- Removedget-stream@2.3.13.0.04.1.05.2.0(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglobal@4.4.0(transitive)
- Removedgot@7.1.09.6.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-symbol-support-x@1.4.2(transitive)
- Removedhas-to-string-tag-x@1.4.1(transitive)
- Removedhash-base@3.0.5(transitive)
- Removedhash.js@1.1.31.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedhttp-https@1.0.0(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedidna-uts46-hx@2.3.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedis-function@1.0.2(transitive)
- Removedis-hex-prefixed@1.0.0(transitive)
- Removedis-natural-number@4.0.1(transitive)
- Removedis-object@1.0.2(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedisurl@1.0.0(transitive)
- Removedjs-sha3@0.5.7(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-buffer@3.0.0(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedkeyv@3.1.0(transitive)
- Removedlowercase-keys@1.0.12.0.0(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmiller-rabin@4.0.1(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removedmin-document@2.19.0(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedminimist@1.2.8(transitive)
- Removedminipass@2.9.0(transitive)
- Removedminizlib@1.3.3(transitive)
- Removedmkdirp@0.5.63.0.1(transitive)
- Removedmkdirp-promise@5.0.1(transitive)
- Removedmock-fs@4.14.0(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednano-json-stream-parser@0.1.2(transitive)
- Removednegotiator@0.6.3(transitive)
- Removednormalize-url@4.5.1(transitive)
- Removednumber-to-bn@1.7.0(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedoboe@2.1.4(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-cancelable@0.3.01.1.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-timeout@1.2.1(transitive)
- Removedparse-asn1@5.1.7(transitive)
- Removedparse-headers@2.0.5(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.10(transitive)
- Removedpbkdf2@3.1.2(transitive)
- Removedpend@1.2.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpify@2.3.03.0.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprepend-http@1.0.42.0.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedpsl@1.14.0(transitive)
- Removedpublic-encrypt@4.0.3(transitive)
- Removedpump@3.0.2(transitive)
- Removedpunycode@2.1.02.3.1(transitive)
- Removedqs@6.13.06.5.3(transitive)
- Removedquery-string@5.1.1(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedrandomfill@1.0.4(transitive)
- Removedrandomhex@0.1.5(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedrequest@2.88.2(transitive)
- Removedresponselike@1.0.2(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedsafe-buffer@5.1.25.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedscrypt-js@2.0.3(transitive)
- Removedscryptsy@2.1.0(transitive)
- Removedseek-bzip@1.0.6(transitive)
- Removedsemver@6.2.0(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedservify@0.1.12(transitive)
- Removedsetimmediate@1.0.41.0.5(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedsha.js@2.4.11(transitive)
- Removedsimple-concat@1.0.1(transitive)
- Removedsimple-get@2.8.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-dirs@2.1.0(transitive)
- Removedstrip-hex-prefix@1.0.0(transitive)
- Removedswarm-js@0.1.39(transitive)
- Removedtar@4.4.19(transitive)
- Removedtar-stream@1.6.2(transitive)
- Removedthrough@2.3.8(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedto-buffer@1.1.1(transitive)
- Removedto-readable-stream@1.0.0(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedultron@1.1.1(transitive)
- Removedunbzip2-stream@1.4.3(transitive)
- Removedunderscore@1.9.1(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedunpipe@1.0.0(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedurl-parse-lax@1.0.03.0.0(transitive)
- Removedurl-set-query@1.0.0(transitive)
- Removedurl-to-options@1.0.1(transitive)
- Removedutf8@3.0.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removeduuid@2.0.13.3.23.4.0(transitive)
- Removedvary@1.1.2(transitive)
- Removedverror@1.10.0(transitive)
- Removedweb3@1.2.1(transitive)
- Removedweb3-bzz@1.2.1(transitive)
- Removedweb3-core@1.2.1(transitive)
- Removedweb3-core-helpers@1.2.1(transitive)
- Removedweb3-core-method@1.2.1(transitive)
- Removedweb3-core-promievent@1.2.1(transitive)
- Removedweb3-core-requestmanager@1.2.1(transitive)
- Removedweb3-core-subscriptions@1.2.1(transitive)
- Removedweb3-eth@1.2.1(transitive)
- Removedweb3-eth-abi@1.2.1(transitive)
- Removedweb3-eth-accounts@1.2.1(transitive)
- Removedweb3-eth-contract@1.2.1(transitive)
- Removedweb3-eth-ens@1.2.1(transitive)
- Removedweb3-eth-iban@1.2.1(transitive)
- Removedweb3-eth-personal@1.2.1(transitive)
- Removedweb3-net@1.2.1(transitive)
- Removedweb3-providers-http@1.2.1(transitive)
- Removedweb3-providers-ipc@1.2.1(transitive)
- Removedweb3-providers-ws@1.2.1(transitive)
- Removedweb3-shh@1.2.1(transitive)
- Removedweb3-utils@1.2.1(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedws@3.3.3(transitive)
- Removedxhr@2.6.0(transitive)
- Removedxhr-request@1.1.0(transitive)
- Removedxhr-request-promise@0.1.3(transitive)
- Removedxhr2-cookies@1.1.0(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyallist@3.1.1(transitive)
- Removedyauzl@2.10.0(transitive)