@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
|
@@ -2,17 +2,15 @@ import assert from "assert";
|
|
|
2
2
|
import { Transport } from "viem";
|
|
3
3
|
import { providers } from "ethers";
|
|
4
4
|
import { CHAIN_IDs } from "../constants";
|
|
5
|
-
import { BigNumber, fixedPointAdjustment, isEvmProvider,
|
|
5
|
+
import { BigNumber, fixedPointAdjustment, isEvmProvider, toBNWei, isDefined } from "../utils";
|
|
6
6
|
import { SVMProvider as SolanaProvider } from "../arch/svm";
|
|
7
|
-
import {
|
|
8
|
-
import { EvmGasPriceEstimate, GasPriceEstimate, SvmGasPriceEstimate, TvmGasPriceEstimate } from "./types";
|
|
7
|
+
import { EvmGasPriceEstimate, GasPriceEstimate, SvmGasPriceEstimate } from "./types";
|
|
9
8
|
import { getPublicClient } from "./util";
|
|
10
9
|
import * as arbitrum from "./adapters/arbitrum";
|
|
11
10
|
import * as ethereum from "./adapters/ethereum";
|
|
12
11
|
import * as polygon from "./adapters/polygon";
|
|
13
12
|
import * as lineaViem from "./adapters/linea-viem";
|
|
14
13
|
import * as solana from "./adapters/solana";
|
|
15
|
-
import * as tron from "./adapters/tron";
|
|
16
14
|
import { EvmProvider } from "../arch/evm/types";
|
|
17
15
|
|
|
18
16
|
export interface GasPriceEstimateOptions {
|
|
@@ -58,12 +56,6 @@ export async function getGasPriceEstimate(
|
|
|
58
56
|
opts?: Partial<GasPriceEstimateOptions>
|
|
59
57
|
): Promise<SvmGasPriceEstimate>;
|
|
60
58
|
|
|
61
|
-
// Overload For TVM providers
|
|
62
|
-
export async function getGasPriceEstimate(
|
|
63
|
-
provider: TronWeb,
|
|
64
|
-
opts?: Partial<GasPriceEstimateOptions>
|
|
65
|
-
): Promise<TvmGasPriceEstimate>;
|
|
66
|
-
|
|
67
59
|
/**
|
|
68
60
|
* Provide an estimate for the current gas price for a particular chain.
|
|
69
61
|
* @param provider A valid ethers provider.
|
|
@@ -71,24 +63,12 @@ export async function getGasPriceEstimate(
|
|
|
71
63
|
* @returns An object of type GasPriceEstimate.
|
|
72
64
|
*/
|
|
73
65
|
export async function getGasPriceEstimate(
|
|
74
|
-
provider: EvmProvider | SolanaProvider
|
|
66
|
+
provider: EvmProvider | SolanaProvider,
|
|
75
67
|
opts: Partial<GasPriceEstimateOptions> = {}
|
|
76
68
|
): Promise<GasPriceEstimate> {
|
|
77
69
|
const baseFeeMultiplier = opts.baseFeeMultiplier ?? toBNWei("1");
|
|
78
70
|
const priorityFeeMultiplier = opts.priorityFeeMultiplier ?? toBNWei("1");
|
|
79
71
|
|
|
80
|
-
// Exit here if we need to estimate on TRON.
|
|
81
|
-
if (isTvmProvider(provider)) {
|
|
82
|
-
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
83
|
-
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
84
|
-
baseFeeMultiplier,
|
|
85
|
-
priorityFeeMultiplier,
|
|
86
|
-
...opts,
|
|
87
|
-
chainId: opts.chainId ?? CHAIN_IDs.TRON,
|
|
88
|
-
};
|
|
89
|
-
return tron.gasPrices(provider, optsWithDefaults);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
72
|
// Exit here if we need to estimate on Solana.
|
|
93
73
|
if (!isEvmProvider(provider)) {
|
|
94
74
|
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
@@ -133,6 +113,7 @@ function getGasPriceEthers(provider: providers.Provider, opts: GasPriceEstimateO
|
|
|
133
113
|
[CHAIN_IDs.POLYGON]: polygon.gasStation,
|
|
134
114
|
[CHAIN_IDs.SCROLL]: ethereum.legacy,
|
|
135
115
|
[CHAIN_IDs.TEMPO]: ethereum.eip1559,
|
|
116
|
+
[CHAIN_IDs.TRON]: ethereum.legacy,
|
|
136
117
|
[CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
|
|
137
118
|
// Testnet
|
|
138
119
|
[CHAIN_IDs.POLYGON_AMOY]: polygon.gasStation,
|
|
@@ -2,7 +2,7 @@ import { type Chain, type Transport, PublicClient, FeeValuesEIP1559 } from "viem
|
|
|
2
2
|
import { BigNumber, bnZero, isDefined } from "../utils";
|
|
3
3
|
|
|
4
4
|
export type InternalGasPriceEstimate = FeeValuesEIP1559;
|
|
5
|
-
export type GasPriceEstimate = EvmGasPriceEstimate | SvmGasPriceEstimate
|
|
5
|
+
export type GasPriceEstimate = EvmGasPriceEstimate | SvmGasPriceEstimate;
|
|
6
6
|
|
|
7
7
|
export type EvmGasPriceEstimate = {
|
|
8
8
|
maxFeePerGas: BigNumber;
|
|
@@ -14,11 +14,6 @@ export type SvmGasPriceEstimate = {
|
|
|
14
14
|
microLamportsPerComputeUnit: BigNumber;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export type TvmGasPriceEstimate = {
|
|
18
|
-
energyPrice: BigNumber;
|
|
19
|
-
bandwidthPrice: BigNumber;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
17
|
export interface GasPriceFeed {
|
|
23
18
|
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
24
19
|
}
|
|
@@ -40,8 +35,3 @@ export function isSVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is SvmGasPri
|
|
|
40
35
|
const { baseFee, microLamportsPerComputeUnit } = gasPrice as SvmGasPriceEstimate;
|
|
41
36
|
return isDefined(baseFee) && isDefined(microLamportsPerComputeUnit);
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
export function isTVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is TvmGasPriceEstimate {
|
|
45
|
-
const { energyPrice, bandwidthPrice } = gasPrice as TvmGasPriceEstimate;
|
|
46
|
-
return isDefined(energyPrice) && isDefined(bandwidthPrice);
|
|
47
|
-
}
|
|
@@ -5,13 +5,12 @@ import { asL2Provider } from "@eth-optimism/sdk";
|
|
|
5
5
|
import { providers } from "ethers";
|
|
6
6
|
import { TronWeb } from "tronweb";
|
|
7
7
|
import { CUSTOM_GAS_TOKENS } from "../../constants";
|
|
8
|
-
import { chainIsEvm, chainIsOPStack, isDefined, chainIsSvm,
|
|
8
|
+
import { chainIsEvm, chainIsOPStack, isDefined, chainIsSvm, SvmAddress } from "../../utils";
|
|
9
9
|
import { QueryBase } from "./baseQuery";
|
|
10
10
|
import { SVMProvider as svmProvider } from "../../arch/svm";
|
|
11
11
|
import { DEFAULT_LOGGER, getDefaultRelayer, Logger } from "../relayFeeCalculator";
|
|
12
12
|
import { CustomGasTokenQueries } from "./customGasToken";
|
|
13
13
|
import { SvmQuery } from "./svmQuery";
|
|
14
|
-
import { TvmQuery } from "./tvmQuery";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Some chains have a fixed gas price that is applied to the gas estimates. We should override
|
|
@@ -31,7 +30,7 @@ export class QueryBase__factory {
|
|
|
31
30
|
coingeckoProApiKey?: string,
|
|
32
31
|
logger: Logger = DEFAULT_LOGGER,
|
|
33
32
|
coingeckoBaseCurrency = "eth"
|
|
34
|
-
): QueryBase | SvmQuery
|
|
33
|
+
): QueryBase | SvmQuery {
|
|
35
34
|
assert(isDefined(spokePoolAddress));
|
|
36
35
|
|
|
37
36
|
const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
|
|
@@ -64,19 +63,6 @@ export class QueryBase__factory {
|
|
|
64
63
|
coingeckoBaseCurrency
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
|
-
if (chainIsTvm(chainId)) {
|
|
68
|
-
assert(relayerAddress.isEVM());
|
|
69
|
-
return new TvmQuery(
|
|
70
|
-
provider as TronWeb,
|
|
71
|
-
symbolMapping,
|
|
72
|
-
spokePoolAddress,
|
|
73
|
-
relayerAddress,
|
|
74
|
-
logger,
|
|
75
|
-
coingeckoProApiKey,
|
|
76
|
-
fixedGasPrice[chainId],
|
|
77
|
-
coingeckoBaseCurrency
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
66
|
|
|
81
67
|
// For OPStack chains, we need to wrap the provider in an L2Provider
|
|
82
68
|
provider = chainIsOPStack(chainId)
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gasPrices = gasPrices;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var utils_1 = require("../../utils");
|
|
6
|
-
function gasPrices(provider, _opts) {
|
|
7
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
8
|
-
var _a, energyPrice, bandwidthPrice;
|
|
9
|
-
return tslib_1.__generator(this, function (_b) {
|
|
10
|
-
switch (_b.label) {
|
|
11
|
-
case 0: return [4, Promise.all([getEnergyPrice(provider), getBandwidthPrice(provider)])];
|
|
12
|
-
case 1:
|
|
13
|
-
_a = _b.sent(), energyPrice = _a[0], bandwidthPrice = _a[1];
|
|
14
|
-
return [2, {
|
|
15
|
-
energyPrice: (0, utils_1.toBN)(energyPrice),
|
|
16
|
-
bandwidthPrice: (0, utils_1.toBN)(bandwidthPrice),
|
|
17
|
-
}];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function getEnergyPrice(tronWeb) {
|
|
23
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
24
|
-
var pricesStr, entries, lastEntry, price;
|
|
25
|
-
return tslib_1.__generator(this, function (_a) {
|
|
26
|
-
switch (_a.label) {
|
|
27
|
-
case 0: return [4, tronWeb.trx.getEnergyPrices()];
|
|
28
|
-
case 1:
|
|
29
|
-
pricesStr = _a.sent();
|
|
30
|
-
entries = pricesStr.split(",");
|
|
31
|
-
lastEntry = entries[entries.length - 1];
|
|
32
|
-
price = Number(lastEntry.split(":")[1]);
|
|
33
|
-
if (!Number.isFinite(price) || price <= 0) {
|
|
34
|
-
throw new Error("getEnergyPrice: unexpected energy price: ".concat(lastEntry));
|
|
35
|
-
}
|
|
36
|
-
return [2, price];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function getBandwidthPrice(tronWeb) {
|
|
42
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var params, entry;
|
|
44
|
-
return tslib_1.__generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0: return [4, tronWeb.trx.getChainParameters()];
|
|
47
|
-
case 1:
|
|
48
|
-
params = _a.sent();
|
|
49
|
-
entry = params.find(function (p) { return p.key === "getTransactionFee"; });
|
|
50
|
-
if (!entry) {
|
|
51
|
-
throw new Error("getBandwidthPrice: getTransactionFee not found in chain parameters");
|
|
52
|
-
}
|
|
53
|
-
return [2, entry.value];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=tron.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tron.js","sourceRoot":"","sources":["../../../../../src/gasPriceOracle/adapters/tron.ts"],"names":[],"mappings":";;AAWA,8BAOC;;AAjBD,qCAAmC;AAUnC,SAAsB,SAAS,CAAC,QAAiB,EAAE,KAA8B;;;;;wBACzC,WAAM,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAA;;oBAA1G,KAAgC,SAA0E,EAAzG,WAAW,QAAA,EAAE,cAAc,QAAA;oBAElC,WAAO;4BACL,WAAW,EAAE,IAAA,YAAI,EAAC,WAAW,CAAC;4BAC9B,cAAc,EAAE,IAAA,YAAI,EAAC,cAAc,CAAC;yBACrC,EAAC;;;;CACH;AAMD,SAAe,cAAc,CAAC,OAAgB;;;;;wBAC1B,WAAM,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAA;;oBAA/C,SAAS,GAAG,SAAmC;oBAC/C,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC/B,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBACxC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;wBAC1C,MAAM,IAAI,KAAK,CAAC,mDAA4C,SAAS,CAAE,CAAC,CAAC;oBAC3E,CAAC;oBAED,WAAO,KAAK,EAAC;;;;CACd;AAKD,SAAe,iBAAiB,CAAC,OAAgB;;;;;wBAChC,WAAM,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAA;;oBAA/C,MAAM,GAAG,SAAsC;oBAC/C,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAC,CAAiC,IAAK,OAAA,CAAC,CAAC,GAAG,KAAK,mBAAmB,EAA7B,CAA6B,CAAC,CAAC;oBAEhG,IAAI,CAAC,KAAK,EAAE,CAAC;wBACX,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;oBACxF,CAAC;oBAED,WAAO,KAAK,CAAC,KAAK,EAAC;;;;CACpB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PopulatedTransaction, providers } from "ethers";
|
|
2
|
-
import { TronWeb } from "tronweb";
|
|
3
|
-
import { GasPriceEstimateOptions } from "../../gasPriceOracle";
|
|
4
|
-
import { RelayData } from "../../interfaces";
|
|
5
|
-
import { Address, BigNumber, BigNumberish, EvmAddress, TransactionCostEstimate } from "../../utils";
|
|
6
|
-
import { Logger } from "../relayFeeCalculator";
|
|
7
|
-
import { QueryBase, SymbolMappingType } from "./baseQuery";
|
|
8
|
-
export declare class TvmQuery extends QueryBase {
|
|
9
|
-
readonly tronWeb: TronWeb;
|
|
10
|
-
constructor(tronWeb: TronWeb, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: EvmAddress, logger: Logger, coingeckoProApiKey?: string, fixedGasPrice?: BigNumberish, coingeckoBaseCurrency?: string);
|
|
11
|
-
estimateGas(unsignedTx: PopulatedTransaction, senderAddress: Address, provider: providers.Provider, options?: Partial<GasPriceEstimateOptions & {
|
|
12
|
-
gasPrice: BigNumberish;
|
|
13
|
-
gasUnits: BigNumberish;
|
|
14
|
-
}>): Promise<TransactionCostEstimate>;
|
|
15
|
-
getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber;
|
|
16
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TvmQuery = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var ethers_1 = require("ethers");
|
|
7
|
-
var gasPriceOracle_1 = require("../../gasPriceOracle");
|
|
8
|
-
var utils_1 = require("../../utils");
|
|
9
|
-
var __1 = require("../..");
|
|
10
|
-
var baseQuery_1 = require("./baseQuery");
|
|
11
|
-
var TvmQuery = (function (_super) {
|
|
12
|
-
tslib_1.__extends(TvmQuery, _super);
|
|
13
|
-
function TvmQuery(tronWeb, symbolMapping, spokePoolAddress, simulatedRelayerAddress, logger, coingeckoProApiKey, fixedGasPrice, coingeckoBaseCurrency) {
|
|
14
|
-
if (coingeckoBaseCurrency === void 0) { coingeckoBaseCurrency = "eth"; }
|
|
15
|
-
var _this = this;
|
|
16
|
-
var provider = new ethers_1.providers.StaticJsonRpcProvider(tronWeb.fullNode.host);
|
|
17
|
-
_this = _super.call(this, provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, logger, coingeckoProApiKey, fixedGasPrice, coingeckoBaseCurrency) || this;
|
|
18
|
-
_this.tronWeb = tronWeb;
|
|
19
|
-
return _this;
|
|
20
|
-
}
|
|
21
|
-
TvmQuery.prototype.estimateGas = function (unsignedTx_1, senderAddress_1, provider_1) {
|
|
22
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (unsignedTx, senderAddress, provider, options) {
|
|
23
|
-
var _gasPrice, gasUnits, voidSigner, _a, nativeGasCost, gasPriceEstimate, gasPrice, tokenGasCost;
|
|
24
|
-
if (options === void 0) { options = {}; }
|
|
25
|
-
return tslib_1.__generator(this, function (_b) {
|
|
26
|
-
switch (_b.label) {
|
|
27
|
-
case 0:
|
|
28
|
-
_gasPrice = options.gasPrice, gasUnits = options.gasUnits;
|
|
29
|
-
voidSigner = new ethers_1.VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
30
|
-
return [4, Promise.all([
|
|
31
|
-
gasUnits ? Promise.resolve(utils_1.BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
|
|
32
|
-
_gasPrice
|
|
33
|
-
? Promise.resolve({ energyPrice: utils_1.BigNumber.from(_gasPrice.toString()), bandwidthPrice: utils_1.bnZero })
|
|
34
|
-
: (0, gasPriceOracle_1.getGasPriceEstimate)(this.tronWeb),
|
|
35
|
-
])];
|
|
36
|
-
case 1:
|
|
37
|
-
_a = _b.sent(), nativeGasCost = _a[0], gasPriceEstimate = _a[1];
|
|
38
|
-
(0, assert_1.default)(nativeGasCost.gt(utils_1.bnZero), "Gas cost should not be 0");
|
|
39
|
-
gasPrice = gasPriceEstimate.energyPrice;
|
|
40
|
-
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
41
|
-
return [2, { nativeGasCost: nativeGasCost, tokenGasCost: tokenGasCost, gasPrice: gasPrice }];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
TvmQuery.prototype.getAuxiliaryNativeTokenCost = function (deposit) {
|
|
47
|
-
return __1.arch.tvm.getAuxiliaryNativeTokenCost(deposit);
|
|
48
|
-
};
|
|
49
|
-
return TvmQuery;
|
|
50
|
-
}(baseQuery_1.QueryBase));
|
|
51
|
-
exports.TvmQuery = TvmQuery;
|
|
52
|
-
//# sourceMappingURL=tvmQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tvmQuery.js","sourceRoot":"","sources":["../../../../../src/relayFeeCalculator/chain-queries/tvmQuery.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAC5B,iCAAqE;AAErE,uDAAoF;AAGpF,qCAA4G;AAC5G,2BAA6B;AAE7B,yCAA2D;AAW3D;IAA8B,oCAAS;IAGrC,kBACE,OAAgB,EAChB,aAAgC,EAChC,gBAAwB,EACxB,uBAAmC,EACnC,MAAc,EACd,kBAA2B,EAC3B,aAA4B,EAC5B,qBAAqC;QAArC,sCAAA,EAAA,6BAAqC;QARvC,iBAsBC;QAZC,IAAM,QAAQ,GAAG,IAAI,kBAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5E,QAAA,MAAK,YACH,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,qBAAqB,CACtB,SAAC;QACF,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IASc,8BAAW,GAA1B;oEACE,UAAgC,EAChC,aAAsB,EACtB,QAA4B,EAC5B,OAKM;;YALN,wBAAA,EAAA,YAKM;;;;wBAEY,SAAS,GAAe,OAAO,SAAtB,EAAE,QAAQ,GAAK,OAAO,SAAZ,CAAa;wBAE5C,UAAU,GAAG,IAAI,mBAAU,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,QAAQ,CAAC,CAAC;wBAEhC,WAAM,OAAO,CAAC,GAAG,CAAC;gCAC1D,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC;gCACzF,SAAS;oCACP,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,iBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAE,cAAM,EAAE,CAAC;oCAChG,CAAC,CAAC,IAAA,oCAAmB,EAAC,IAAI,CAAC,OAAO,CAAC;6BACtC,CAAC,EAAA;;wBALI,KAAoC,SAKxC,EALK,aAAa,QAAA,EAAE,gBAAgB,QAAA;wBAOtC,IAAA,gBAAM,EAAC,aAAa,CAAC,EAAE,CAAC,cAAM,CAAC,EAAE,0BAA0B,CAAC,CAAC;wBAEvD,QAAQ,GAAI,gBAAwC,CAAC,WAAW,CAAC;wBACjE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;wBAEjD,WAAO,EAAE,aAAa,eAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,EAAC;;;;KAClD;IAEQ,8CAA2B,GAApC,UAAqC,OAAkB;QACrD,OAAO,QAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IACH,eAAC;AAAD,CAAC,AAnED,CAA8B,qBAAS,GAmEtC;AAnEY,4BAAQ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TronWeb } from "tronweb";
|
|
2
|
-
import { TvmGasPriceEstimate } from "../types";
|
|
3
|
-
import { GasPriceEstimateOptions } from "../oracle";
|
|
4
|
-
/**
|
|
5
|
-
* @notice Returns energy and bandwidth prices for the TRON network.
|
|
6
|
-
* @param provider A TronWeb instance.
|
|
7
|
-
* @param _opts Gas price estimate options (unused, kept for interface consistency).
|
|
8
|
-
* @returns TvmGasPriceEstimate with energyPrice and bandwidthPrice in SUN per unit.
|
|
9
|
-
*/
|
|
10
|
-
export declare function gasPrices(provider: TronWeb, _opts: GasPriceEstimateOptions): Promise<TvmGasPriceEstimate>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
|
-
import { toBN } from "../../utils";
|
|
3
|
-
/**
|
|
4
|
-
* @notice Returns energy and bandwidth prices for the TRON network.
|
|
5
|
-
* @param provider A TronWeb instance.
|
|
6
|
-
* @param _opts Gas price estimate options (unused, kept for interface consistency).
|
|
7
|
-
* @returns TvmGasPriceEstimate with energyPrice and bandwidthPrice in SUN per unit.
|
|
8
|
-
*/
|
|
9
|
-
export function gasPrices(provider, _opts) {
|
|
10
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11
|
-
var _a, energyPrice, bandwidthPrice;
|
|
12
|
-
return __generator(this, function (_b) {
|
|
13
|
-
switch (_b.label) {
|
|
14
|
-
case 0: return [4 /*yield*/, Promise.all([getEnergyPrice(provider), getBandwidthPrice(provider)])];
|
|
15
|
-
case 1:
|
|
16
|
-
_a = _b.sent(), energyPrice = _a[0], bandwidthPrice = _a[1];
|
|
17
|
-
return [2 /*return*/, {
|
|
18
|
-
energyPrice: toBN(energyPrice),
|
|
19
|
-
bandwidthPrice: toBN(bandwidthPrice),
|
|
20
|
-
}];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Query the current energy price in SUN per unit of energy.
|
|
27
|
-
* Parses the last entry from the comma-separated "timestamp:price" string.
|
|
28
|
-
*/
|
|
29
|
-
function getEnergyPrice(tronWeb) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
31
|
-
var pricesStr, entries, lastEntry, price;
|
|
32
|
-
return __generator(this, function (_a) {
|
|
33
|
-
switch (_a.label) {
|
|
34
|
-
case 0: return [4 /*yield*/, tronWeb.trx.getEnergyPrices()];
|
|
35
|
-
case 1:
|
|
36
|
-
pricesStr = _a.sent();
|
|
37
|
-
entries = pricesStr.split(",");
|
|
38
|
-
lastEntry = entries[entries.length - 1];
|
|
39
|
-
price = Number(lastEntry.split(":")[1]);
|
|
40
|
-
if (!Number.isFinite(price) || price <= 0) {
|
|
41
|
-
throw new Error("getEnergyPrice: unexpected energy price: ".concat(lastEntry));
|
|
42
|
-
}
|
|
43
|
-
return [2 /*return*/, price];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Query the current bandwidth price (getTransactionFee) from chain parameters.
|
|
50
|
-
*/
|
|
51
|
-
function getBandwidthPrice(tronWeb) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var params, entry;
|
|
54
|
-
return __generator(this, function (_a) {
|
|
55
|
-
switch (_a.label) {
|
|
56
|
-
case 0: return [4 /*yield*/, tronWeb.trx.getChainParameters()];
|
|
57
|
-
case 1:
|
|
58
|
-
params = _a.sent();
|
|
59
|
-
entry = params.find(function (p) { return p.key === "getTransactionFee"; });
|
|
60
|
-
if (!entry) {
|
|
61
|
-
throw new Error("getBandwidthPrice: getTransactionFee not found in chain parameters");
|
|
62
|
-
}
|
|
63
|
-
return [2 /*return*/, entry.value];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=tron.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tron.js","sourceRoot":"","sources":["../../../../../src/gasPriceOracle/adapters/tron.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC;;;;;GAKG;AACH,MAAM,UAAgB,SAAS,CAAC,QAAiB,EAAE,KAA8B;;;;;wBACzC,qBAAM,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAA;;oBAA1G,KAAgC,SAA0E,EAAzG,WAAW,QAAA,EAAE,cAAc,QAAA;oBAElC,sBAAO;4BACL,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC;4BAC9B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC;yBACrC,EAAC;;;;CACH;AAED;;;GAGG;AACH,SAAe,cAAc,CAAC,OAAgB;;;;;wBAC1B,qBAAM,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,EAAA;;oBAA/C,SAAS,GAAG,SAAmC;oBAC/C,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC/B,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBACxC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;wBAC1C,MAAM,IAAI,KAAK,CAAC,mDAA4C,SAAS,CAAE,CAAC,CAAC;oBAC3E,CAAC;oBAED,sBAAO,KAAK,EAAC;;;;CACd;AAED;;GAEG;AACH,SAAe,iBAAiB,CAAC,OAAgB;;;;;wBAChC,qBAAM,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAA;;oBAA/C,MAAM,GAAG,SAAsC;oBAC/C,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAC,CAAiC,IAAK,OAAA,CAAC,CAAC,GAAG,KAAK,mBAAmB,EAA7B,CAA6B,CAAC,CAAC;oBAEhG,IAAI,CAAC,KAAK,EAAE,CAAC;wBACX,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;oBACxF,CAAC;oBAED,sBAAO,KAAK,CAAC,KAAK,EAAC;;;;CACpB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PopulatedTransaction, providers } from "ethers";
|
|
2
|
-
import { TronWeb } from "tronweb";
|
|
3
|
-
import { GasPriceEstimateOptions } from "../../gasPriceOracle";
|
|
4
|
-
import { RelayData } from "../../interfaces";
|
|
5
|
-
import { Address, BigNumber, BigNumberish, EvmAddress, TransactionCostEstimate } from "../../utils";
|
|
6
|
-
import { Logger } from "../relayFeeCalculator";
|
|
7
|
-
import { QueryBase, SymbolMappingType } from "./baseQuery";
|
|
8
|
-
/**
|
|
9
|
-
* A TVM-specific query implementation for TRON.
|
|
10
|
-
*
|
|
11
|
-
* TRON's JSON-RPC is EVM-compatible for reads and gas estimation, so this
|
|
12
|
-
* class extends QueryBase and overrides only the gas price oracle dispatch
|
|
13
|
-
* to use TronWeb (energy/bandwidth pricing) instead of the EVM oracle.
|
|
14
|
-
*
|
|
15
|
-
* The ethers provider is derived from the TronWeb instance's fullNode URL.
|
|
16
|
-
*/
|
|
17
|
-
export declare class TvmQuery extends QueryBase {
|
|
18
|
-
readonly tronWeb: TronWeb;
|
|
19
|
-
constructor(tronWeb: TronWeb, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: EvmAddress, logger: Logger, coingeckoProApiKey?: string, fixedGasPrice?: BigNumberish, coingeckoBaseCurrency?: string);
|
|
20
|
-
/**
|
|
21
|
-
* Estimate the gas cost of a transaction using TVM energy pricing.
|
|
22
|
-
*
|
|
23
|
-
* Gas units (energy) are estimated via the ethers provider (TRON's JSON-RPC
|
|
24
|
-
* returns energy units for eth_estimateGas). The energy price is queried
|
|
25
|
-
* from TronWeb's gas price oracle.
|
|
26
|
-
*/
|
|
27
|
-
estimateGas(unsignedTx: PopulatedTransaction, senderAddress: Address, provider: providers.Provider, options?: Partial<GasPriceEstimateOptions & {
|
|
28
|
-
gasPrice: BigNumberish;
|
|
29
|
-
gasUnits: BigNumberish;
|
|
30
|
-
}>): Promise<TransactionCostEstimate>;
|
|
31
|
-
getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber;
|
|
32
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __extends, __generator } from "tslib";
|
|
2
|
-
import assert from "assert";
|
|
3
|
-
import { providers, VoidSigner } from "ethers";
|
|
4
|
-
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
5
|
-
import { BigNumber, bnZero } from "../../utils";
|
|
6
|
-
import { arch } from "../..";
|
|
7
|
-
import { QueryBase } from "./baseQuery";
|
|
8
|
-
/**
|
|
9
|
-
* A TVM-specific query implementation for TRON.
|
|
10
|
-
*
|
|
11
|
-
* TRON's JSON-RPC is EVM-compatible for reads and gas estimation, so this
|
|
12
|
-
* class extends QueryBase and overrides only the gas price oracle dispatch
|
|
13
|
-
* to use TronWeb (energy/bandwidth pricing) instead of the EVM oracle.
|
|
14
|
-
*
|
|
15
|
-
* The ethers provider is derived from the TronWeb instance's fullNode URL.
|
|
16
|
-
*/
|
|
17
|
-
var TvmQuery = /** @class */ (function (_super) {
|
|
18
|
-
__extends(TvmQuery, _super);
|
|
19
|
-
function TvmQuery(tronWeb, symbolMapping, spokePoolAddress, simulatedRelayerAddress, logger, coingeckoProApiKey, fixedGasPrice, coingeckoBaseCurrency) {
|
|
20
|
-
if (coingeckoBaseCurrency === void 0) { coingeckoBaseCurrency = "eth"; }
|
|
21
|
-
var _this = this;
|
|
22
|
-
var provider = new providers.StaticJsonRpcProvider(tronWeb.fullNode.host);
|
|
23
|
-
_this = _super.call(this, provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, logger, coingeckoProApiKey, fixedGasPrice, coingeckoBaseCurrency) || this;
|
|
24
|
-
_this.tronWeb = tronWeb;
|
|
25
|
-
return _this;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Estimate the gas cost of a transaction using TVM energy pricing.
|
|
29
|
-
*
|
|
30
|
-
* Gas units (energy) are estimated via the ethers provider (TRON's JSON-RPC
|
|
31
|
-
* returns energy units for eth_estimateGas). The energy price is queried
|
|
32
|
-
* from TronWeb's gas price oracle.
|
|
33
|
-
*/
|
|
34
|
-
TvmQuery.prototype.estimateGas = function (unsignedTx_1, senderAddress_1, provider_1) {
|
|
35
|
-
return __awaiter(this, arguments, void 0, function (unsignedTx, senderAddress, provider, options) {
|
|
36
|
-
var _gasPrice, gasUnits, voidSigner, _a, nativeGasCost, gasPriceEstimate, gasPrice, tokenGasCost;
|
|
37
|
-
if (options === void 0) { options = {}; }
|
|
38
|
-
return __generator(this, function (_b) {
|
|
39
|
-
switch (_b.label) {
|
|
40
|
-
case 0:
|
|
41
|
-
_gasPrice = options.gasPrice, gasUnits = options.gasUnits;
|
|
42
|
-
voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
43
|
-
return [4 /*yield*/, Promise.all([
|
|
44
|
-
gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
|
|
45
|
-
_gasPrice
|
|
46
|
-
? Promise.resolve({ energyPrice: BigNumber.from(_gasPrice.toString()), bandwidthPrice: bnZero })
|
|
47
|
-
: getGasPriceEstimate(this.tronWeb),
|
|
48
|
-
])];
|
|
49
|
-
case 1:
|
|
50
|
-
_a = _b.sent(), nativeGasCost = _a[0], gasPriceEstimate = _a[1];
|
|
51
|
-
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
52
|
-
gasPrice = gasPriceEstimate.energyPrice;
|
|
53
|
-
tokenGasCost = nativeGasCost.mul(gasPrice);
|
|
54
|
-
return [2 /*return*/, { nativeGasCost: nativeGasCost, tokenGasCost: tokenGasCost, gasPrice: gasPrice }];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
TvmQuery.prototype.getAuxiliaryNativeTokenCost = function (deposit) {
|
|
60
|
-
return arch.tvm.getAuxiliaryNativeTokenCost(deposit);
|
|
61
|
-
};
|
|
62
|
-
return TvmQuery;
|
|
63
|
-
}(QueryBase));
|
|
64
|
-
export { TvmQuery };
|
|
65
|
-
//# sourceMappingURL=tvmQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tvmQuery.js","sourceRoot":"","sources":["../../../../../src/relayFeeCalculator/chain-queries/tvmQuery.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAwB,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAA2B,MAAM,sBAAsB,CAAC;AAGpF,OAAO,EAAW,SAAS,EAAgB,MAAM,EAAuC,MAAM,aAAa,CAAC;AAC5G,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAE3D;;;;;;;;GAQG;AACH;IAA8B,4BAAS;IAGrC,kBACE,OAAgB,EAChB,aAAgC,EAChC,gBAAwB,EACxB,uBAAmC,EACnC,MAAc,EACd,kBAA2B,EAC3B,aAA4B,EAC5B,qBAAqC;QAArC,sCAAA,EAAA,6BAAqC;QARvC,iBAsBC;QAZC,IAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5E,QAAA,MAAK,YACH,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,qBAAqB,CACtB,SAAC;QACF,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IAED;;;;;;OAMG;IACY,8BAAW,GAA1B;4DACE,UAAgC,EAChC,aAAsB,EACtB,QAA4B,EAC5B,OAKM;;YALN,wBAAA,EAAA,YAKM;;;;wBAEY,SAAS,GAAe,OAAO,SAAtB,EAAE,QAAQ,GAAK,OAAO,SAAZ,CAAa;wBAE5C,UAAU,GAAG,IAAI,UAAU,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,QAAQ,CAAC,CAAC;wBAEhC,qBAAM,OAAO,CAAC,GAAG,CAAC;gCAC1D,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC;gCACzF,SAAS;oCACP,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;oCAChG,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC;6BACtC,CAAC,EAAA;;wBALI,KAAoC,SAKxC,EALK,aAAa,QAAA,EAAE,gBAAgB,QAAA;wBAOtC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,0BAA0B,CAAC,CAAC;wBAEvD,QAAQ,GAAI,gBAAwC,CAAC,WAAW,CAAC;wBACjE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;wBAEjD,sBAAO,EAAE,aAAa,eAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,EAAC;;;;KAClD;IAEQ,8CAA2B,GAApC,UAAqC,OAAkB;QACrD,OAAO,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IACH,eAAC;AAAD,CAAC,AAnED,CAA8B,SAAS,GAmEtC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TronWeb } from "tronweb";
|
|
2
|
-
import { TvmGasPriceEstimate } from "../types";
|
|
3
|
-
import { GasPriceEstimateOptions } from "../oracle";
|
|
4
|
-
/**
|
|
5
|
-
* @notice Returns energy and bandwidth prices for the TRON network.
|
|
6
|
-
* @param provider A TronWeb instance.
|
|
7
|
-
* @param _opts Gas price estimate options (unused, kept for interface consistency).
|
|
8
|
-
* @returns TvmGasPriceEstimate with energyPrice and bandwidthPrice in SUN per unit.
|
|
9
|
-
*/
|
|
10
|
-
export declare function gasPrices(provider: TronWeb, _opts: GasPriceEstimateOptions): Promise<TvmGasPriceEstimate>;
|
|
11
|
-
//# sourceMappingURL=tron.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tron.d.ts","sourceRoot":"","sources":["../../../../../src/gasPriceOracle/adapters/tron.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAO/G"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PopulatedTransaction, providers } from "ethers";
|
|
2
|
-
import { TronWeb } from "tronweb";
|
|
3
|
-
import { GasPriceEstimateOptions } from "../../gasPriceOracle";
|
|
4
|
-
import { RelayData } from "../../interfaces";
|
|
5
|
-
import { Address, BigNumber, BigNumberish, EvmAddress, TransactionCostEstimate } from "../../utils";
|
|
6
|
-
import { Logger } from "../relayFeeCalculator";
|
|
7
|
-
import { QueryBase, SymbolMappingType } from "./baseQuery";
|
|
8
|
-
/**
|
|
9
|
-
* A TVM-specific query implementation for TRON.
|
|
10
|
-
*
|
|
11
|
-
* TRON's JSON-RPC is EVM-compatible for reads and gas estimation, so this
|
|
12
|
-
* class extends QueryBase and overrides only the gas price oracle dispatch
|
|
13
|
-
* to use TronWeb (energy/bandwidth pricing) instead of the EVM oracle.
|
|
14
|
-
*
|
|
15
|
-
* The ethers provider is derived from the TronWeb instance's fullNode URL.
|
|
16
|
-
*/
|
|
17
|
-
export declare class TvmQuery extends QueryBase {
|
|
18
|
-
readonly tronWeb: TronWeb;
|
|
19
|
-
constructor(tronWeb: TronWeb, symbolMapping: SymbolMappingType, spokePoolAddress: string, simulatedRelayerAddress: EvmAddress, logger: Logger, coingeckoProApiKey?: string, fixedGasPrice?: BigNumberish, coingeckoBaseCurrency?: string);
|
|
20
|
-
/**
|
|
21
|
-
* Estimate the gas cost of a transaction using TVM energy pricing.
|
|
22
|
-
*
|
|
23
|
-
* Gas units (energy) are estimated via the ethers provider (TRON's JSON-RPC
|
|
24
|
-
* returns energy units for eth_estimateGas). The energy price is queried
|
|
25
|
-
* from TronWeb's gas price oracle.
|
|
26
|
-
*/
|
|
27
|
-
estimateGas(unsignedTx: PopulatedTransaction, senderAddress: Address, provider: providers.Provider, options?: Partial<GasPriceEstimateOptions & {
|
|
28
|
-
gasPrice: BigNumberish;
|
|
29
|
-
gasUnits: BigNumberish;
|
|
30
|
-
}>): Promise<TransactionCostEstimate>;
|
|
31
|
-
getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=tvmQuery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tvmQuery.d.ts","sourceRoot":"","sources":["../../../../../src/relayFeeCalculator/chain-queries/tvmQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAc,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAuB,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAU,UAAU,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE5G,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;;GAQG;AACH,qBAAa,QAAS,SAAQ,SAAS;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAGxB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,iBAAiB,EAChC,gBAAgB,EAAE,MAAM,EACxB,uBAAuB,EAAE,UAAU,EACnC,MAAM,EAAE,MAAM,EACd,kBAAkB,CAAC,EAAE,MAAM,EAC3B,aAAa,CAAC,EAAE,YAAY,EAC5B,qBAAqB,GAAE,MAAc;IAgBvC;;;;;;OAMG;IACY,WAAW,CACxB,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,OAAO,EACtB,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,GAAE,OAAO,CACd,uBAAuB,GAAG;QACxB,QAAQ,EAAE,YAAY,CAAC;QACvB,QAAQ,EAAE,YAAY,CAAC;KACxB,CACG,GACL,OAAO,CAAC,uBAAuB,CAAC;IAoB1B,2BAA2B,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS;CAGpE"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { TronWeb } from "tronweb";
|
|
2
|
-
import { toBN } from "../../utils";
|
|
3
|
-
import { TvmGasPriceEstimate } from "../types";
|
|
4
|
-
import { GasPriceEstimateOptions } from "../oracle";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @notice Returns energy and bandwidth prices for the TRON network.
|
|
8
|
-
* @param provider A TronWeb instance.
|
|
9
|
-
* @param _opts Gas price estimate options (unused, kept for interface consistency).
|
|
10
|
-
* @returns TvmGasPriceEstimate with energyPrice and bandwidthPrice in SUN per unit.
|
|
11
|
-
*/
|
|
12
|
-
export async function gasPrices(provider: TronWeb, _opts: GasPriceEstimateOptions): Promise<TvmGasPriceEstimate> {
|
|
13
|
-
const [energyPrice, bandwidthPrice] = await Promise.all([getEnergyPrice(provider), getBandwidthPrice(provider)]);
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
energyPrice: toBN(energyPrice),
|
|
17
|
-
bandwidthPrice: toBN(bandwidthPrice),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Query the current energy price in SUN per unit of energy.
|
|
23
|
-
* Parses the last entry from the comma-separated "timestamp:price" string.
|
|
24
|
-
*/
|
|
25
|
-
async function getEnergyPrice(tronWeb: TronWeb): Promise<number> {
|
|
26
|
-
const pricesStr = await tronWeb.trx.getEnergyPrices();
|
|
27
|
-
const entries = pricesStr.split(",");
|
|
28
|
-
const lastEntry = entries[entries.length - 1];
|
|
29
|
-
const price = Number(lastEntry.split(":")[1]);
|
|
30
|
-
|
|
31
|
-
if (!Number.isFinite(price) || price <= 0) {
|
|
32
|
-
throw new Error(`getEnergyPrice: unexpected energy price: ${lastEntry}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return price;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Query the current bandwidth price (getTransactionFee) from chain parameters.
|
|
40
|
-
*/
|
|
41
|
-
async function getBandwidthPrice(tronWeb: TronWeb): Promise<number> {
|
|
42
|
-
const params = await tronWeb.trx.getChainParameters();
|
|
43
|
-
const entry = params.find((p: { key: string; value: number }) => p.key === "getTransactionFee");
|
|
44
|
-
|
|
45
|
-
if (!entry) {
|
|
46
|
-
throw new Error("getBandwidthPrice: getTransactionFee not found in chain parameters");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return entry.value;
|
|
50
|
-
}
|