@mixerx/oracles 1.0.0 → 2.0.0
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/README.md +78 -111
- package/dist/application/ports/ILogger.d.ts +0 -1
- package/dist/application/ports/ILogger.js.map +1 -1
- package/dist/application/ports/index.d.ts +0 -1
- package/dist/application/ports/index.js.map +1 -1
- package/dist/domain/config/TokenDefaults.d.ts +0 -32
- package/dist/domain/config/TokenDefaults.js +7 -72
- package/dist/domain/config/TokenDefaults.js.map +1 -1
- package/dist/domain/config/index.d.ts +1 -2
- package/dist/domain/config/index.js +1 -13
- package/dist/domain/config/index.js.map +1 -1
- package/dist/domain/exceptions.d.ts +8 -4
- package/dist/domain/exceptions.js +12 -3
- package/dist/domain/exceptions.js.map +1 -1
- package/dist/domain/repositories.d.ts +3 -1
- package/dist/domain/repositories.js +10 -0
- package/dist/domain/repositories.js.map +1 -1
- package/dist/factory.d.ts +11 -32
- package/dist/factory.js +16 -26
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/blockchain/staticProvider.d.ts +3 -0
- package/dist/infrastructure/blockchain/staticProvider.js +37 -0
- package/dist/infrastructure/blockchain/staticProvider.js.map +1 -0
- package/dist/infrastructure/config/ProtocolTokenConfig.d.ts +0 -1
- package/dist/infrastructure/config/ProtocolTokenConfig.js +2 -0
- package/dist/infrastructure/config/ProtocolTokenConfig.js.map +1 -1
- package/dist/infrastructure/config/gasOracleConfigs.d.ts +2 -13
- package/dist/infrastructure/config/gasOracleConfigs.js +7 -33
- package/dist/infrastructure/config/gasOracleConfigs.js.map +1 -1
- package/dist/infrastructure/config/index.d.ts +0 -1
- package/dist/infrastructure/config/index.js.map +1 -1
- package/dist/infrastructure/gas/GasPriceOracle.d.ts +12 -2
- package/dist/infrastructure/gas/GasPriceOracle.js +77 -38
- package/dist/infrastructure/gas/GasPriceOracle.js.map +1 -1
- package/dist/infrastructure/mixerx/MixerXFeeOracle.d.ts +88 -0
- package/dist/infrastructure/mixerx/MixerXFeeOracle.js +220 -0
- package/dist/infrastructure/mixerx/MixerXFeeOracle.js.map +1 -0
- package/dist/infrastructure/multicall/MulticallProvider.d.ts +5 -3
- package/dist/infrastructure/multicall/MulticallProvider.js +44 -9
- package/dist/infrastructure/multicall/MulticallProvider.js.map +1 -1
- package/dist/infrastructure/token-price/TokenPriceOracle.d.ts +11 -46
- package/dist/infrastructure/token-price/TokenPriceOracle.js +68 -101
- package/dist/infrastructure/token-price/TokenPriceOracle.js.map +1 -1
- package/dist/infrastructure/token-price/index.d.ts +2 -2
- package/dist/infrastructure/token-price/index.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.js.map +1 -1
- package/package.json +56 -40
- package/dist/application/ports/ILogger.d.ts.map +0 -1
- package/dist/application/ports/index.d.ts.map +0 -1
- package/dist/application/services/TokenPriceService.d.ts +0 -61
- package/dist/application/services/TokenPriceService.d.ts.map +0 -1
- package/dist/application/services/TokenPriceService.js +0 -137
- package/dist/application/services/TokenPriceService.js.map +0 -1
- package/dist/domain/config/TokenDefaults.d.ts.map +0 -1
- package/dist/domain/config/index.d.ts.map +0 -1
- package/dist/domain/exceptions.d.ts.map +0 -1
- package/dist/domain/repositories.d.ts.map +0 -1
- package/dist/factory.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/infrastructure/blockchain/contracts.d.ts +0 -20
- package/dist/infrastructure/blockchain/contracts.d.ts.map +0 -1
- package/dist/infrastructure/blockchain/contracts.js +0 -10
- package/dist/infrastructure/blockchain/contracts.js.map +0 -1
- package/dist/infrastructure/config/ProtocolTokenConfig.d.ts.map +0 -1
- package/dist/infrastructure/config/gasOracleConfigs.d.ts.map +0 -1
- package/dist/infrastructure/config/index.d.ts.map +0 -1
- package/dist/infrastructure/gas/GasPriceOracle.d.ts.map +0 -1
- package/dist/infrastructure/multicall/MulticallProvider.d.ts.map +0 -1
- package/dist/infrastructure/token-price/TokenPriceOracle.d.ts.map +0 -1
- package/dist/infrastructure/token-price/index.d.ts.map +0 -1
- package/dist/infrastructure/tornado/TornadoFeeOracle.d.ts +0 -90
- package/dist/infrastructure/tornado/TornadoFeeOracle.d.ts.map +0 -1
- package/dist/infrastructure/tornado/TornadoFeeOracle.js +0 -230
- package/dist/infrastructure/tornado/TornadoFeeOracle.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPriceOracle.js","sourceRoot":"","sources":["../../../src/infrastructure/token-price/TokenPriceOracle.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;
|
|
1
|
+
{"version":3,"file":"TokenPriceOracle.js","sourceRoot":"","sources":["../../../src/infrastructure/token-price/TokenPriceOracle.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,6DAA6D;AAC7D,wDAAuE;AAEvE,uEAAmG;AACnG,sEAA8E;AAE9E,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,mBAAmB,GAAG;IAC1B,2GAA2G;CACnG,CAAC;AAEX,MAAa,gBAAgB;IACV,SAAS,CAAoB;IAC7B,qBAAqB,CAAS;IAC9B,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACtD,MAAM,CAAU;IACzB,aAAa,CAAU;IAE/B,YACE,MAAc,EACd,OAAyB,EACzB,qBAA8B,EAC9B,gBAAyB,EACzB,MAAgB,EAChB,MAAgB,EAChB,YAAqB;QAErB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,IAAI,IAAA,kDAA4B,EAAC,OAAO,CAAC,CAAC;QAC5F,IAAI,CAAC,eAAM,CAAC,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,wBAAW,CAAC,gBAAgB,EAAE,mDAAmD,CAAC,CAAC;QAC/F,CAAC;QAED,IAAI,CAAC,aAAa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AE,CAAC,CAAC;YAC/E,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,SAAS,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC;YAChC,MAAM,IAAI,wBAAW,CAAC,gBAAgB,EAAE,sBAAsB,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;CACF;AA1GD,4CA0GC","sourcesContent":["import { ethers } from 'ethers';\r\nimport type { ILogger } from '../../application/ports/ILogger';\r\nimport { NullLogger } from '../../application/ports/ILogger';\r\nimport { OracleError, TokenPriceError } from '../../domain/exceptions';\r\nimport type { ChainId, Token, TokenPrices } from '../../types';\r\nimport { resolveDefaultTokens, resolveOffchainOracleAddress } from '../config/ProtocolTokenConfig';\r\nimport { MulticallProvider, type Call } from '../multicall/MulticallProvider';\r\n\r\nconst MAX_TOKENS = 32;\r\nconst OFFCHAIN_ORACLE_ABI = [\r\n 'function getRateToEth(address srcToken, bool useSrcWrappers) external view returns (uint256 weightedRate)',\r\n] as const;\r\n\r\nexport class TokenPriceOracle {\r\n private readonly multicall: MulticallProvider;\r\n private readonly offchainOracleAddress: string;\r\n private readonly interface = new ethers.Interface(OFFCHAIN_ORACLE_ABI);\r\n private readonly logger: ILogger;\r\n private defaultTokens: Token[];\r\n\r\n constructor(\r\n rpcUrl: string,\r\n chainId: ChainId | number,\r\n offchainOracleAddress?: string,\r\n multicallAddress?: string,\r\n tokens?: Token[],\r\n logger?: ILogger,\r\n rpcTimeoutMs?: number,\r\n ) {\r\n this.offchainOracleAddress = offchainOracleAddress ?? resolveOffchainOracleAddress(chainId);\r\n if (!ethers.isAddress(this.offchainOracleAddress)) {\r\n throw new OracleError('INVALID_CONFIG', 'offchainOracleAddress must be a valid EVM address');\r\n }\r\n\r\n this.defaultTokens = this.normalizeTokens(tokens ?? resolveDefaultTokens(chainId));\r\n this.multicall = new MulticallProvider(rpcUrl, multicallAddress, chainId, rpcTimeoutMs);\r\n this.logger = logger ?? new NullLogger();\r\n }\r\n\r\n async fetchPrices(tokens: readonly Token[] = this.defaultTokens): Promise<TokenPrices> {\r\n const normalizedTokens = this.normalizeTokens(tokens);\r\n const calls: Call[] = normalizedTokens.map((token) => ({\r\n target: this.offchainOracleAddress,\r\n callData: this.interface.encodeFunctionData('getRateToEth', [token.address, true]),\r\n }));\r\n const results = await this.multicall.aggregate(calls);\r\n const prices = Object.create(null) as TokenPrices;\r\n const failedSymbols: string[] = [];\r\n\r\n for (const [index, result] of results.entries()) {\r\n const token = normalizedTokens[index];\r\n if (!result.success) {\r\n failedSymbols.push(token.symbol);\r\n continue;\r\n }\r\n\r\n try {\r\n const rateWei = this.interface.decodeFunctionResult('getRateToEth', result.returnData)[0] as bigint;\r\n const price = (rateWei * 10n ** BigInt(token.decimals)) / 10n ** 18n;\r\n if (price <= 0n) {\r\n failedSymbols.push(token.symbol);\r\n continue;\r\n }\r\n prices[token.symbol] = price.toString();\r\n } catch {\r\n failedSymbols.push(token.symbol);\r\n }\r\n }\r\n\r\n if (failedSymbols.length > 0) {\r\n this.logger.warn('Token price batch rejected', { failedSymbols: [...failedSymbols] });\r\n throw new TokenPriceError('One or more on-chain token prices are unavailable', failedSymbols);\r\n }\r\n\r\n return { ...prices };\r\n }\r\n\r\n async fetchPrice(token: Token): Promise<string> {\r\n const prices = await this.fetchPrices([token]);\r\n return prices[token.symbol.trim().toLowerCase()];\r\n }\r\n\r\n getSupportedTokens(): Token[] {\r\n return this.defaultTokens.map((token) => ({ ...token }));\r\n }\r\n\r\n addTokens(tokens: readonly Token[]): void {\r\n this.defaultTokens = this.normalizeTokens([...this.defaultTokens, ...tokens]);\r\n }\r\n\r\n private normalizeTokens(tokens: readonly Token[]): Token[] {\r\n if (tokens.length === 0) {\r\n throw new OracleError('INVALID_CONFIG', `Token list must contain between 1 and ${String(MAX_TOKENS)} items`);\r\n }\r\n\r\n const byAddress = new Map<string, Token>();\r\n const symbols = new Set<string>();\r\n for (const token of tokens) {\r\n const address = token.address.trim().toLowerCase();\r\n const symbol = token.symbol.trim().toLowerCase();\r\n if (!ethers.isAddress(address) || !/^[a-z0-9]{2,16}$/.test(symbol)) {\r\n throw new OracleError('INVALID_CONFIG', 'Token address or symbol is invalid');\r\n }\r\n if (!Number.isInteger(token.decimals) || token.decimals < 0 || token.decimals > 255) {\r\n throw new OracleError('INVALID_CONFIG', `Invalid decimals for token ${symbol}`);\r\n }\r\n if (symbols.has(symbol) && byAddress.get(address)?.symbol !== symbol) {\r\n throw new OracleError('INVALID_CONFIG', `Duplicate token symbol: ${symbol}`);\r\n }\r\n\r\n symbols.add(symbol);\r\n byAddress.set(address, { address, symbol, decimals: token.decimals });\r\n }\r\n\r\n if (byAddress.size > MAX_TOKENS) {\r\n throw new OracleError('INVALID_CONFIG', `Token list exceeds ${String(MAX_TOKENS)} unique addresses`);\r\n }\r\n return [...byAddress.values()];\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/token-price/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/token-price/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["export { TokenPriceOracle } from './TokenPriceOracle';\r\nexport type { TokenPrices } from '../../types';\r\nexport type { Token } from '../../types';\r\n"]}
|
package/dist/types.d.ts
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type ChainId = number;\r\n\r\nexport interface Token {\r\n address: string;\r\n symbol: string;\r\n decimals: number;\r\n}\r\n\r\nexport interface TokenPrices {\r\n [symbol: string]: string;\r\n}\r\n\r\nexport interface TokenPriceQuote {\r\n priceInEthWei: bigint;\r\n observedAtMs: number;\r\n source: 'repository';\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mixerx/oracles",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"packageManager": "yarn@4.12.0",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist/**/*"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@mixerx/oracles",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Fail-closed Sepolia gas, token-price and withdrawal-fee policies for MixerX",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"packageManager": "yarn@4.12.0",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**/*"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "yarn clean && tsc",
|
|
13
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"lint": "eslint src tests",
|
|
16
|
+
"test": "yarn build && node --test \"tests/**/*.test.cjs\"",
|
|
17
|
+
"validate": "yarn typecheck && yarn lint && yarn test",
|
|
18
|
+
"prepack": "yarn build",
|
|
19
|
+
"prepublish": "yarn validate"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"mixerx",
|
|
23
|
+
"ethereum",
|
|
24
|
+
"gas",
|
|
25
|
+
"oracle",
|
|
26
|
+
"fees"
|
|
27
|
+
],
|
|
28
|
+
"author": "MixerX Contributors",
|
|
29
|
+
"license": "GPL-3.0-only",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/zkusd-mixerx/mixerx-oracles.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/zkusd-mixerx/mixerx-oracles/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/zkusd-mixerx/mixerx-oracles#readme",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@mixerx/config": "0.5.4",
|
|
43
|
+
"ethers": "6.17.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/js": "9.39.1",
|
|
47
|
+
"@types/node": "24.10.1",
|
|
48
|
+
"eslint": "9.39.1",
|
|
49
|
+
"globals": "16.5.0",
|
|
50
|
+
"typescript": "5.9.3",
|
|
51
|
+
"typescript-eslint": "8.48.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.12.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ILogger.d.ts","sourceRoot":"","sources":["../../../src/application/ports/ILogger.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAED,qBAAa,UAAW,YAAW,OAAO;IACxC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAC9C,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAC7C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;CAC/C;AAED,qBAAa,aAAc,YAAW,OAAO;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,SAAmB;IAErD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAI5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAI3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;CAG7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/application/ports/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrD;AAED,cAAc,WAAW,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ITokenPriceFetcher } from '../ports';
|
|
2
|
-
import { Token, TokenPrices } from '../../types';
|
|
3
|
-
import { ChainId } from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for TokenPriceService
|
|
6
|
-
*/
|
|
7
|
-
export interface TokenPriceServiceConfig {
|
|
8
|
-
/** Chain ID used to resolve default tokens from @mixerx/config */
|
|
9
|
-
chainId: ChainId | number;
|
|
10
|
-
/** RPC URL for Ethereum Mainnet */
|
|
11
|
-
rpcUrl: string;
|
|
12
|
-
/** Multicall contract address */
|
|
13
|
-
multicallAddress: string;
|
|
14
|
-
/** Offchain Oracle contract address */
|
|
15
|
-
offchainOracleAddress: string;
|
|
16
|
-
/** Default token prices (fallback) */
|
|
17
|
-
defaultTokenPrices?: TokenPrices;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Token Price Service
|
|
21
|
-
* Fetches token prices from on-chain oracles using multicall
|
|
22
|
-
* Based on TokenPriceOracle from tornado-oracles
|
|
23
|
-
*/
|
|
24
|
-
export declare class TokenPriceService implements ITokenPriceFetcher {
|
|
25
|
-
private readonly config;
|
|
26
|
-
private provider;
|
|
27
|
-
private oracle;
|
|
28
|
-
private multicall;
|
|
29
|
-
private supportedTokens;
|
|
30
|
-
constructor(config: TokenPriceServiceConfig);
|
|
31
|
-
/**
|
|
32
|
-
* Fetch prices for tokens
|
|
33
|
-
* Uses multicall to batch requests
|
|
34
|
-
*/
|
|
35
|
-
fetchPrices(tokens?: Token[]): Promise<TokenPrices>;
|
|
36
|
-
/**
|
|
37
|
-
* Fetch price for a single token
|
|
38
|
-
*/
|
|
39
|
-
fetchSinglePrice(token: Token): Promise<string | null>;
|
|
40
|
-
/**
|
|
41
|
-
* Get default prices (fallback)
|
|
42
|
-
*/
|
|
43
|
-
getDefaultPrices(): TokenPrices;
|
|
44
|
-
/**
|
|
45
|
-
* Get supported tokens
|
|
46
|
-
*/
|
|
47
|
-
getSupportedTokens(): Token[];
|
|
48
|
-
/**
|
|
49
|
-
* Add custom tokens
|
|
50
|
-
*/
|
|
51
|
-
addTokens(tokens: Token[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* ABI for Offchain Oracle (simplified)
|
|
54
|
-
*/
|
|
55
|
-
private getOracleAbi;
|
|
56
|
-
/**
|
|
57
|
-
* ABI for Multicall (simplified)
|
|
58
|
-
*/
|
|
59
|
-
private getMulticallAbi;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=TokenPriceService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPriceService.d.ts","sourceRoot":"","sources":["../../../src/application/services/TokenPriceService.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,EACL,WAAW,EACZ,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,kEAAkE;IAClE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;IAE1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IAEf,iCAAiC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IAEzB,uCAAuC;IACvC,qBAAqB,EAAE,MAAM,CAAC;IAE9B,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,WAAW,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAM9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,eAAe,CAAU;gBAEJ,MAAM,EAAE,uBAAuB;IAiB5D;;;OAGG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAkEzD;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAS5D;;OAEG;IACH,gBAAgB,IAAI,WAAW;IAY/B;;OAEG;IACH,kBAAkB,IAAI,KAAK,EAAE;IAI7B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAIhC;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,eAAe;CAKxB"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenPriceService = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
const TokenDefaults_1 = require("../../domain/config/TokenDefaults");
|
|
6
|
-
const exceptions_1 = require("../../domain/exceptions");
|
|
7
|
-
const ProtocolTokenConfig_1 = require("../../infrastructure/config/ProtocolTokenConfig");
|
|
8
|
-
/**
|
|
9
|
-
* Token Price Service
|
|
10
|
-
* Fetches token prices from on-chain oracles using multicall
|
|
11
|
-
* Based on TokenPriceOracle from tornado-oracles
|
|
12
|
-
*/
|
|
13
|
-
class TokenPriceService {
|
|
14
|
-
config;
|
|
15
|
-
provider;
|
|
16
|
-
oracle;
|
|
17
|
-
multicall;
|
|
18
|
-
supportedTokens;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.config = config;
|
|
21
|
-
this.provider = new ethers_1.ethers.JsonRpcProvider(config.rpcUrl);
|
|
22
|
-
this.oracle = new ethers_1.ethers.Contract(config.offchainOracleAddress, this.getOracleAbi(), this.provider);
|
|
23
|
-
this.multicall = new ethers_1.ethers.Contract(config.multicallAddress, this.getMulticallAbi(), this.provider);
|
|
24
|
-
this.supportedTokens = (0, ProtocolTokenConfig_1.resolveDefaultTokens)(config.chainId);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Fetch prices for tokens
|
|
28
|
-
* Uses multicall to batch requests
|
|
29
|
-
*/
|
|
30
|
-
async fetchPrices(tokens) {
|
|
31
|
-
const tokensToFetch = tokens || this.supportedTokens;
|
|
32
|
-
try {
|
|
33
|
-
if (!tokensToFetch?.length) {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
// Prepare call data for multicall
|
|
37
|
-
const callData = tokensToFetch.map((token) => ({
|
|
38
|
-
to: this.oracle.target,
|
|
39
|
-
data: this.oracle.interface.encodeFunctionData('getRateToEth', [
|
|
40
|
-
token.address,
|
|
41
|
-
true // use wrappers
|
|
42
|
-
]),
|
|
43
|
-
}));
|
|
44
|
-
// Execute multicall
|
|
45
|
-
const { results, success } = await this.multicall.multicall(callData);
|
|
46
|
-
const prices = {};
|
|
47
|
-
// Decode results
|
|
48
|
-
for (let i = 0; i < results.length; i++) {
|
|
49
|
-
const tokenSymbol = tokensToFetch[i].symbol.toLowerCase();
|
|
50
|
-
if (!success[i]) {
|
|
51
|
-
// Use default if call failed
|
|
52
|
-
const defaultPrice = this.getDefaultPrices()[tokenSymbol];
|
|
53
|
-
if (defaultPrice) {
|
|
54
|
-
prices[tokenSymbol] = defaultPrice;
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
// Decode the rate
|
|
60
|
-
const decodedRate = ethers_1.ethers.AbiCoder.defaultAbiCoder().decode(['uint256'], results[i])[0];
|
|
61
|
-
// Calculate price with decimals adjustment
|
|
62
|
-
// Formula: (rate * 10^tokenDecimals) / 10^18
|
|
63
|
-
const tokenDecimals = 10n ** BigInt(tokensToFetch[i].decimals);
|
|
64
|
-
const ethDecimals = 10n ** 18n;
|
|
65
|
-
const price = (decodedRate * tokenDecimals) / ethDecimals;
|
|
66
|
-
prices[tokenSymbol] = price.toString();
|
|
67
|
-
}
|
|
68
|
-
catch (decodeError) {
|
|
69
|
-
// Use default if decoding failed
|
|
70
|
-
const defaultPrice = this.getDefaultPrices()[tokenSymbol];
|
|
71
|
-
if (defaultPrice) {
|
|
72
|
-
prices[tokenSymbol] = defaultPrice;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return prices;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
throw new exceptions_1.TokenPriceError(`Failed to fetch prices: ${error instanceof Error ? error.message : String(error)}`, tokensToFetch.map(t => t.symbol));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Fetch price for a single token
|
|
84
|
-
*/
|
|
85
|
-
async fetchSinglePrice(token) {
|
|
86
|
-
try {
|
|
87
|
-
const prices = await this.fetchPrices([token]);
|
|
88
|
-
return prices[token.symbol.toLowerCase()] || null;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get default prices (fallback)
|
|
96
|
-
*/
|
|
97
|
-
getDefaultPrices() {
|
|
98
|
-
if (!this.config.defaultTokenPrices) {
|
|
99
|
-
return TokenDefaults_1.DEFAULT_TOKEN_PRICES;
|
|
100
|
-
}
|
|
101
|
-
const normalized = {};
|
|
102
|
-
for (const [symbol, value] of Object.entries(this.config.defaultTokenPrices)) {
|
|
103
|
-
normalized[symbol.toLowerCase()] = value;
|
|
104
|
-
}
|
|
105
|
-
return normalized;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get supported tokens
|
|
109
|
-
*/
|
|
110
|
-
getSupportedTokens() {
|
|
111
|
-
return this.supportedTokens;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Add custom tokens
|
|
115
|
-
*/
|
|
116
|
-
addTokens(tokens) {
|
|
117
|
-
this.supportedTokens = [...this.supportedTokens, ...tokens];
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* ABI for Offchain Oracle (simplified)
|
|
121
|
-
*/
|
|
122
|
-
getOracleAbi() {
|
|
123
|
-
return [
|
|
124
|
-
'function getRateToEth(address srcToken, bool useSrcWrappers) external view returns (uint256 weightedRate)',
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* ABI for Multicall (simplified)
|
|
129
|
-
*/
|
|
130
|
-
getMulticallAbi() {
|
|
131
|
-
return [
|
|
132
|
-
'function multicall(tuple(address to, bytes data)[] calls) external view returns (bytes[] results, bool[] success)',
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.TokenPriceService = TokenPriceService;
|
|
137
|
-
//# sourceMappingURL=TokenPriceService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPriceService.js","sourceRoot":"","sources":["../../../src/application/services/TokenPriceService.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAYhC,qEAE2C;AAC3C,wDAA0D;AAC1D,yFAAuF;AAuBvF;;;;GAIG;AACH,MAAa,iBAAiB;IAMC;IALrB,QAAQ,CAAyB;IACjC,MAAM,CAAoB;IAC1B,SAAS,CAAe;IACxB,eAAe,CAAU;IAEjC,YAA6B,MAA+B;QAA/B,WAAM,GAAN,MAAM,CAAyB;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,QAAQ,CAC/B,MAAM,CAAC,qBAAqB,EAC5B,IAAI,CAAC,YAAY,EAAE,EACnB,IAAI,CAAC,QAAQ,CACkB,CAAC;QAElC,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,QAAQ,CAClC,MAAM,CAAC,gBAAgB,EACvB,IAAI,CAAC,eAAe,EAAE,EACtB,IAAI,CAAC,QAAQ,CACa,CAAC;QAE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MAAM,CAAC,MAAM,EAAE,MAAM,CAOrD,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGpD,CAAC;AAGF,eAAO,MAAM,2BAA2B,QAAQ,CAAC;AAGjD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAE1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/config/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,oBAAoB,EAGpB,kBAAkB,EAClB,iBAAiB,EAGjB,2BAA2B,EAC3B,gBAAgB,EAGhB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/domain/exceptions.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;aACK,OAAO,EAAE,MAAM,EAAE;gBAAlD,OAAO,EAAE,MAAM,EAAkB,OAAO,GAAE,MAAM,EAAO;CAIpE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repositories.d.ts","sourceRoot":"","sources":["../../src/domain/repositories.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,C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,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,cAAc,EAAE,cAAc,CAAC;IAE/B,sDAAsD;IACtD,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,2DAA2D;IAC3D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,+CAA+C;IAC/C,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpC,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,oBAAoB,CA6CtB"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { InterfaceAbi } from 'ethers';
|
|
2
|
-
export type OffchainOracleAbi = {
|
|
3
|
-
interface: {
|
|
4
|
-
encodeFunctionData(functionName: string, values?: readonly unknown[]): string;
|
|
5
|
-
};
|
|
6
|
-
target: string | object;
|
|
7
|
-
};
|
|
8
|
-
export type MulticallInput = {
|
|
9
|
-
to: string;
|
|
10
|
-
data: string;
|
|
11
|
-
};
|
|
12
|
-
export type MulticallAbi = {
|
|
13
|
-
multicall(calls: MulticallInput[]): Promise<{
|
|
14
|
-
results: string[];
|
|
15
|
-
success: boolean[];
|
|
16
|
-
}>;
|
|
17
|
-
};
|
|
18
|
-
export declare const OFFCHAIN_ORACLE_ABI: InterfaceAbi;
|
|
19
|
-
export declare const MULTICALL_ABI: InterfaceAbi;
|
|
20
|
-
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/blockchain/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE;QACT,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC;KAC/E,CAAC;IACF,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;CACxF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,YAE3B,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MULTICALL_ABI = exports.OFFCHAIN_ORACLE_ABI = void 0;
|
|
4
|
-
exports.OFFCHAIN_ORACLE_ABI = [
|
|
5
|
-
'function getRateToEth(address srcToken, bool useSrcWrappers) external view returns (uint256 weightedRate)',
|
|
6
|
-
];
|
|
7
|
-
exports.MULTICALL_ABI = [
|
|
8
|
-
'function multicall(tuple(address to, bytes data)[] calls) external view returns (bytes[] results, bool[] success)',
|
|
9
|
-
];
|
|
10
|
-
//# sourceMappingURL=contracts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/infrastructure/blockchain/contracts.ts"],"names":[],"mappings":";;;AAkBa,QAAA,mBAAmB,GAAiB;IAC/C,2GAA2G;CAC5G,CAAC;AAEW,QAAA,aAAa,GAAiB;IACzC,mHAAmH;CACpH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolTokenConfig.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/ProtocolTokenConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAWlD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAQ9E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,CAoCvE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gasOracleConfigs.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/gasOracleConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,IAAI,wBAAwB,EAG7C,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAElD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAM9F;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO7D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GasPriceOracle.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/gas/GasPriceOracle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;CACvD;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE;QAClB,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1E,OAAO,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAC;YAAC,oBAAoB,EAAE,MAAM,CAAA;SAAE,CAAC;KACnF,CAAC;CACH;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoE;gBAEjF,OAAO,EAAE,qBAAqB;IASpC,cAAc,CAAC,KAAK,GAAE,mBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;IA4C9E,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,QAAQ;CAOjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MulticallProvider.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/multicall/MulticallProvider.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAEtC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM;IAIhD,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAYtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPriceOracle.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/token-price/TokenPriceOracle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAc,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,WAAW,WAAW;IAC1B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,iBAAiB,CAEvB;IAGF,OAAO,CAAC,aAAa,CAAU;IAG/B,OAAO,CAAC,aAAa,CAAqC;IAE1D,OAAO,CAAC,MAAM,CAAU;gBAGtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,qBAAqB,CAAC,EAAE,MAAM,EAC9B,gBAAgB,CAAC,EAAE,MAAM,EACzB,MAAM,CAAC,EAAE,KAAK,EAAE,EAChB,MAAM,CAAC,EAAE,OAAO;IAQlB;;;OAGG;IACG,WAAW,CAAC,MAAM,GAAE,KAAK,EAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsE7E;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKtD;;OAEG;IACH,gBAAgB,IAAI,WAAW;IAI/B;;OAEG;IACH,kBAAkB,IAAI,KAAK,EAAE;IAI7B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAIhC;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAI3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/token-price/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { GasPriceOracle, GasPriceParams } from '../gas/GasPriceOracle';
|
|
2
|
-
import { TokenPriceOracle } from '../token-price/TokenPriceOracle';
|
|
3
|
-
import { ITokenPriceRepository } from '../../domain/repositories';
|
|
4
|
-
import { ChainId } from '../config/gasOracleConfigs';
|
|
5
|
-
import { ILogger } from '../../application/ports/ILogger';
|
|
6
|
-
export interface TornadoFeeOracleOptions {
|
|
7
|
-
chainId: ChainId;
|
|
8
|
-
rpcUrl: string;
|
|
9
|
-
relayerFeePercent: number;
|
|
10
|
-
gasPriceOracle?: GasPriceOracle;
|
|
11
|
-
tokenPriceOracle?: TokenPriceOracle;
|
|
12
|
-
priceRepository?: ITokenPriceRepository;
|
|
13
|
-
logger?: ILogger;
|
|
14
|
-
multicallAddress?: string;
|
|
15
|
-
offchainOracleAddress?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface WithdrawalFeeInput {
|
|
18
|
-
currency: string;
|
|
19
|
-
amount: bigint;
|
|
20
|
-
decimals: number;
|
|
21
|
-
refund?: string;
|
|
22
|
-
txType?: 'relayer_withdrawal' | 'user_withdrawal' | 'relayer_withdrawal_check_v4';
|
|
23
|
-
}
|
|
24
|
-
export interface FeeCalculationResult {
|
|
25
|
-
gasCost: bigint;
|
|
26
|
-
relayerFee: bigint;
|
|
27
|
-
refundAmount: bigint;
|
|
28
|
-
totalFee: bigint;
|
|
29
|
-
currency: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* TornadoFeeOracle
|
|
33
|
-
* Calculates fees for Tornado Cash withdrawals
|
|
34
|
-
* Based on @tornado/tornado-oracles TornadoFeeOracleV5
|
|
35
|
-
*
|
|
36
|
-
* Features:
|
|
37
|
-
* - Smart gas limit bumping (10% for relayer, 30% for user)
|
|
38
|
-
* - Token price conversion (ETH↔Token)
|
|
39
|
-
* - Refund calculation for non-ETH tokens
|
|
40
|
-
* - EIP-1559 and Legacy support
|
|
41
|
-
*/
|
|
42
|
-
export declare class TornadoFeeOracle {
|
|
43
|
-
private chainId;
|
|
44
|
-
private relayerFeePercent;
|
|
45
|
-
private gasPriceOracle;
|
|
46
|
-
private tokenPriceOracle?;
|
|
47
|
-
private priceRepository?;
|
|
48
|
-
private logger;
|
|
49
|
-
constructor(options: TornadoFeeOracleOptions);
|
|
50
|
-
/**
|
|
51
|
-
* Calculate withdrawal fee
|
|
52
|
-
* Main method matching TornadoFeeOracleV5.calculateWithdrawalFeeViaRelayer
|
|
53
|
-
*/
|
|
54
|
-
calculateWithdrawalFee(input: WithdrawalFeeInput): Promise<FeeCalculationResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Get gas parameters for transaction
|
|
57
|
-
*/
|
|
58
|
-
private getGasParams;
|
|
59
|
-
/**
|
|
60
|
-
* Calculate gas cost in wei
|
|
61
|
-
*/
|
|
62
|
-
private calculateGasCost;
|
|
63
|
-
/**
|
|
64
|
-
* Calculate relayer fee
|
|
65
|
-
*/
|
|
66
|
-
private calculateRelayerFee;
|
|
67
|
-
/**
|
|
68
|
-
* Get gas limit for operation and token
|
|
69
|
-
* Uses centralized TokenDefaults to eliminate duplication
|
|
70
|
-
*/
|
|
71
|
-
private getGasLimit;
|
|
72
|
-
/**
|
|
73
|
-
* Get bump percent based on transaction type (V5 smart bumping)
|
|
74
|
-
* Uses centralized TokenDefaults to eliminate duplication
|
|
75
|
-
*/
|
|
76
|
-
private getBumpPercent;
|
|
77
|
-
/**
|
|
78
|
-
* Get token price in ETH (wei per token unit)
|
|
79
|
-
*/
|
|
80
|
-
private getTokenPrice;
|
|
81
|
-
/**
|
|
82
|
-
* Get gas parameters for direct use
|
|
83
|
-
*/
|
|
84
|
-
getGasParameters(isLegacy?: boolean): Promise<GasPriceParams>;
|
|
85
|
-
/**
|
|
86
|
-
* Get chain ID
|
|
87
|
-
*/
|
|
88
|
-
getChainId(): ChainId;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=TornadoFeeOracle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TornadoFeeOracle.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/tornado/TornadoFeeOracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAoB,MAAM,4BAA4B,CAAC;AACvE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