Stylistic changes in README
This commit is contained in:
parent
c63e6a320f
commit
2e3273b7bc
46
README.md
46
README.md
@ -6,23 +6,19 @@ This is a library providing convenient and fast access to oracles for Tornado-sp
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
* Create `.npmrc` file in project root with content `@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/`
|
- Create `.npmrc` file in project root with content `@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/`
|
||||||
* Run `npm i @tornado/tornado-oracles`
|
- Run `npm i @tornado/tornado-oracles`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Import
|
### Import
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const {TornadoFeeOracleV5, TornadoFeeOracleV5, TokenPriceOracle} = require('@tornado/tornado-oracles')
|
const { TornadoFeeOracleV5, TornadoFeeOracleV5, TokenPriceOracle } = require('@tornado/tornado-oracles');
|
||||||
or
|
or
|
||||||
import {TornadoFeeOracleV5, TornadoFeeOracleV5, TokenPriceOracle} from '@tornado/tornado-oracles'
|
import { TornadoFeeOracleV5, TornadoFeeOracleV5, TokenPriceOracle } from '@tornado/tornado-oracles';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@ -30,31 +26,31 @@ import {TornadoFeeOracleV5, TornadoFeeOracleV5, TokenPriceOracle} from '@tornado
|
|||||||
##### Estimate withdrawal gas costs
|
##### Estimate withdrawal gas costs
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { TornadoFeeOracleV5 } from '@tornado/tornado-oracles'
|
import { TornadoFeeOracleV5 } from '@tornado/tornado-oracles';
|
||||||
|
|
||||||
const tx: TransactionData = {
|
const tx: TransactionData = {
|
||||||
to: tornadoProxyLightAddress,
|
to: tornadoProxyLightAddress,
|
||||||
data: poolInstance.methods.withdraw(...params).encodeABI(),
|
data: poolInstance.methods.withdraw(...params).encodeABI(),
|
||||||
value: withdrawalProofArgs[5]
|
value: withdrawalProofArgs[5],
|
||||||
}
|
};
|
||||||
|
|
||||||
const feeOracle = new TornadoFeeOracleV5(1, "https://eth.llamarpc.com"); // First parameter - chain ID
|
const feeOracle = new TornadoFeeOracleV5(1, 'https://eth.llamarpc.com'); // First parameter - chain ID
|
||||||
const withdrawalGas = await feeOracle.getGas(tx, "relayer_withdrawal");
|
const withdrawalGas = await feeOracle.getGas(tx, 'relayer_withdrawal');
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Estimate gas price and gas limit to send transaction
|
##### Estimate gas price and gas limit to send transaction
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { TornadoFeeOracleV5 } from '@tornado/tornado-oracles'
|
import { TornadoFeeOracleV5 } from '@tornado/tornado-oracles';
|
||||||
|
|
||||||
const incompleteTx: TransactionData = {
|
const incompleteTx: TransactionData = {
|
||||||
to: tornadoProxyLightAddress,
|
to: tornadoProxyLightAddress,
|
||||||
data: poolInstance.methods.withdraw(...params).encodeABI(),
|
data: poolInstance.methods.withdraw(...params).encodeABI(),
|
||||||
value: withdrawalProofArgs[5]
|
value: withdrawalProofArgs[5],
|
||||||
}
|
};
|
||||||
|
|
||||||
const feeOracle = new TornadoFeeOracleV5(1, "https://eth.llamarpc.com");
|
const feeOracle = new TornadoFeeOracleV5(1, 'https://eth.llamarpc.com');
|
||||||
const transactionType: TxType = "relayer_withdrawal";
|
const transactionType: TxType = 'relayer_withdrawal';
|
||||||
const gasPrice = await feeOracle.getGasPriceInHex(transactionType);
|
const gasPrice = await feeOracle.getGasPriceInHex(transactionType);
|
||||||
const gasLimit = await feeOracle.getGasLimit(incompleteTx, transactionType);
|
const gasLimit = await feeOracle.getGasLimit(incompleteTx, transactionType);
|
||||||
|
|
||||||
@ -64,9 +60,9 @@ const tx: TransactionData = Object.assign({ gasPrice, gasLimit }, incompleteTx);
|
|||||||
##### Get token prices (rate to ETH) for tokens that used in Tornado
|
##### Get token prices (rate to ETH) for tokens that used in Tornado
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { TokenPriceOracle } from '@tornado/tornado-oracles'
|
import { TokenPriceOracle } from '@tornado/tornado-oracles';
|
||||||
|
|
||||||
const priceOracle = new TokenPriceOracle("https://eth.llamarpc.com");
|
const priceOracle = new TokenPriceOracle('https://eth.llamarpc.com');
|
||||||
const tokenPrices = await priceOracle.fetchPrices();
|
const tokenPrices = await priceOracle.fetchPrices();
|
||||||
|
|
||||||
console.log(tokenPrices); // All prices in WEI
|
console.log(tokenPrices); // All prices in WEI
|
||||||
@ -84,4 +80,4 @@ console.log(tokenPrices); // All prices in WEI
|
|||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
Loading…
Reference in New Issue
Block a user