@across-protocol/sdk 4.3.139-alpha.1 → 4.3.139-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/cjs/src/gasPriceOracle/oracle.d.ts +1 -3
- package/dist/cjs/src/gasPriceOracle/oracle.js +11 -15
- package/dist/cjs/src/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/src/gasPriceOracle/types.d.ts +1 -6
- package/dist/cjs/src/gasPriceOracle/types.js +0 -5
- package/dist/cjs/src/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.d.ts +1 -2
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js +0 -5
- package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js +0 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/esm/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/esm/src/gasPriceOracle/oracle.d.ts +1 -3
- package/dist/esm/src/gasPriceOracle/oracle.js +12 -17
- package/dist/esm/src/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/src/gasPriceOracle/types.d.ts +1 -6
- package/dist/esm/src/gasPriceOracle/types.js +0 -4
- package/dist/esm/src/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.d.ts +1 -2
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js +1 -6
- package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.js +0 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/types/src/gasPriceOracle/index.d.ts +1 -1
- package/dist/types/src/gasPriceOracle/index.d.ts.map +1 -1
- package/dist/types/src/gasPriceOracle/oracle.d.ts +1 -3
- package/dist/types/src/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/src/gasPriceOracle/types.d.ts +1 -6
- package/dist/types/src/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts +1 -2
- package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/gasPriceOracle/index.ts +1 -1
- package/src/gasPriceOracle/oracle.ts +4 -23
- package/src/gasPriceOracle/types.ts +1 -11
- package/src/relayFeeCalculator/chain-queries/factory.ts +2 -16
- package/src/relayFeeCalculator/chain-queries/index.ts +0 -1
- package/dist/cjs/src/gasPriceOracle/adapters/tron.d.ts +0 -4
- package/dist/cjs/src/gasPriceOracle/adapters/tron.js +0 -58
- package/dist/cjs/src/gasPriceOracle/adapters/tron.js.map +0 -1
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -16
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js +0 -52
- package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +0 -1
- package/dist/esm/src/gasPriceOracle/adapters/tron.d.ts +0 -10
- package/dist/esm/src/gasPriceOracle/adapters/tron.js +0 -68
- package/dist/esm/src/gasPriceOracle/adapters/tron.js.map +0 -1
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -32
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js +0 -65
- package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +0 -1
- package/dist/types/src/gasPriceOracle/adapters/tron.d.ts +0 -11
- package/dist/types/src/gasPriceOracle/adapters/tron.d.ts.map +0 -1
- package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -33
- package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts.map +0 -1
- package/src/gasPriceOracle/adapters/tron.ts +0 -50
- package/src/relayFeeCalculator/chain-queries/tvmQuery.ts +0 -88
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
import { PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
3
|
-
import { TronWeb } from "tronweb";
|
|
4
|
-
import { getGasPriceEstimate, GasPriceEstimateOptions } from "../../gasPriceOracle";
|
|
5
|
-
import { TvmGasPriceEstimate } from "../../gasPriceOracle/types";
|
|
6
|
-
import { RelayData } from "../../interfaces";
|
|
7
|
-
import { Address, BigNumber, BigNumberish, bnZero, EvmAddress, TransactionCostEstimate } from "../../utils";
|
|
8
|
-
import { arch } from "../..";
|
|
9
|
-
import { Logger } from "../relayFeeCalculator";
|
|
10
|
-
import { QueryBase, SymbolMappingType } from "./baseQuery";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A TVM-specific query implementation for TRON.
|
|
14
|
-
*
|
|
15
|
-
* TRON's JSON-RPC is EVM-compatible for reads and gas estimation, so this
|
|
16
|
-
* class extends QueryBase and overrides only the gas price oracle dispatch
|
|
17
|
-
* to use TronWeb (energy/bandwidth pricing) instead of the EVM oracle.
|
|
18
|
-
*
|
|
19
|
-
* The ethers provider is derived from the TronWeb instance's fullNode URL.
|
|
20
|
-
*/
|
|
21
|
-
export class TvmQuery extends QueryBase {
|
|
22
|
-
readonly tronWeb: TronWeb;
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
tronWeb: TronWeb,
|
|
26
|
-
symbolMapping: SymbolMappingType,
|
|
27
|
-
spokePoolAddress: string,
|
|
28
|
-
simulatedRelayerAddress: EvmAddress,
|
|
29
|
-
logger: Logger,
|
|
30
|
-
coingeckoProApiKey?: string,
|
|
31
|
-
fixedGasPrice?: BigNumberish,
|
|
32
|
-
coingeckoBaseCurrency: string = "eth"
|
|
33
|
-
) {
|
|
34
|
-
const provider = new providers.StaticJsonRpcProvider(tronWeb.fullNode.host);
|
|
35
|
-
super(
|
|
36
|
-
provider,
|
|
37
|
-
symbolMapping,
|
|
38
|
-
spokePoolAddress,
|
|
39
|
-
simulatedRelayerAddress,
|
|
40
|
-
logger,
|
|
41
|
-
coingeckoProApiKey,
|
|
42
|
-
fixedGasPrice,
|
|
43
|
-
coingeckoBaseCurrency
|
|
44
|
-
);
|
|
45
|
-
this.tronWeb = tronWeb;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Estimate the gas cost of a transaction using TVM energy pricing.
|
|
50
|
-
*
|
|
51
|
-
* Gas units (energy) are estimated via the ethers provider (TRON's JSON-RPC
|
|
52
|
-
* returns energy units for eth_estimateGas). The energy price is queried
|
|
53
|
-
* from TronWeb's gas price oracle.
|
|
54
|
-
*/
|
|
55
|
-
override async estimateGas(
|
|
56
|
-
unsignedTx: PopulatedTransaction,
|
|
57
|
-
senderAddress: Address,
|
|
58
|
-
provider: providers.Provider,
|
|
59
|
-
options: Partial<
|
|
60
|
-
GasPriceEstimateOptions & {
|
|
61
|
-
gasPrice: BigNumberish;
|
|
62
|
-
gasUnits: BigNumberish;
|
|
63
|
-
}
|
|
64
|
-
> = {}
|
|
65
|
-
): Promise<TransactionCostEstimate> {
|
|
66
|
-
const { gasPrice: _gasPrice, gasUnits } = options;
|
|
67
|
-
|
|
68
|
-
const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
69
|
-
|
|
70
|
-
const [nativeGasCost, gasPriceEstimate] = await Promise.all([
|
|
71
|
-
gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
|
|
72
|
-
_gasPrice
|
|
73
|
-
? Promise.resolve({ energyPrice: BigNumber.from(_gasPrice.toString()), bandwidthPrice: bnZero })
|
|
74
|
-
: getGasPriceEstimate(this.tronWeb),
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
78
|
-
|
|
79
|
-
const gasPrice = (gasPriceEstimate as TvmGasPriceEstimate).energyPrice;
|
|
80
|
-
const tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
81
|
-
|
|
82
|
-
return { nativeGasCost, tokenGasCost, gasPrice };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
override getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
|
|
86
|
-
return arch.tvm.getAuxiliaryNativeTokenCost(deposit);
|
|
87
|
-
}
|
|
88
|
-
}
|