dequanto 0.0.1
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/.vscode/settings.json +11 -0
- package/actions/gen.act.ts +38 -0
- package/actions/tokens.act.ts +12 -0
- package/configs/dequanto.yml +51 -0
- package/contracts/abi/erc20.abi.json +222 -0
- package/contracts/gen/amm/AmmFactoryV2ContractBase.ts +66 -0
- package/contracts/gen/amm/AmmMasterChefV2ContractBase.ts +158 -0
- package/contracts/gen/amm/AmmPairContractV2Base.ts +158 -0
- package/contracts/gen/amm/AmmPairContractV3Base.ts +125 -0
- package/contracts/gen/amm/AmmRouterV2ContractBase.ts +124 -0
- package/contracts/gen/amm/AmmVaultV2ContractBase.ts +214 -0
- package/contracts/gen/base/ERC20Base.ts +90 -0
- package/contracts/gen/bsc/OneInchRouterV3Base.ts +57 -0
- package/contracts/gen/eth/WETHBase/WETHBase.sol +756 -0
- package/contracts/gen/eth/WETHBase.ts +136 -0
- package/contracts/gen/polygon/ERC20PolygonBase.ts +305 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Address.sol +216 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BeaconProxy.sol +61 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Bridge.sol +437 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGetters.sol +70 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGovernance.sol +142 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeImplementation.sol +34 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeSetters.sol +57 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeState.sol +52 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeStructs.sol +66 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/BytesLib.sol +510 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Context.sol +23 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Proxy.sol +32 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Upgrade.sol +193 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/IBeacon.sol +15 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/IERC20.sol +81 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/IWormhole.sol +42 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Ownable.sol +71 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Proxy.sol +85 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/SafeERC20.sol +98 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/StorageSlot.sol +83 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Structs.sol +40 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/Token.sol +12 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenBridge.sol +15 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenImplementation.sol +177 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenState.sol +31 -0
- package/contracts/gen/polygon/WormholeBridgeContractBase.ts +231 -0
- package/contracts/gen/xdai/WXDaiTokenContractBase.ts +136 -0
- package/data/cex/eth.csv +356 -0
- package/data/tokens/1inch.json +16557 -0
- package/data/tokens/arbitrum.json +1 -0
- package/data/tokens/sushi.json +56388 -0
- package/dist/contracts/gen/amm/AmmFactoryV2ContractBase.js +53 -0
- package/dist/contracts/gen/amm/AmmMasterChefV2ContractBase.js +122 -0
- package/dist/contracts/gen/amm/AmmPairContractV2Base.js +122 -0
- package/dist/contracts/gen/amm/AmmPairContractV3Base.js +98 -0
- package/dist/contracts/gen/amm/AmmRouterV2ContractBase.js +95 -0
- package/dist/contracts/gen/amm/AmmVaultV2ContractBase.js +164 -0
- package/dist/contracts/gen/base/ERC20Base.js +64 -0
- package/dist/contracts/gen/bsc/OneInchRouterV3Base.js +47 -0
- package/dist/contracts/gen/eth/WETHBase.js +96 -0
- package/dist/contracts/gen/polygon/ERC20PolygonBase.js +233 -0
- package/dist/contracts/gen/polygon/WormholeBridgeContractBase.js +172 -0
- package/dist/contracts/gen/xdai/WXDaiTokenContractBase.js +96 -0
- package/dist/src/BlockchainExplorer/BlockChainExplorerFactory.js +227 -0
- package/dist/src/BlockchainExplorer/BlockChainExplorerProvider.js +32 -0
- package/dist/src/BlockchainExplorer/BlockNumberCache.js +33 -0
- package/dist/src/BlockchainExplorer/Bscscan.js +27 -0
- package/dist/src/BlockchainExplorer/Etherscan.js +27 -0
- package/dist/src/BlockchainExplorer/IAbiProvider.js +2 -0
- package/dist/src/BlockchainExplorer/IBlockChainExplorer.js +2 -0
- package/dist/src/BlockchainExplorer/Polyscan.js +27 -0
- package/dist/src/ChainAccounts.js +69 -0
- package/dist/src/ChainAccountsService.js +75 -0
- package/dist/src/Config.js +7 -0
- package/dist/src/blocks/BlockDateResolver.js +125 -0
- package/dist/src/bridges/BridgeFactory.js +19 -0
- package/dist/src/bridges/hop/HopAddresses.js +520 -0
- package/dist/src/bridges/hop/HopBridge.js +327 -0
- package/dist/src/bridges/hop/contracts/gen.act.js +43 -0
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.js +52 -0
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.js +319 -0
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.js +178 -0
- package/dist/src/bridges/models/IBridge.js +2 -0
- package/dist/src/bridges/wormhole/contracts/WormholeBridgeContract.js +15 -0
- package/dist/src/chains/PlatformFactory.js +42 -0
- package/dist/src/chains/arbitrum/ArbTokenProvider.js +40 -0
- package/dist/src/chains/arbitrum/ArbWeb3Client.js +39 -0
- package/dist/src/chains/arbitrum/Arbiscan.js +27 -0
- package/dist/src/chains/boba/BobaWeb3Client.js +47 -0
- package/dist/src/chains/boba/Bobascan.js +28 -0
- package/dist/src/chains/xdai/XDaiWeb3Client.js +87 -0
- package/dist/src/chains/xdai/XDaiscan.js +27 -0
- package/dist/src/chains/xdai/tokens/WXDaiTokenContract.js +15 -0
- package/dist/src/clients/BscWeb3Client.js +38 -0
- package/dist/src/clients/ClientEventsStream.js +34 -0
- package/dist/src/clients/ClientPool.js +560 -0
- package/dist/src/clients/ClientPoolStats.js +52 -0
- package/dist/src/clients/EthWeb3Client.js +35 -0
- package/dist/src/clients/HardhatWeb3Client.js +56 -0
- package/dist/src/clients/PolyWeb3Client.js +77 -0
- package/dist/src/clients/Web3Client.js +186 -0
- package/dist/src/clients/Web3ClientFactory.js +32 -0
- package/dist/src/clients/interfaces/IWeb3Client.js +2 -0
- package/dist/src/clients/interfaces/IWeb3ClientStatus.js +2 -0
- package/dist/src/clients/interfaces/IWeb3EndpointOptions.js +2 -0
- package/dist/src/clients/model/ClientStatus.js +9 -0
- package/dist/src/clients/model/PromiEventWrap.js +52 -0
- package/dist/src/clients/model/SubscriptionWrap.js +42 -0
- package/dist/src/clients/utils/ClientEndpoints.js +27 -0
- package/dist/src/clients/utils/ClientErrorUtil.js +30 -0
- package/dist/src/clients/utils/TxFactory.js +14 -0
- package/dist/src/contracts/BscContract.js +30 -0
- package/dist/src/contracts/Contract.js +90 -0
- package/dist/src/contracts/ContractBase.js +139 -0
- package/dist/src/contracts/ContractFactory.js +17 -0
- package/dist/src/contracts/ContractProvider.js +40 -0
- package/dist/src/contracts/ContractReader.js +76 -0
- package/dist/src/contracts/ContractStream.js +20 -0
- package/dist/src/contracts/ContractWriter.js +62 -0
- package/dist/src/contracts/EthContract.js +31 -0
- package/dist/src/contracts/TxContract.js +37 -0
- package/dist/src/contracts/common/ERC20.js +14 -0
- package/dist/src/contracts/common/ERC20Polygon.js +14 -0
- package/dist/src/contracts/common/PoolPair.js +23 -0
- package/dist/src/contracts/utils/AbiDeserializer.js +89 -0
- package/dist/src/contracts/utils/ConvertUtils.js +21 -0
- package/dist/src/contracts/utils/InputDataUtils.js +87 -0
- package/dist/src/contracts/utils/TypeUtils.js +24 -0
- package/dist/src/defi/OneInch/OneInchRouter.js +14 -0
- package/dist/src/env/BigIntSerializer.js +19 -0
- package/dist/src/gen/Ast.js +12 -0
- package/dist/src/gen/ContractTemplate.js +27 -0
- package/dist/src/gen/Generator.js +180 -0
- package/dist/src/gen/GeneratorFromAbi.js +361 -0
- package/dist/src/handlers/TokenHandler.js +69 -0
- package/dist/src/indexer/BlocksTxIndexer.js +52 -0
- package/dist/src/indexer/PendingTxIndexer.js +96 -0
- package/dist/src/indexer/handlers/BlocksWalker.js +306 -0
- package/dist/src/indexer/handlers/TxQueueLoader.js +117 -0
- package/dist/src/json/JsonArrayStore.js +296 -0
- package/dist/src/json/JsonObjectStore.js +214 -0
- package/dist/src/json/JsonStore.spec.js +83 -0
- package/dist/src/loggers/ILogger.js +2 -0
- package/dist/src/loggers/LoggerService.js +34 -0
- package/dist/src/loggers/TxLoggerService.js +122 -0
- package/dist/src/models/IContractDetails.js +2 -0
- package/dist/src/models/IToken.js +2 -0
- package/dist/src/models/ITokenGlob.js +6 -0
- package/dist/src/models/ITransactionDetails.js +2 -0
- package/dist/src/models/TAddress.js +2 -0
- package/dist/src/models/TBufferLike.js +2 -0
- package/dist/src/models/THex.js +2 -0
- package/dist/src/models/TPlatform.js +2 -0
- package/dist/src/models/TResult.js +2 -0
- package/dist/src/ns/NameService.js +19 -0
- package/dist/src/ns/providers/EnsProvider.js +41 -0
- package/dist/src/ns/providers/INsProvider.js +2 -0
- package/dist/src/ns/providers/UDProvider.js +39 -0
- package/dist/src/ns/utils/$ns.js +17 -0
- package/dist/src/structs/PackedRanges.js +186 -0
- package/dist/src/structs/PackedRanges.spec.js +30 -0
- package/dist/src/tokens/TokenExchangeService.js +110 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/AmmUtilts.js +17 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.js +15 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.js +15 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.js +16 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +144 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.js +15 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.js +15 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.js +22 -0
- package/dist/src/tokens/TokenExchanges/AmmV2ExchangeBase.js +194 -0
- package/dist/src/tokens/TokenExchanges/OneInchExchange.js +92 -0
- package/dist/src/tokens/TokenExchanges/PancakeswapExchange.js +28 -0
- package/dist/src/tokens/TokenExchanges/SushiswapPolygonExchange.js +28 -0
- package/dist/src/tokens/TokenExchanges/UniswapExchange.js +28 -0
- package/dist/src/tokens/TokenOracles/AmmPriceV2Oracle.js +319 -0
- package/dist/src/tokens/TokenOracles/TokenPriceStore.js +108 -0
- package/dist/src/tokens/TokenPriceService.js +196 -0
- package/dist/src/tokens/TokenPriceServiceProvider.js +31 -0
- package/dist/src/tokens/TokenProviders/ATokenProvider.js +38 -0
- package/dist/src/tokens/TokenProviders/ITokenProvider.js +2 -0
- package/dist/src/tokens/TokenProviders/TPChain.js +35 -0
- package/dist/src/tokens/TokenProviders/TPCoinmarketcap.js +63 -0
- package/dist/src/tokens/TokenProviders/TPOneInch.js +65 -0
- package/dist/src/tokens/TokenProviders/TPSushiswap.js +89 -0
- package/dist/src/tokens/TokenProviders/TPUniswap.js +84 -0
- package/dist/src/tokens/TokenService.js +115 -0
- package/dist/src/tokens/TokenSwapService.js +37 -0
- package/dist/src/tokens/TokenTransferService.js +189 -0
- package/dist/src/tokens/TokensService.js +236 -0
- package/dist/src/tokens/TokensServiceBsc.js +18 -0
- package/dist/src/tokens/TokensServiceEth.js +15 -0
- package/dist/src/tokens/TokensServiceFactory.js +29 -0
- package/dist/src/tokens/TokensServicePolygon.js +18 -0
- package/dist/src/tokens/TokensServiceXDai.js +24 -0
- package/dist/src/tokens/defi/ISwapService.js +2 -0
- package/dist/src/tokens/defi/paraswap/Paraswap.js +135 -0
- package/dist/src/tokens/erc20/eth/WETH.js +14 -0
- package/dist/src/tokens/utils/TokenUtils.js +66 -0
- package/dist/src/txs/ITxConfig.js +2 -0
- package/dist/src/txs/TxDataBuilder.js +159 -0
- package/dist/src/txs/TxLogger.js +119 -0
- package/dist/src/txs/TxProvider.js +73 -0
- package/dist/src/txs/TxService.js +19 -0
- package/dist/src/txs/TxWriter.js +287 -0
- package/dist/src/txs/conditional/GasWatcherLogger.js +61 -0
- package/dist/src/txs/conditional/GasWatcherService.js +103 -0
- package/dist/src/txs/conditional/GasWatcherStore.js +25 -0
- package/dist/src/txs/conditional/GasWatcherTx.js +126 -0
- package/dist/src/txs/receipt/ITxLogItem.js +2 -0
- package/dist/src/txs/receipt/TxLogParser.js +27 -0
- package/dist/src/txs/receipt/TxLogsTransfer.js +50 -0
- package/dist/src/txs/receipt/TxTopicInMemoryProvider.js +41 -0
- package/dist/src/txs/receipt/TxTopicProvider.js +25 -0
- package/dist/src/utils/$abiParser.js +159 -0
- package/dist/src/utils/$abiType.js +77 -0
- package/dist/src/utils/$abiUtils.js +43 -0
- package/dist/src/utils/$address.js +41 -0
- package/dist/src/utils/$array.js +60 -0
- package/dist/src/utils/$bigint.js +130 -0
- package/dist/src/utils/$block.js +10 -0
- package/dist/src/utils/$class.js +13 -0
- package/dist/src/utils/$config.js +18 -0
- package/dist/src/utils/$contract.js +67 -0
- package/dist/src/utils/$csv.js +79 -0
- package/dist/src/utils/$date.js +496 -0
- package/dist/src/utils/$fn.js +117 -0
- package/dist/src/utils/$is.js +40 -0
- package/dist/src/utils/$logger.js +15 -0
- package/dist/src/utils/$number.js +95 -0
- package/dist/src/utils/$object.js +82 -0
- package/dist/src/utils/$path.js +33 -0
- package/dist/src/utils/$promise.js +13 -0
- package/dist/src/utils/$require.js +127 -0
- package/dist/src/utils/$sign.js +35 -0
- package/dist/src/utils/$signSerializer.js +264 -0
- package/dist/src/utils/$wallet.js +13 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/wallets/Wallet.js +26 -0
- package/dist/src/wallets/WalletBsc.js +17 -0
- package/dist/src/wallets/WalletService.js +35 -0
- package/dist/src/www/utils/BlockChainExplorerFormatter.js +15 -0
- package/hardhat.config.js +6 -0
- package/package.json +52 -0
- package/readme.md +76 -0
- package/src/BlockchainExplorer/BlockChainExplorerFactory.ts +273 -0
- package/src/BlockchainExplorer/BlockChainExplorerProvider.ts +26 -0
- package/src/BlockchainExplorer/BlockNumberCache.ts +46 -0
- package/src/BlockchainExplorer/Bscscan.ts +23 -0
- package/src/BlockchainExplorer/Etherscan.ts +25 -0
- package/src/BlockchainExplorer/IAbiProvider.ts +5 -0
- package/src/BlockchainExplorer/IBlockChainExplorer.ts +37 -0
- package/src/BlockchainExplorer/Polyscan.ts +23 -0
- package/src/ChainAccounts.ts +72 -0
- package/src/ChainAccountsService.ts +74 -0
- package/src/Config.ts +34 -0
- package/src/blocks/BlockDateResolver.ts +149 -0
- package/src/bridges/BridgeFactory.ts +16 -0
- package/src/bridges/hop/HopAddresses.ts +518 -0
- package/src/bridges/hop/HopBridge.ts +430 -0
- package/src/bridges/hop/contracts/gen.act.ts +50 -0
- package/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.ts +69 -0
- package/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.ts +453 -0
- package/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.ts +264 -0
- package/src/bridges/models/IBridge.ts +43 -0
- package/src/bridges/wormhole/contracts/WormholeBridgeContract.ts +14 -0
- package/src/chains/PlatformFactory.ts +45 -0
- package/src/chains/arbitrum/ArbTokenProvider.ts +39 -0
- package/src/chains/arbitrum/ArbWeb3Client.ts +39 -0
- package/src/chains/arbitrum/Arbiscan.ts +24 -0
- package/src/chains/boba/BobaWeb3Client.ts +49 -0
- package/src/chains/boba/Bobascan.ts +25 -0
- package/src/chains/xdai/XDaiWeb3Client.ts +82 -0
- package/src/chains/xdai/XDaiscan.ts +24 -0
- package/src/chains/xdai/tokens/WXDaiTokenContract.json +279 -0
- package/src/chains/xdai/tokens/WXDaiTokenContract.ts +14 -0
- package/src/clients/BscWeb3Client.ts +38 -0
- package/src/clients/ClientEventsStream.ts +33 -0
- package/src/clients/ClientPool.ts +673 -0
- package/src/clients/ClientPoolStats.ts +64 -0
- package/src/clients/EthWeb3Client.ts +36 -0
- package/src/clients/HardhatWeb3Client.ts +60 -0
- package/src/clients/PolyWeb3Client.ts +91 -0
- package/src/clients/Web3Client.ts +228 -0
- package/src/clients/Web3ClientFactory.ts +28 -0
- package/src/clients/interfaces/IWeb3Client.ts +14 -0
- package/src/clients/interfaces/IWeb3ClientStatus.ts +23 -0
- package/src/clients/interfaces/IWeb3EndpointOptions.ts +9 -0
- package/src/clients/model/ClientStatus.ts +5 -0
- package/src/clients/model/PromiEventWrap.ts +61 -0
- package/src/clients/model/SubscriptionWrap.ts +53 -0
- package/src/clients/utils/ClientEndpoints.ts +26 -0
- package/src/clients/utils/ClientErrorUtil.ts +26 -0
- package/src/clients/utils/TxFactory.ts +17 -0
- package/src/contracts/BscContract.ts +28 -0
- package/src/contracts/Contract.ts +126 -0
- package/src/contracts/ContractBase.ts +158 -0
- package/src/contracts/ContractFactory.ts +19 -0
- package/src/contracts/ContractProvider.ts +55 -0
- package/src/contracts/ContractReader.ts +87 -0
- package/src/contracts/ContractStream.ts +18 -0
- package/src/contracts/ContractWriter.ts +97 -0
- package/src/contracts/EthContract.ts +29 -0
- package/src/contracts/TxContract.ts +43 -0
- package/src/contracts/common/ERC20.ts +13 -0
- package/src/contracts/common/ERC20Polygon.ts +13 -0
- package/src/contracts/common/PoolPair.ts +22 -0
- package/src/contracts/utils/AbiDeserializer.ts +98 -0
- package/src/contracts/utils/ConvertUtils.ts +16 -0
- package/src/contracts/utils/InputDataUtils.ts +93 -0
- package/src/contracts/utils/TypeUtils.ts +21 -0
- package/src/defi/OneInch/OneInchRouter.ts +13 -0
- package/src/env/BigIntSerializer.ts +18 -0
- package/src/gen/Ast.ts +12 -0
- package/src/gen/ContractTemplate.ts +36 -0
- package/src/gen/Generator.ts +227 -0
- package/src/gen/GeneratorFromAbi.ts +402 -0
- package/src/handlers/TokenHandler.ts +78 -0
- package/src/indexer/BlocksTxIndexer.ts +69 -0
- package/src/indexer/PendingTxIndexer.ts +124 -0
- package/src/indexer/handlers/BlocksWalker.ts +390 -0
- package/src/indexer/handlers/TxQueueLoader.ts +143 -0
- package/src/json/JsonArrayStore.ts +310 -0
- package/src/json/JsonObjectStore.ts +239 -0
- package/src/json/JsonStore.spec.ts +98 -0
- package/src/loggers/ILogger.ts +3 -0
- package/src/loggers/LoggerService.ts +39 -0
- package/src/loggers/TxLoggerService.ts +146 -0
- package/src/models/IContractDetails.ts +8 -0
- package/src/models/IToken.ts +11 -0
- package/src/models/ITokenGlob.ts +14 -0
- package/src/models/ITransactionDetails.ts +11 -0
- package/src/models/TAddress.ts +1 -0
- package/src/models/TBufferLike.ts +2 -0
- package/src/models/THex.ts +1 -0
- package/src/models/TPlatform.ts +1 -0
- package/src/models/TResult.ts +6 -0
- package/src/ns/NameService.ts +21 -0
- package/src/ns/providers/EnsProvider.ts +45 -0
- package/src/ns/providers/INsProvider.ts +6 -0
- package/src/ns/providers/UDProvider.ts +49 -0
- package/src/ns/utils/$ns.ts +15 -0
- package/src/structs/PackedRanges.spec.ts +38 -0
- package/src/structs/PackedRanges.ts +207 -0
- package/src/tokens/TokenExchangeService.ts +126 -0
- package/src/tokens/TokenExchanges/AmmBase/AmmUtilts.ts +16 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.ts +15 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.ts +15 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.ts +17 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +208 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.ts +15 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.ts +15 -0
- package/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.ts +24 -0
- package/src/tokens/TokenExchanges/AmmV2ExchangeBase.ts +242 -0
- package/src/tokens/TokenExchanges/OneInchExchange.ts +111 -0
- package/src/tokens/TokenExchanges/PancakeswapExchange.ts +30 -0
- package/src/tokens/TokenExchanges/SushiswapPolygonExchange.ts +30 -0
- package/src/tokens/TokenExchanges/UniswapExchange.ts +31 -0
- package/src/tokens/TokenOracles/AmmPriceV2Oracle.ts +440 -0
- package/src/tokens/TokenOracles/TokenPriceStore.ts +129 -0
- package/src/tokens/TokenPriceService.ts +276 -0
- package/src/tokens/TokenPriceServiceProvider.ts +36 -0
- package/src/tokens/TokenProviders/ATokenProvider.ts +42 -0
- package/src/tokens/TokenProviders/ITokenProvider.ts +9 -0
- package/src/tokens/TokenProviders/TPChain.ts +41 -0
- package/src/tokens/TokenProviders/TPCoinmarketcap.ts +82 -0
- package/src/tokens/TokenProviders/TPOneInch.ts +71 -0
- package/src/tokens/TokenProviders/TPSushiswap.ts +96 -0
- package/src/tokens/TokenProviders/TPUniswap.ts +85 -0
- package/src/tokens/TokenService.ts +128 -0
- package/src/tokens/TokenSwapService.ts +47 -0
- package/src/tokens/TokenTransferService.ts +216 -0
- package/src/tokens/TokensService.ts +252 -0
- package/src/tokens/TokensServiceBsc.ts +17 -0
- package/src/tokens/TokensServiceEth.ts +9 -0
- package/src/tokens/TokensServiceFactory.ts +24 -0
- package/src/tokens/TokensServicePolygon.ts +17 -0
- package/src/tokens/TokensServiceXDai.ts +26 -0
- package/src/tokens/defi/ISwapService.ts +12 -0
- package/src/tokens/defi/paraswap/Paraswap.ts +244 -0
- package/src/tokens/erc20/eth/WETH.ts +13 -0
- package/src/tokens/utils/TokenUtils.ts +63 -0
- package/src/txs/ITxConfig.ts +27 -0
- package/src/txs/TxDataBuilder.ts +207 -0
- package/src/txs/TxLogger.ts +121 -0
- package/src/txs/TxProvider.ts +68 -0
- package/src/txs/TxService.ts +19 -0
- package/src/txs/TxWriter.ts +370 -0
- package/src/txs/conditional/GasWatcherLogger.ts +57 -0
- package/src/txs/conditional/GasWatcherService.ts +117 -0
- package/src/txs/conditional/GasWatcherStore.ts +40 -0
- package/src/txs/conditional/GasWatcherTx.ts +143 -0
- package/src/txs/receipt/ITxLogItem.ts +25 -0
- package/src/txs/receipt/TxLogParser.ts +29 -0
- package/src/txs/receipt/TxLogsTransfer.ts +61 -0
- package/src/txs/receipt/TxTopicInMemoryProvider.ts +45 -0
- package/src/txs/receipt/TxTopicProvider.ts +29 -0
- package/src/utils/$abiParser.ts +179 -0
- package/src/utils/$abiType.ts +85 -0
- package/src/utils/$abiUtils.ts +38 -0
- package/src/utils/$address.ts +37 -0
- package/src/utils/$array.ts +57 -0
- package/src/utils/$bigint.ts +127 -0
- package/src/utils/$block.ts +7 -0
- package/src/utils/$class.ts +8 -0
- package/src/utils/$config.ts +17 -0
- package/src/utils/$contract.ts +67 -0
- package/src/utils/$csv.ts +54 -0
- package/src/utils/$date.ts +473 -0
- package/src/utils/$fn.ts +134 -0
- package/src/utils/$is.ts +37 -0
- package/src/utils/$logger.ts +10 -0
- package/src/utils/$number.ts +89 -0
- package/src/utils/$object.ts +95 -0
- package/src/utils/$path.ts +32 -0
- package/src/utils/$promise.ts +7 -0
- package/src/utils/$require.ts +118 -0
- package/src/utils/$sign.ts +36 -0
- package/src/utils/$signSerializer.ts +339 -0
- package/src/utils/$wallet.ts +10 -0
- package/src/utils/types.ts +29 -0
- package/src/wallets/Wallet.ts +33 -0
- package/src/wallets/WalletBsc.ts +13 -0
- package/src/wallets/WalletService.ts +43 -0
- package/src/www/utils/BlockChainExplorerFormatter.ts +13 -0
- package/test/ChainAccount.spec.ts +9 -0
- package/test/client.spec.ts +59 -0
- package/test/fixtures/DaiTokenContract.ts +13 -0
- package/test/fixtures/receipts/swap.json +94 -0
- package/test/generate/class.spec.ts +27 -0
- package/test/hardhat/TestNode.ts +61 -0
- package/test/ns.spec.ts +30 -0
- package/test/receipt.spec.ts +27 -0
- package/test/utils/abi-parser.spec.ts +117 -0
- package/test/utils/bigint.spec.ts +40 -0
- package/test/utils/date.spec.ts +8 -0
- package/test/utils/fn.spec.ts +39 -0
- package/test/utils/number.spec.ts +41 -0
- package/test/utils/sign.spec.ts +22 -0
- package/tsconfig-build.json +24 -0
- package/tsconfig-src.json +36 -0
- package/tsconfig.json +27 -0
- package/typings/globals/assertion/index.d.ts +159 -0
- package/typings/globals/assertion/typings.json +10 -0
- package/typings/globals/atma-utest/index.d.ts +53 -0
- package/typings/globals/atma-utest/typings.json +10 -0
- package/typings/globals/axios/index.d.ts +6 -0
- package/typings/globals/mask/index.d.ts +6 -0
- package/typings/globals/mask/typings.json +9 -0
- package/typings/index.d.ts +6 -0
- package/typings.json +6 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @dev Provides information about the current execution context, including the
|
|
7
|
+
* sender of the transaction and its data. While these are generally available
|
|
8
|
+
* via msg.sender and msg.data, they should not be accessed in such a direct
|
|
9
|
+
* manner, since when dealing with meta-transactions the account sending and
|
|
10
|
+
* paying for execution may not be the actual sender (as far as an application
|
|
11
|
+
* is concerned).
|
|
12
|
+
*
|
|
13
|
+
* This contract is only required for intermediate, library-like contracts.
|
|
14
|
+
*/
|
|
15
|
+
abstract contract Context {
|
|
16
|
+
function _msgSender() internal view virtual returns (address) {
|
|
17
|
+
return msg.sender;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _msgData() internal view virtual returns (bytes calldata) {
|
|
21
|
+
return msg.data;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "../Proxy.sol";
|
|
6
|
+
import "./ERC1967Upgrade.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
|
|
10
|
+
* implementation address that can be changed. This address is stored in storage in the location specified by
|
|
11
|
+
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
|
|
12
|
+
* implementation behind the proxy.
|
|
13
|
+
*/
|
|
14
|
+
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
|
|
15
|
+
/**
|
|
16
|
+
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
|
|
17
|
+
*
|
|
18
|
+
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
|
|
19
|
+
* function call, and allows initializating the storage of the proxy like a Solidity constructor.
|
|
20
|
+
*/
|
|
21
|
+
constructor(address _logic, bytes memory _data) payable {
|
|
22
|
+
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
|
|
23
|
+
_upgradeToAndCall(_logic, _data, false);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @dev Returns the current implementation address.
|
|
28
|
+
*/
|
|
29
|
+
function _implementation() internal view virtual override returns (address impl) {
|
|
30
|
+
return ERC1967Upgrade._getImplementation();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.2;
|
|
4
|
+
|
|
5
|
+
import "../beacon/IBeacon.sol";
|
|
6
|
+
import "../../utils/Address.sol";
|
|
7
|
+
import "../../utils/StorageSlot.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @dev This abstract contract provides getters and event emitting update functions for
|
|
11
|
+
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
|
|
12
|
+
*
|
|
13
|
+
* _Available since v4.1._
|
|
14
|
+
*
|
|
15
|
+
* @custom:oz-upgrades-unsafe-allow delegatecall
|
|
16
|
+
*/
|
|
17
|
+
abstract contract ERC1967Upgrade {
|
|
18
|
+
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
|
|
19
|
+
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @dev Storage slot with the address of the current implementation.
|
|
23
|
+
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
|
|
24
|
+
* validated in the constructor.
|
|
25
|
+
*/
|
|
26
|
+
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @dev Emitted when the implementation is upgraded.
|
|
30
|
+
*/
|
|
31
|
+
event Upgraded(address indexed implementation);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @dev Returns the current implementation address.
|
|
35
|
+
*/
|
|
36
|
+
function _getImplementation() internal view returns (address) {
|
|
37
|
+
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @dev Stores a new address in the EIP1967 implementation slot.
|
|
42
|
+
*/
|
|
43
|
+
function _setImplementation(address newImplementation) private {
|
|
44
|
+
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
|
|
45
|
+
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @dev Perform implementation upgrade
|
|
50
|
+
*
|
|
51
|
+
* Emits an {Upgraded} event.
|
|
52
|
+
*/
|
|
53
|
+
function _upgradeTo(address newImplementation) internal {
|
|
54
|
+
_setImplementation(newImplementation);
|
|
55
|
+
emit Upgraded(newImplementation);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @dev Perform implementation upgrade with additional setup call.
|
|
60
|
+
*
|
|
61
|
+
* Emits an {Upgraded} event.
|
|
62
|
+
*/
|
|
63
|
+
function _upgradeToAndCall(
|
|
64
|
+
address newImplementation,
|
|
65
|
+
bytes memory data,
|
|
66
|
+
bool forceCall
|
|
67
|
+
) internal {
|
|
68
|
+
_upgradeTo(newImplementation);
|
|
69
|
+
if (data.length > 0 || forceCall) {
|
|
70
|
+
Address.functionDelegateCall(newImplementation, data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
|
|
76
|
+
*
|
|
77
|
+
* Emits an {Upgraded} event.
|
|
78
|
+
*/
|
|
79
|
+
function _upgradeToAndCallSecure(
|
|
80
|
+
address newImplementation,
|
|
81
|
+
bytes memory data,
|
|
82
|
+
bool forceCall
|
|
83
|
+
) internal {
|
|
84
|
+
address oldImplementation = _getImplementation();
|
|
85
|
+
|
|
86
|
+
// Initial upgrade and setup call
|
|
87
|
+
_setImplementation(newImplementation);
|
|
88
|
+
if (data.length > 0 || forceCall) {
|
|
89
|
+
Address.functionDelegateCall(newImplementation, data);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Perform rollback test if not already in progress
|
|
93
|
+
StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
|
|
94
|
+
if (!rollbackTesting.value) {
|
|
95
|
+
// Trigger rollback using upgradeTo from the new implementation
|
|
96
|
+
rollbackTesting.value = true;
|
|
97
|
+
Address.functionDelegateCall(
|
|
98
|
+
newImplementation,
|
|
99
|
+
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
|
|
100
|
+
);
|
|
101
|
+
rollbackTesting.value = false;
|
|
102
|
+
// Check rollback was effective
|
|
103
|
+
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
|
|
104
|
+
// Finally reset to the new implementation and log the upgrade
|
|
105
|
+
_upgradeTo(newImplementation);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @dev Storage slot with the admin of the contract.
|
|
111
|
+
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
|
|
112
|
+
* validated in the constructor.
|
|
113
|
+
*/
|
|
114
|
+
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @dev Emitted when the admin account has changed.
|
|
118
|
+
*/
|
|
119
|
+
event AdminChanged(address previousAdmin, address newAdmin);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @dev Returns the current admin.
|
|
123
|
+
*/
|
|
124
|
+
function _getAdmin() internal view returns (address) {
|
|
125
|
+
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @dev Stores a new address in the EIP1967 admin slot.
|
|
130
|
+
*/
|
|
131
|
+
function _setAdmin(address newAdmin) private {
|
|
132
|
+
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
|
|
133
|
+
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @dev Changes the admin of the proxy.
|
|
138
|
+
*
|
|
139
|
+
* Emits an {AdminChanged} event.
|
|
140
|
+
*/
|
|
141
|
+
function _changeAdmin(address newAdmin) internal {
|
|
142
|
+
emit AdminChanged(_getAdmin(), newAdmin);
|
|
143
|
+
_setAdmin(newAdmin);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
|
|
148
|
+
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
|
|
149
|
+
*/
|
|
150
|
+
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @dev Emitted when the beacon is upgraded.
|
|
154
|
+
*/
|
|
155
|
+
event BeaconUpgraded(address indexed beacon);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @dev Returns the current beacon.
|
|
159
|
+
*/
|
|
160
|
+
function _getBeacon() internal view returns (address) {
|
|
161
|
+
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @dev Stores a new beacon in the EIP1967 beacon slot.
|
|
166
|
+
*/
|
|
167
|
+
function _setBeacon(address newBeacon) private {
|
|
168
|
+
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
|
|
169
|
+
require(
|
|
170
|
+
Address.isContract(IBeacon(newBeacon).implementation()),
|
|
171
|
+
"ERC1967: beacon implementation is not a contract"
|
|
172
|
+
);
|
|
173
|
+
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
|
|
178
|
+
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
|
|
179
|
+
*
|
|
180
|
+
* Emits a {BeaconUpgraded} event.
|
|
181
|
+
*/
|
|
182
|
+
function _upgradeBeaconToAndCall(
|
|
183
|
+
address newBeacon,
|
|
184
|
+
bytes memory data,
|
|
185
|
+
bool forceCall
|
|
186
|
+
) internal {
|
|
187
|
+
_setBeacon(newBeacon);
|
|
188
|
+
emit BeaconUpgraded(newBeacon);
|
|
189
|
+
if (data.length > 0 || forceCall) {
|
|
190
|
+
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @dev This is the interface that {BeaconProxy} expects of its beacon.
|
|
7
|
+
*/
|
|
8
|
+
interface IBeacon {
|
|
9
|
+
/**
|
|
10
|
+
* @dev Must return an address that can be used as a delegate call target.
|
|
11
|
+
*
|
|
12
|
+
* {BeaconProxy} will check that this address is a contract.
|
|
13
|
+
*/
|
|
14
|
+
function implementation() external view returns (address);
|
|
15
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @dev Interface of the ERC20 standard as defined in the EIP.
|
|
7
|
+
*/
|
|
8
|
+
interface IERC20 {
|
|
9
|
+
/**
|
|
10
|
+
* @dev Returns the amount of tokens in existence.
|
|
11
|
+
*/
|
|
12
|
+
function totalSupply() external view returns (uint256);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @dev Returns the amount of tokens owned by `account`.
|
|
16
|
+
*/
|
|
17
|
+
function balanceOf(address account) external view returns (uint256);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
|
21
|
+
*
|
|
22
|
+
* Returns a boolean value indicating whether the operation succeeded.
|
|
23
|
+
*
|
|
24
|
+
* Emits a {Transfer} event.
|
|
25
|
+
*/
|
|
26
|
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @dev Returns the remaining number of tokens that `spender` will be
|
|
30
|
+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
|
31
|
+
* zero by default.
|
|
32
|
+
*
|
|
33
|
+
* This value changes when {approve} or {transferFrom} are called.
|
|
34
|
+
*/
|
|
35
|
+
function allowance(address owner, address spender) external view returns (uint256);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
|
39
|
+
*
|
|
40
|
+
* Returns a boolean value indicating whether the operation succeeded.
|
|
41
|
+
*
|
|
42
|
+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
|
43
|
+
* that someone may use both the old and the new allowance by unfortunate
|
|
44
|
+
* transaction ordering. One possible solution to mitigate this race
|
|
45
|
+
* condition is to first reduce the spender's allowance to 0 and set the
|
|
46
|
+
* desired value afterwards:
|
|
47
|
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
|
48
|
+
*
|
|
49
|
+
* Emits an {Approval} event.
|
|
50
|
+
*/
|
|
51
|
+
function approve(address spender, uint256 amount) external returns (bool);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
|
55
|
+
* allowance mechanism. `amount` is then deducted from the caller's
|
|
56
|
+
* allowance.
|
|
57
|
+
*
|
|
58
|
+
* Returns a boolean value indicating whether the operation succeeded.
|
|
59
|
+
*
|
|
60
|
+
* Emits a {Transfer} event.
|
|
61
|
+
*/
|
|
62
|
+
function transferFrom(
|
|
63
|
+
address sender,
|
|
64
|
+
address recipient,
|
|
65
|
+
uint256 amount
|
|
66
|
+
) external returns (bool);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
|
70
|
+
* another (`to`).
|
|
71
|
+
*
|
|
72
|
+
* Note that `value` may be zero.
|
|
73
|
+
*/
|
|
74
|
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
|
78
|
+
* a call to {approve}. `value` is the new allowance.
|
|
79
|
+
*/
|
|
80
|
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
|
81
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// contracts/Messages.sol
|
|
2
|
+
// SPDX-License-Identifier: Apache 2
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
import "../Structs.sol";
|
|
7
|
+
|
|
8
|
+
interface IWormhole is Structs {
|
|
9
|
+
event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel);
|
|
10
|
+
|
|
11
|
+
function publishMessage(
|
|
12
|
+
uint32 nonce,
|
|
13
|
+
bytes memory payload,
|
|
14
|
+
uint8 consistencyLevel
|
|
15
|
+
) external payable returns (uint64 sequence);
|
|
16
|
+
|
|
17
|
+
function parseAndVerifyVM(bytes calldata encodedVM) external view returns (Structs.VM memory vm, bool valid, string memory reason);
|
|
18
|
+
|
|
19
|
+
function verifyVM(Structs.VM memory vm) external view returns (bool valid, string memory reason);
|
|
20
|
+
|
|
21
|
+
function verifySignatures(bytes32 hash, Structs.Signature[] memory signatures, Structs.GuardianSet memory guardianSet) external pure returns (bool valid, string memory reason) ;
|
|
22
|
+
|
|
23
|
+
function parseVM(bytes memory encodedVM) external pure returns (Structs.VM memory vm);
|
|
24
|
+
|
|
25
|
+
function getGuardianSet(uint32 index) external view returns (Structs.GuardianSet memory) ;
|
|
26
|
+
|
|
27
|
+
function getCurrentGuardianSetIndex() external view returns (uint32) ;
|
|
28
|
+
|
|
29
|
+
function getGuardianSetExpiry() external view returns (uint32) ;
|
|
30
|
+
|
|
31
|
+
function governanceActionIsConsumed(bytes32 hash) external view returns (bool) ;
|
|
32
|
+
|
|
33
|
+
function isInitialized(address impl) external view returns (bool) ;
|
|
34
|
+
|
|
35
|
+
function chainId() external view returns (uint16) ;
|
|
36
|
+
|
|
37
|
+
function governanceChainId() external view returns (uint16);
|
|
38
|
+
|
|
39
|
+
function governanceContract() external view returns (bytes32);
|
|
40
|
+
|
|
41
|
+
function messageFee() external view returns (uint256) ;
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "../utils/Context.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @dev Contract module which provides a basic access control mechanism, where
|
|
9
|
+
* there is an account (an owner) that can be granted exclusive access to
|
|
10
|
+
* specific functions.
|
|
11
|
+
*
|
|
12
|
+
* By default, the owner account will be the one that deploys the contract. This
|
|
13
|
+
* can later be changed with {transferOwnership}.
|
|
14
|
+
*
|
|
15
|
+
* This module is used through inheritance. It will make available the modifier
|
|
16
|
+
* `onlyOwner`, which can be applied to your functions to restrict their use to
|
|
17
|
+
* the owner.
|
|
18
|
+
*/
|
|
19
|
+
abstract contract Ownable is Context {
|
|
20
|
+
address private _owner;
|
|
21
|
+
|
|
22
|
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @dev Initializes the contract setting the deployer as the initial owner.
|
|
26
|
+
*/
|
|
27
|
+
constructor() {
|
|
28
|
+
_setOwner(_msgSender());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @dev Returns the address of the current owner.
|
|
33
|
+
*/
|
|
34
|
+
function owner() public view virtual returns (address) {
|
|
35
|
+
return _owner;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @dev Throws if called by any account other than the owner.
|
|
40
|
+
*/
|
|
41
|
+
modifier onlyOwner() {
|
|
42
|
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
|
43
|
+
_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @dev Leaves the contract without owner. It will not be possible to call
|
|
48
|
+
* `onlyOwner` functions anymore. Can only be called by the current owner.
|
|
49
|
+
*
|
|
50
|
+
* NOTE: Renouncing ownership will leave the contract without an owner,
|
|
51
|
+
* thereby removing any functionality that is only available to the owner.
|
|
52
|
+
*/
|
|
53
|
+
function renounceOwnership() public virtual onlyOwner {
|
|
54
|
+
_setOwner(address(0));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
59
|
+
* Can only be called by the current owner.
|
|
60
|
+
*/
|
|
61
|
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
62
|
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
63
|
+
_setOwner(newOwner);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _setOwner(address newOwner) private {
|
|
67
|
+
address oldOwner = _owner;
|
|
68
|
+
_owner = newOwner;
|
|
69
|
+
emit OwnershipTransferred(oldOwner, newOwner);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
|
|
7
|
+
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
|
|
8
|
+
* be specified by overriding the virtual {_implementation} function.
|
|
9
|
+
*
|
|
10
|
+
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
|
|
11
|
+
* different contract through the {_delegate} function.
|
|
12
|
+
*
|
|
13
|
+
* The success and return data of the delegated call will be returned back to the caller of the proxy.
|
|
14
|
+
*/
|
|
15
|
+
abstract contract Proxy {
|
|
16
|
+
/**
|
|
17
|
+
* @dev Delegates the current call to `implementation`.
|
|
18
|
+
*
|
|
19
|
+
* This function does not return to its internall call site, it will return directly to the external caller.
|
|
20
|
+
*/
|
|
21
|
+
function _delegate(address implementation) internal virtual {
|
|
22
|
+
assembly {
|
|
23
|
+
// Copy msg.data. We take full control of memory in this inline assembly
|
|
24
|
+
// block because it will not return to Solidity code. We overwrite the
|
|
25
|
+
// Solidity scratch pad at memory position 0.
|
|
26
|
+
calldatacopy(0, 0, calldatasize())
|
|
27
|
+
|
|
28
|
+
// Call the implementation.
|
|
29
|
+
// out and outsize are 0 because we don't know the size yet.
|
|
30
|
+
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
|
|
31
|
+
|
|
32
|
+
// Copy the returned data.
|
|
33
|
+
returndatacopy(0, 0, returndatasize())
|
|
34
|
+
|
|
35
|
+
switch result
|
|
36
|
+
// delegatecall returns 0 on error.
|
|
37
|
+
case 0 {
|
|
38
|
+
revert(0, returndatasize())
|
|
39
|
+
}
|
|
40
|
+
default {
|
|
41
|
+
return(0, returndatasize())
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
|
|
48
|
+
* and {_fallback} should delegate.
|
|
49
|
+
*/
|
|
50
|
+
function _implementation() internal view virtual returns (address);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @dev Delegates the current call to the address returned by `_implementation()`.
|
|
54
|
+
*
|
|
55
|
+
* This function does not return to its internall call site, it will return directly to the external caller.
|
|
56
|
+
*/
|
|
57
|
+
function _fallback() internal virtual {
|
|
58
|
+
_beforeFallback();
|
|
59
|
+
_delegate(_implementation());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
|
|
64
|
+
* function in the contract matches the call data.
|
|
65
|
+
*/
|
|
66
|
+
fallback() external payable virtual {
|
|
67
|
+
_fallback();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
|
|
72
|
+
* is empty.
|
|
73
|
+
*/
|
|
74
|
+
receive() external payable virtual {
|
|
75
|
+
_fallback();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
|
|
80
|
+
* call, or as part of the Solidity `fallback` or `receive` functions.
|
|
81
|
+
*
|
|
82
|
+
* If overriden should call `super._beforeFallback()`.
|
|
83
|
+
*/
|
|
84
|
+
function _beforeFallback() internal virtual {}
|
|
85
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "../IERC20.sol";
|
|
6
|
+
import "../../../utils/Address.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title SafeERC20
|
|
10
|
+
* @dev Wrappers around ERC20 operations that throw on failure (when the token
|
|
11
|
+
* contract returns false). Tokens that return no value (and instead revert or
|
|
12
|
+
* throw on failure) are also supported, non-reverting calls are assumed to be
|
|
13
|
+
* successful.
|
|
14
|
+
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
|
|
15
|
+
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
|
|
16
|
+
*/
|
|
17
|
+
library SafeERC20 {
|
|
18
|
+
using Address for address;
|
|
19
|
+
|
|
20
|
+
function safeTransfer(
|
|
21
|
+
IERC20 token,
|
|
22
|
+
address to,
|
|
23
|
+
uint256 value
|
|
24
|
+
) internal {
|
|
25
|
+
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function safeTransferFrom(
|
|
29
|
+
IERC20 token,
|
|
30
|
+
address from,
|
|
31
|
+
address to,
|
|
32
|
+
uint256 value
|
|
33
|
+
) internal {
|
|
34
|
+
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @dev Deprecated. This function has issues similar to the ones found in
|
|
39
|
+
* {IERC20-approve}, and its usage is discouraged.
|
|
40
|
+
*
|
|
41
|
+
* Whenever possible, use {safeIncreaseAllowance} and
|
|
42
|
+
* {safeDecreaseAllowance} instead.
|
|
43
|
+
*/
|
|
44
|
+
function safeApprove(
|
|
45
|
+
IERC20 token,
|
|
46
|
+
address spender,
|
|
47
|
+
uint256 value
|
|
48
|
+
) internal {
|
|
49
|
+
// safeApprove should only be called when setting an initial allowance,
|
|
50
|
+
// or when resetting it to zero. To increase and decrease it, use
|
|
51
|
+
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
|
|
52
|
+
require(
|
|
53
|
+
(value == 0) || (token.allowance(address(this), spender) == 0),
|
|
54
|
+
"SafeERC20: approve from non-zero to non-zero allowance"
|
|
55
|
+
);
|
|
56
|
+
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function safeIncreaseAllowance(
|
|
60
|
+
IERC20 token,
|
|
61
|
+
address spender,
|
|
62
|
+
uint256 value
|
|
63
|
+
) internal {
|
|
64
|
+
uint256 newAllowance = token.allowance(address(this), spender) + value;
|
|
65
|
+
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function safeDecreaseAllowance(
|
|
69
|
+
IERC20 token,
|
|
70
|
+
address spender,
|
|
71
|
+
uint256 value
|
|
72
|
+
) internal {
|
|
73
|
+
unchecked {
|
|
74
|
+
uint256 oldAllowance = token.allowance(address(this), spender);
|
|
75
|
+
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
|
|
76
|
+
uint256 newAllowance = oldAllowance - value;
|
|
77
|
+
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
|
|
83
|
+
* on the return value: the return value is optional (but if data is returned, it must not be false).
|
|
84
|
+
* @param token The token targeted by the call.
|
|
85
|
+
* @param data The call data (encoded using abi.encode or one of its variants).
|
|
86
|
+
*/
|
|
87
|
+
function _callOptionalReturn(IERC20 token, bytes memory data) private {
|
|
88
|
+
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
|
|
89
|
+
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
|
|
90
|
+
// the target address contains contract code and also asserts for success in the low-level call.
|
|
91
|
+
|
|
92
|
+
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
|
|
93
|
+
if (returndata.length > 0) {
|
|
94
|
+
// Return data is optional
|
|
95
|
+
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|