dequanto 0.0.1 → 0.0.7
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/.circleci/config.yml +28 -0
- package/actions/contracts.act.ts +50 -0
- package/actions/logs.act.ts +7 -0
- package/actions/safe.act.ts +7 -0
- package/actions/tokens.act.ts +20 -2
- package/configs/defi.yml +24 -0
- package/configs/dequanto.yml +49 -2
- package/contracts/abi/gnosis/GnosisSafe.json +979 -0
- package/contracts/gen/base/{ERC20Base.ts → ERC20Base/ERC20Base.ts} +136 -90
- package/contracts/gen/eth/WETHBase.ts +35 -35
- package/contracts/gnosis/GnosisSafe.ts +750 -0
- package/contracts/openzeppelin/AccessControl.json +206 -0
- package/contracts/openzeppelin/AccessControl.ts +236 -0
- package/contracts/openzeppelin/AccessControlCrossChain.json +219 -0
- package/contracts/openzeppelin/AccessControlCrossChain.ts +247 -0
- package/contracts/openzeppelin/AccessControlEnumerable.json +249 -0
- package/contracts/openzeppelin/AccessControlEnumerable.ts +258 -0
- package/contracts/openzeppelin/Address.json +1 -0
- package/contracts/openzeppelin/Address.ts +83 -0
- package/contracts/openzeppelin/Arrays.json +1 -0
- package/contracts/openzeppelin/Arrays.ts +83 -0
- package/contracts/openzeppelin/Base64.json +1 -0
- package/contracts/openzeppelin/Base64.ts +83 -0
- package/contracts/openzeppelin/BeaconProxy.json +71 -0
- package/contracts/openzeppelin/BeaconProxy.ts +163 -0
- package/contracts/openzeppelin/BitMaps.json +1 -0
- package/contracts/openzeppelin/BitMaps.ts +83 -0
- package/contracts/openzeppelin/Checkpoints.json +1 -0
- package/contracts/openzeppelin/Checkpoints.ts +83 -0
- package/contracts/openzeppelin/Clones.json +1 -0
- package/contracts/openzeppelin/Clones.ts +83 -0
- package/contracts/openzeppelin/ConditionalEscrow.json +156 -0
- package/contracts/openzeppelin/ConditionalEscrow.ts +236 -0
- package/contracts/openzeppelin/Context.json +1 -0
- package/contracts/openzeppelin/Context.ts +83 -0
- package/contracts/openzeppelin/Counters.json +1 -0
- package/contracts/openzeppelin/Counters.ts +83 -0
- package/contracts/openzeppelin/Create2.json +1 -0
- package/contracts/openzeppelin/Create2.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabled.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabled.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledAMB.json +13 -0
- package/contracts/openzeppelin/CrossChainEnabledAMB.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL1.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL1.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL2.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL2.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledOptimism.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledOptimism.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledPolygonChild.json +30 -0
- package/contracts/openzeppelin/CrossChainEnabledPolygonChild.ts +90 -0
- package/contracts/openzeppelin/DoubleEndedQueue.json +12 -0
- package/contracts/openzeppelin/DoubleEndedQueue.ts +83 -0
- package/contracts/openzeppelin/ECDSA.json +1 -0
- package/contracts/openzeppelin/ECDSA.ts +83 -0
- package/contracts/openzeppelin/EIP712.json +1 -0
- package/contracts/openzeppelin/EIP712.ts +83 -0
- package/contracts/openzeppelin/ERC1155.json +325 -0
- package/contracts/openzeppelin/ERC1155.ts +276 -0
- package/contracts/openzeppelin/ERC1155Burnable.json +360 -0
- package/contracts/openzeppelin/ERC1155Burnable.ts +298 -0
- package/contracts/openzeppelin/ERC1155Holder.json +99 -0
- package/contracts/openzeppelin/ERC1155Holder.ts +112 -0
- package/contracts/openzeppelin/ERC1155Pausable.json +353 -0
- package/contracts/openzeppelin/ERC1155Pausable.ts +345 -0
- package/contracts/openzeppelin/ERC1155PresetMinterPauser.json +734 -0
- package/contracts/openzeppelin/ERC1155PresetMinterPauser.ts +608 -0
- package/contracts/openzeppelin/ERC1155Receiver.json +99 -0
- package/contracts/openzeppelin/ERC1155Receiver.ts +112 -0
- package/contracts/openzeppelin/ERC1155Supply.json +352 -0
- package/contracts/openzeppelin/ERC1155Supply.ts +298 -0
- package/contracts/openzeppelin/ERC1155URIStorage.json +314 -0
- package/contracts/openzeppelin/ERC1155URIStorage.ts +276 -0
- package/contracts/openzeppelin/ERC165.json +21 -0
- package/contracts/openzeppelin/ERC165.ts +90 -0
- package/contracts/openzeppelin/ERC165Checker.json +1 -0
- package/contracts/openzeppelin/ERC165Checker.ts +83 -0
- package/contracts/openzeppelin/ERC165Storage.json +21 -0
- package/contracts/openzeppelin/ERC165Storage.ts +90 -0
- package/contracts/openzeppelin/ERC1820Implementer.json +26 -0
- package/contracts/openzeppelin/ERC1820Implementer.ts +90 -0
- package/contracts/openzeppelin/ERC1967Proxy.json +71 -0
- package/contracts/openzeppelin/ERC1967Proxy.ts +163 -0
- package/contracts/openzeppelin/ERC1967Upgrade.json +47 -0
- package/contracts/openzeppelin/ERC1967Upgrade.ts +163 -0
- package/contracts/openzeppelin/ERC20.json +288 -0
- package/contracts/openzeppelin/ERC20.ts +251 -0
- package/contracts/openzeppelin/ERC20Burnable.json +303 -0
- package/contracts/openzeppelin/ERC20Burnable.ts +273 -0
- package/contracts/openzeppelin/ERC20Capped.json +285 -0
- package/contracts/openzeppelin/ERC20Capped.ts +262 -0
- package/contracts/openzeppelin/ERC20FlashMint.json +349 -0
- package/contracts/openzeppelin/ERC20FlashMint.ts +284 -0
- package/contracts/openzeppelin/ERC20Pausable.json +311 -0
- package/contracts/openzeppelin/ERC20Pausable.ts +320 -0
- package/contracts/openzeppelin/ERC20Permit.json +347 -0
- package/contracts/openzeppelin/ERC20Permit.ts +284 -0
- package/contracts/openzeppelin/ERC20PresetFixedSupply.json +329 -0
- package/contracts/openzeppelin/ERC20PresetFixedSupply.ts +273 -0
- package/contracts/openzeppelin/ERC20PresetMinterPauser.json +663 -0
- package/contracts/openzeppelin/ERC20PresetMinterPauser.ts +583 -0
- package/contracts/openzeppelin/ERC20Snapshot.json +328 -0
- package/contracts/openzeppelin/ERC20Snapshot.ts +302 -0
- package/contracts/openzeppelin/ERC20Votes.json +584 -0
- package/contracts/openzeppelin/ERC20Votes.ts +430 -0
- package/contracts/openzeppelin/ERC20VotesComp.json +627 -0
- package/contracts/openzeppelin/ERC20VotesComp.ts +452 -0
- package/contracts/openzeppelin/ERC20Wrapper.json +333 -0
- package/contracts/openzeppelin/ERC20Wrapper.ts +284 -0
- package/contracts/openzeppelin/ERC2771Context.json +21 -0
- package/contracts/openzeppelin/ERC2771Context.ts +90 -0
- package/contracts/openzeppelin/ERC2981.json +50 -0
- package/contracts/openzeppelin/ERC2981.ts +101 -0
- package/contracts/openzeppelin/ERC4626.json +662 -0
- package/contracts/openzeppelin/ERC4626.ts +485 -0
- package/contracts/openzeppelin/ERC721.json +348 -0
- package/contracts/openzeppelin/ERC721.ts +295 -0
- package/contracts/openzeppelin/ERC721Burnable.json +345 -0
- package/contracts/openzeppelin/ERC721Burnable.ts +306 -0
- package/contracts/openzeppelin/ERC721Enumerable.json +388 -0
- package/contracts/openzeppelin/ERC721Enumerable.ts +328 -0
- package/contracts/openzeppelin/ERC721Holder.json +36 -0
- package/contracts/openzeppelin/ERC721Holder.ts +90 -0
- package/contracts/openzeppelin/ERC721Pausable.json +371 -0
- package/contracts/openzeppelin/ERC721Pausable.ts +364 -0
- package/contracts/openzeppelin/ERC721PresetMinterPauserAutoId.json +742 -0
- package/contracts/openzeppelin/ERC721PresetMinterPauserAutoId.ts +638 -0
- package/contracts/openzeppelin/ERC721Royalty.json +361 -0
- package/contracts/openzeppelin/ERC721Royalty.ts +306 -0
- package/contracts/openzeppelin/ERC721URIStorage.json +332 -0
- package/contracts/openzeppelin/ERC721URIStorage.ts +295 -0
- package/contracts/openzeppelin/ERC721Votes.json +546 -0
- package/contracts/openzeppelin/ERC721Votes.ts +441 -0
- package/contracts/openzeppelin/ERC777.json +578 -0
- package/contracts/openzeppelin/ERC777.ts +473 -0
- package/contracts/openzeppelin/ERC777PresetFixedSupply.json +588 -0
- package/contracts/openzeppelin/ERC777PresetFixedSupply.ts +473 -0
- package/contracts/openzeppelin/EnumerableMap.json +1 -0
- package/contracts/openzeppelin/EnumerableMap.ts +83 -0
- package/contracts/openzeppelin/EnumerableSet.json +1 -0
- package/contracts/openzeppelin/EnumerableSet.ts +83 -0
- package/contracts/openzeppelin/Escrow.json +137 -0
- package/contracts/openzeppelin/Escrow.ts +225 -0
- package/contracts/openzeppelin/Governor.json +866 -0
- package/contracts/openzeppelin/Governor.ts +525 -0
- package/contracts/openzeppelin/GovernorCompatibilityBravo.json +1181 -0
- package/contracts/openzeppelin/GovernorCompatibilityBravo.ts +654 -0
- package/contracts/openzeppelin/GovernorCountingSimple.json +895 -0
- package/contracts/openzeppelin/GovernorCountingSimple.ts +536 -0
- package/contracts/openzeppelin/GovernorPreventLateQuorum.json +930 -0
- package/contracts/openzeppelin/GovernorPreventLateQuorum.ts +605 -0
- package/contracts/openzeppelin/GovernorProposalThreshold.json +866 -0
- package/contracts/openzeppelin/GovernorProposalThreshold.ts +525 -0
- package/contracts/openzeppelin/GovernorSettings.json +962 -0
- package/contracts/openzeppelin/GovernorSettings.ts +645 -0
- package/contracts/openzeppelin/GovernorTimelockCompound.json +990 -0
- package/contracts/openzeppelin/GovernorTimelockCompound.ts +638 -0
- package/contracts/openzeppelin/GovernorTimelockControl.json +983 -0
- package/contracts/openzeppelin/GovernorTimelockControl.ts +627 -0
- package/contracts/openzeppelin/GovernorVotes.json +879 -0
- package/contracts/openzeppelin/GovernorVotes.ts +536 -0
- package/contracts/openzeppelin/GovernorVotesComp.json +879 -0
- package/contracts/openzeppelin/GovernorVotesComp.ts +536 -0
- package/contracts/openzeppelin/GovernorVotesQuorumFraction.json +937 -0
- package/contracts/openzeppelin/GovernorVotesQuorumFraction.ts +598 -0
- package/contracts/openzeppelin/IAMB.json +327 -0
- package/contracts/openzeppelin/IAMB.ts +331 -0
- package/contracts/openzeppelin/IAccessControl.json +174 -0
- package/contracts/openzeppelin/IAccessControl.ts +214 -0
- package/contracts/openzeppelin/IAccessControlEnumerable.json +217 -0
- package/contracts/openzeppelin/IAccessControlEnumerable.ts +236 -0
- package/contracts/openzeppelin/IArbSys.json +270 -0
- package/contracts/openzeppelin/IArbSys.ts +233 -0
- package/contracts/openzeppelin/IBeacon.json +15 -0
- package/contracts/openzeppelin/IBeacon.ts +90 -0
- package/contracts/openzeppelin/IBridge.json +296 -0
- package/contracts/openzeppelin/IBridge.ts +287 -0
- package/contracts/openzeppelin/ICompoundTimelock.json +415 -0
- package/contracts/openzeppelin/ICompoundTimelock.ts +389 -0
- package/contracts/openzeppelin/ICrossDomainMessenger.json +101 -0
- package/contracts/openzeppelin/ICrossDomainMessenger.ts +181 -0
- package/contracts/openzeppelin/IERC1155.json +295 -0
- package/contracts/openzeppelin/IERC1155.ts +265 -0
- package/contracts/openzeppelin/IERC1155MetadataURI.json +314 -0
- package/contracts/openzeppelin/IERC1155MetadataURI.ts +276 -0
- package/contracts/openzeppelin/IERC1155Receiver.json +99 -0
- package/contracts/openzeppelin/IERC1155Receiver.ts +112 -0
- package/contracts/openzeppelin/IERC1271.json +26 -0
- package/contracts/openzeppelin/IERC1271.ts +90 -0
- package/contracts/openzeppelin/IERC1363.json +373 -0
- package/contracts/openzeppelin/IERC1363.ts +252 -0
- package/contracts/openzeppelin/IERC1363Receiver.json +36 -0
- package/contracts/openzeppelin/IERC1363Receiver.ts +90 -0
- package/contracts/openzeppelin/IERC1363Spender.json +31 -0
- package/contracts/openzeppelin/IERC1363Spender.ts +90 -0
- package/contracts/openzeppelin/IERC165.json +21 -0
- package/contracts/openzeppelin/IERC165.ts +90 -0
- package/contracts/openzeppelin/IERC1820Implementer.json +26 -0
- package/contracts/openzeppelin/IERC1820Implementer.ts +90 -0
- package/contracts/openzeppelin/IERC1820Registry.json +215 -0
- package/contracts/openzeppelin/IERC1820Registry.ts +218 -0
- package/contracts/openzeppelin/IERC1822Proxiable.json +15 -0
- package/contracts/openzeppelin/IERC1822Proxiable.ts +90 -0
- package/contracts/openzeppelin/IERC20.json +185 -0
- package/contracts/openzeppelin/IERC20.ts +196 -0
- package/contracts/openzeppelin/IERC20Metadata.json +224 -0
- package/contracts/openzeppelin/IERC20Metadata.ts +229 -0
- package/contracts/openzeppelin/IERC20Permit.json +77 -0
- package/contracts/openzeppelin/IERC20Permit.ts +112 -0
- package/contracts/openzeppelin/IERC2612.json +77 -0
- package/contracts/openzeppelin/IERC2612.ts +112 -0
- package/contracts/openzeppelin/IERC2981.json +50 -0
- package/contracts/openzeppelin/IERC2981.ts +101 -0
- package/contracts/openzeppelin/IERC3156FlashBorrower.json +41 -0
- package/contracts/openzeppelin/IERC3156FlashBorrower.ts +90 -0
- package/contracts/openzeppelin/IERC3156FlashLender.json +79 -0
- package/contracts/openzeppelin/IERC3156FlashLender.ts +112 -0
- package/contracts/openzeppelin/IERC4626.json +614 -0
- package/contracts/openzeppelin/IERC4626.ts +463 -0
- package/contracts/openzeppelin/IERC721.json +287 -0
- package/contracts/openzeppelin/IERC721.ts +262 -0
- package/contracts/openzeppelin/IERC721Enumerable.json +343 -0
- package/contracts/openzeppelin/IERC721Enumerable.ts +295 -0
- package/contracts/openzeppelin/IERC721Metadata.json +332 -0
- package/contracts/openzeppelin/IERC721Metadata.ts +295 -0
- package/contracts/openzeppelin/IERC721Receiver.json +36 -0
- package/contracts/openzeppelin/IERC721Receiver.ts +90 -0
- package/contracts/openzeppelin/IERC777.json +393 -0
- package/contracts/openzeppelin/IERC777.ts +360 -0
- package/contracts/openzeppelin/IERC777Recipient.json +40 -0
- package/contracts/openzeppelin/IERC777Recipient.ts +90 -0
- package/contracts/openzeppelin/IERC777Sender.json +40 -0
- package/contracts/openzeppelin/IERC777Sender.ts +90 -0
- package/contracts/openzeppelin/IFxMessageProcessor.json +25 -0
- package/contracts/openzeppelin/IFxMessageProcessor.ts +90 -0
- package/contracts/openzeppelin/IGovernor.json +683 -0
- package/contracts/openzeppelin/IGovernor.ts +448 -0
- package/contracts/openzeppelin/IGovernorCompatibilityBravo.json +913 -0
- package/contracts/openzeppelin/IGovernorCompatibilityBravo.ts +522 -0
- package/contracts/openzeppelin/IGovernorTimelock.json +768 -0
- package/contracts/openzeppelin/IGovernorTimelock.ts +510 -0
- package/contracts/openzeppelin/IInbox.json +377 -0
- package/contracts/openzeppelin/IInbox.ts +273 -0
- package/contracts/openzeppelin/IMessageProvider.json +34 -0
- package/contracts/openzeppelin/IMessageProvider.ts +134 -0
- package/contracts/openzeppelin/IOutbox.json +179 -0
- package/contracts/openzeppelin/IOutbox.ts +218 -0
- package/contracts/openzeppelin/IVotes.json +184 -0
- package/contracts/openzeppelin/IVotes.ts +196 -0
- package/contracts/openzeppelin/Initializable.json +15 -0
- package/contracts/openzeppelin/Initializable.ts +105 -0
- package/contracts/openzeppelin/LibAMB.json +1 -0
- package/contracts/openzeppelin/LibAMB.ts +83 -0
- package/contracts/openzeppelin/LibArbitrumL1.json +1 -0
- package/contracts/openzeppelin/LibArbitrumL1.ts +83 -0
- package/contracts/openzeppelin/LibArbitrumL2.json +15 -0
- package/contracts/openzeppelin/LibArbitrumL2.ts +90 -0
- package/contracts/openzeppelin/LibOptimism.json +1 -0
- package/contracts/openzeppelin/LibOptimism.ts +83 -0
- package/contracts/openzeppelin/Math.json +1 -0
- package/contracts/openzeppelin/Math.ts +83 -0
- package/contracts/openzeppelin/MerkleProof.json +1 -0
- package/contracts/openzeppelin/MerkleProof.ts +83 -0
- package/contracts/openzeppelin/MinimalForwarder.json +143 -0
- package/contracts/openzeppelin/MinimalForwarder.ts +112 -0
- package/contracts/openzeppelin/Multicall.json +21 -0
- package/contracts/openzeppelin/Multicall.ts +90 -0
- package/contracts/openzeppelin/Ownable.json +54 -0
- package/contracts/openzeppelin/Ownable.ts +134 -0
- package/contracts/openzeppelin/Pausable.json +41 -0
- package/contracts/openzeppelin/Pausable.ts +141 -0
- package/contracts/openzeppelin/PaymentSplitter.json +304 -0
- package/contracts/openzeppelin/PaymentSplitter.ts +281 -0
- package/contracts/openzeppelin/Proxy.json +10 -0
- package/contracts/openzeppelin/Proxy.ts +83 -0
- package/contracts/openzeppelin/ProxyAdmin.json +151 -0
- package/contracts/openzeppelin/ProxyAdmin.ts +189 -0
- package/contracts/openzeppelin/PullPayment.json +34 -0
- package/contracts/openzeppelin/PullPayment.ts +101 -0
- package/contracts/openzeppelin/ReentrancyGuard.json +1 -0
- package/contracts/openzeppelin/ReentrancyGuard.ts +83 -0
- package/contracts/openzeppelin/RefundEscrow.json +226 -0
- package/contracts/openzeppelin/RefundEscrow.ts +349 -0
- package/contracts/openzeppelin/SafeCast.json +1 -0
- package/contracts/openzeppelin/SafeCast.ts +83 -0
- package/contracts/openzeppelin/SafeERC20.json +1 -0
- package/contracts/openzeppelin/SafeERC20.ts +83 -0
- package/contracts/openzeppelin/SafeMath.json +1 -0
- package/contracts/openzeppelin/SafeMath.ts +83 -0
- package/contracts/openzeppelin/SignatureChecker.json +1 -0
- package/contracts/openzeppelin/SignatureChecker.ts +83 -0
- package/contracts/openzeppelin/SignedMath.json +1 -0
- package/contracts/openzeppelin/SignedMath.ts +83 -0
- package/contracts/openzeppelin/SignedSafeMath.json +1 -0
- package/contracts/openzeppelin/SignedSafeMath.ts +83 -0
- package/contracts/openzeppelin/StorageSlot.json +1 -0
- package/contracts/openzeppelin/StorageSlot.ts +83 -0
- package/contracts/openzeppelin/Strings.json +1 -0
- package/contracts/openzeppelin/Strings.ts +83 -0
- package/contracts/openzeppelin/TimelockController.json +867 -0
- package/contracts/openzeppelin/TimelockController.ts +583 -0
- package/contracts/openzeppelin/Timers.json +1 -0
- package/contracts/openzeppelin/Timers.ts +83 -0
- package/contracts/openzeppelin/TokenTimelock.json +69 -0
- package/contracts/openzeppelin/TokenTimelock.ts +123 -0
- package/contracts/openzeppelin/TransparentUpgradeableProxy.json +146 -0
- package/contracts/openzeppelin/TransparentUpgradeableProxy.ts +214 -0
- package/contracts/openzeppelin/UUPSUpgradeable.json +91 -0
- package/contracts/openzeppelin/UUPSUpgradeable.ts +192 -0
- package/contracts/openzeppelin/UpgradeableBeacon.json +104 -0
- package/contracts/openzeppelin/UpgradeableBeacon.ts +185 -0
- package/contracts/openzeppelin/VestingWallet.json +193 -0
- package/contracts/openzeppelin/VestingWallet.ts +208 -0
- package/contracts/openzeppelin/Votes.json +216 -0
- package/contracts/openzeppelin/Votes.ts +218 -0
- package/data/evm/eventHashes.json +19314 -0
- package/data/evm/events.json +19314 -0
- package/data/evm/functionHashes.json +121138 -0
- package/data/evm/functions.json +121140 -0
- package/data/tokens/coingecko.json +137409 -0
- package/dist/contracts/gen/base/ERC20Base/ERC20Base.js +94 -0
- package/dist/contracts/gnosis/GnosisSafe.js +357 -0
- package/dist/src/BlockchainExplorer/BlockChainExplorerFactory.js +114 -20
- package/dist/src/BlockchainExplorer/BlockChainExplorerProvider.js +8 -0
- package/dist/src/BlockchainExplorer/Bscscan.js +1 -0
- package/dist/src/BlockchainExplorer/Etherscan.js +14 -4
- package/dist/src/BlockchainExplorer/Evmscan.js +9 -0
- package/dist/src/BlockchainExplorer/Polyscan.js +1 -0
- package/dist/src/ChainAccountProvider.js +89 -0
- package/dist/src/ChainAccountsService.js +20 -2
- package/dist/src/Config.js +76 -0
- package/dist/src/blocks/BlockDateResolver.js +9 -8
- package/dist/src/bridges/hop/HopBridge.js +5 -2
- package/dist/src/chains/PlatformFactory.js +2 -2
- package/dist/src/chains/arbitrum/ArbWeb3Client.js +5 -24
- package/dist/src/chains/arbitrum/TokensServiceArbitrum.js +18 -0
- package/dist/src/chains/boba/BobaWeb3Client.js +5 -33
- package/dist/src/chains/xdai/XDaiWeb3Client.js +6 -30
- package/dist/src/class/SubjectKind.js +9 -0
- package/dist/src/class/SubjectStream.js +104 -0
- package/dist/src/class/Subscription.js +13 -0
- package/dist/src/clients/BscWeb3Client.js +5 -24
- package/dist/src/clients/ClientEventsStream.js +62 -18
- package/dist/src/clients/ClientPool.js +115 -55
- package/dist/src/clients/EthWeb3Client.js +7 -22
- package/dist/src/clients/EvmWeb3Client.js +25 -0
- package/dist/src/clients/HardhatWeb3Client.js +19 -40
- package/dist/src/clients/PolyWeb3Client.js +5 -51
- package/dist/src/clients/Web3Client.js +355 -10
- package/dist/src/clients/Web3ClientFactory.js +15 -0
- package/dist/src/clients/debug/ClientDebugMethods.js +64 -0
- package/dist/src/clients/utils/ClientEndpoints.js +6 -0
- package/dist/src/clients/utils/TxFactory.js +7 -12
- package/dist/src/contracts/Contract.js +2 -1
- package/dist/src/contracts/ContractAbiProvider.js +58 -0
- package/dist/src/contracts/ContractBase.js +161 -26
- package/dist/src/contracts/ContractReader.js +78 -2
- package/dist/src/contracts/ContractStorageReaderBase.js +15 -0
- package/dist/src/contracts/ContractStream.js +21 -8
- package/dist/src/contracts/ContractWriter.js +47 -20
- package/dist/src/contracts/TxContract.js +6 -3
- package/dist/src/contracts/common/ERC20.js +1 -1
- package/dist/src/contracts/utils/AbiDeserializer.js +15 -5
- package/dist/src/contracts/utils/InputDataUtils.js +5 -2
- package/dist/src/env/BigIntSerializer.js +2 -1
- package/dist/src/evm/EVM.js +214 -0
- package/dist/src/evm/OpcodesWalker.js +137 -0
- package/dist/src/evm/Stack.js +57 -0
- package/dist/src/evm/interfaces/IJumps.js +2 -0
- package/dist/src/evm/interfaces/IMemory.js +2 -0
- package/dist/src/evm/interfaces/IOpcode.js +2 -0
- package/dist/src/evm/interfaces/IStorage.js +2 -0
- package/dist/src/evm/opcodes/add.js +50 -0
- package/dist/src/evm/opcodes/addmod.js +19 -0
- package/dist/src/evm/opcodes/address.js +17 -0
- package/dist/src/evm/opcodes/and.js +56 -0
- package/dist/src/evm/opcodes/balance.js +22 -0
- package/dist/src/evm/opcodes/blockhash.js +22 -0
- package/dist/src/evm/opcodes/byte.js +30 -0
- package/dist/src/evm/opcodes/call.js +48 -0
- package/dist/src/evm/opcodes/callcode.js +48 -0
- package/dist/src/evm/opcodes/calldatacopy.js +27 -0
- package/dist/src/evm/opcodes/calldataload.js +33 -0
- package/dist/src/evm/opcodes/calldatasize.js +16 -0
- package/dist/src/evm/opcodes/caller.js +17 -0
- package/dist/src/evm/opcodes/callvalue.js +16 -0
- package/dist/src/evm/opcodes/codecopy.js +31 -0
- package/dist/src/evm/opcodes/codesize.js +16 -0
- package/dist/src/evm/opcodes/coinbase.js +16 -0
- package/dist/src/evm/opcodes/create.js +35 -0
- package/dist/src/evm/opcodes/create2.js +34 -0
- package/dist/src/evm/opcodes/delegatecall.js +44 -0
- package/dist/src/evm/opcodes/difficulty.js +16 -0
- package/dist/src/evm/opcodes/div.js +33 -0
- package/dist/src/evm/opcodes/dup.js +6 -0
- package/dist/src/evm/opcodes/eq.js +69 -0
- package/dist/src/evm/opcodes/exp.js +30 -0
- package/dist/src/evm/opcodes/extcodecopy.js +35 -0
- package/dist/src/evm/opcodes/extcodehash.js +22 -0
- package/dist/src/evm/opcodes/extcodesize.js +22 -0
- package/dist/src/evm/opcodes/gas.js +16 -0
- package/dist/src/evm/opcodes/gaslimit.js +16 -0
- package/dist/src/evm/opcodes/gasprice.js +16 -0
- package/dist/src/evm/opcodes/gt.js +36 -0
- package/dist/src/evm/opcodes/invalid.js +18 -0
- package/dist/src/evm/opcodes/iszero.js +51 -0
- package/dist/src/evm/opcodes/jump.js +66 -0
- package/dist/src/evm/opcodes/jumpdest.js +5 -0
- package/dist/src/evm/opcodes/jumpi.js +298 -0
- package/dist/src/evm/opcodes/log.js +74 -0
- package/dist/src/evm/opcodes/lt.js +36 -0
- package/dist/src/evm/opcodes/mload.js +28 -0
- package/dist/src/evm/opcodes/mod.js +30 -0
- package/dist/src/evm/opcodes/msize.js +16 -0
- package/dist/src/evm/opcodes/mstore.js +30 -0
- package/dist/src/evm/opcodes/mul.js +34 -0
- package/dist/src/evm/opcodes/mulmod.js +19 -0
- package/dist/src/evm/opcodes/not.js +28 -0
- package/dist/src/evm/opcodes/number.js +16 -0
- package/dist/src/evm/opcodes/or.js +30 -0
- package/dist/src/evm/opcodes/origin.js +16 -0
- package/dist/src/evm/opcodes/pc.js +5 -0
- package/dist/src/evm/opcodes/pop.js +5 -0
- package/dist/src/evm/opcodes/push.js +6 -0
- package/dist/src/evm/opcodes/return.js +70 -0
- package/dist/src/evm/opcodes/returndatacopy.js +31 -0
- package/dist/src/evm/opcodes/returndatasize.js +16 -0
- package/dist/src/evm/opcodes/revert.js +57 -0
- package/dist/src/evm/opcodes/sar.js +30 -0
- package/dist/src/evm/opcodes/selfdestruct.js +23 -0
- package/dist/src/evm/opcodes/sha3.js +56 -0
- package/dist/src/evm/opcodes/shl.js +35 -0
- package/dist/src/evm/opcodes/shr.js +30 -0
- package/dist/src/evm/opcodes/signextend.js +19 -0
- package/dist/src/evm/opcodes/sload.js +140 -0
- package/dist/src/evm/opcodes/sstore.js +189 -0
- package/dist/src/evm/opcodes/staticcall.js +44 -0
- package/dist/src/evm/opcodes/stop.js +17 -0
- package/dist/src/evm/opcodes/sub.js +30 -0
- package/dist/src/evm/opcodes/swap.js +6 -0
- package/dist/src/evm/opcodes/timestamp.js +16 -0
- package/dist/src/evm/opcodes/xor.js +30 -0
- package/dist/src/evm/opcodes.js +192 -0
- package/dist/src/evm/tx.class.js +154 -0
- package/dist/src/evm/utils/BigNumber.js +14 -0
- package/dist/src/evm/utils/hex.js +44 -0
- package/dist/src/evm/utils/opcodes.js +217 -0
- package/dist/src/evm/utils/stringify.js +14 -0
- package/dist/src/evm/utils/stringifyEvents.js +38 -0
- package/dist/src/evm/utils/stringifyFunctions.js +70 -0
- package/dist/src/evm/utils/stringifyInstructions.js +44 -0
- package/dist/src/evm/utils/stringifyMappings.js +62 -0
- package/dist/src/evm/utils/stringifyStructs.js +16 -0
- package/dist/src/evm/utils/stringifyVariables.js +33 -0
- package/dist/src/gen/ContractStorageReaderTemplate.js +11 -0
- package/dist/src/gen/Generator.js +37 -16
- package/dist/src/gen/GeneratorFromAbi.js +225 -72
- package/dist/src/gen/GeneratorStorageReader.js +89 -0
- package/dist/src/gen/utils/$gen.js +14 -0
- package/dist/src/gen/utils/Str.js +47 -0
- package/dist/src/hardhat/HardhatProvider.js +177 -0
- package/dist/src/indexer/BlocksTxIndexer.js +19 -7
- package/dist/src/indexer/handlers/BlocksWalker.js +65 -54
- package/dist/src/loggers/LoggerService.js +8 -5
- package/dist/src/models/TAccount.js +2 -0
- package/dist/src/ns/NameService.js +3 -0
- package/dist/src/ns/utils/$ns.js +6 -3
- package/dist/src/safe/$gnosis.js +23 -0
- package/dist/src/safe/GnosisSafeFactory.js +27 -0
- package/dist/src/safe/GnosisSafeHandler.js +361 -0
- package/dist/src/safe/transport/FileServiceTransport.js +92 -0
- package/dist/src/safe/transport/GnosisServiceTransport.js +78 -0
- package/dist/src/safe/transport/ISafeServiceTransport.js +2 -0
- package/dist/src/safe/transport/InMemoryServiceTransport.js +56 -0
- package/dist/src/solidity/SlotsParser.js +594 -0
- package/dist/src/solidity/SlotsStorage.js +158 -0
- package/dist/src/solidity/storage/Accessor.js +126 -0
- package/dist/src/solidity/storage/SlotDynamicArray.js +17 -0
- package/dist/src/solidity/storage/SlotFixedArray.js +28 -0
- package/dist/src/solidity/storage/SlotsStorageHandler.js +10 -0
- package/dist/src/solidity/storage/SlotsStorageTransport.js +126 -0
- package/dist/src/solidity/storage/handlers/SlotDynamicArrayHandler.js +47 -0
- package/dist/src/solidity/storage/handlers/SlotFixedArrayHandler.js +50 -0
- package/dist/src/solidity/storage/handlers/SlotMappingHandler.js +42 -0
- package/dist/src/solidity/storage/handlers/SlotStringHandler.js +109 -0
- package/dist/src/solidity/storage/handlers/SlotStructHandler.js +45 -0
- package/dist/src/solidity/storage/handlers/SlotValueHandler.js +30 -0
- package/dist/src/solidity/utils/$str.js +38 -0
- package/dist/src/solidity/utils/$types.js +22 -0
- package/dist/src/structs/PackedRanges.js +8 -1
- package/dist/src/tokens/TokenDataProvider.js +251 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +3 -1
- package/dist/src/tokens/TokenExchanges/AmmV2ExchangeBase.js +4 -4
- package/dist/src/tokens/TokenExchanges/PancakeswapExchange.js +4 -7
- package/dist/src/tokens/TokenExchanges/SushiswapPolygonExchange.js +4 -5
- package/dist/src/tokens/TokenExchanges/UniswapExchange.js +4 -7
- package/dist/src/tokens/TokenOracles/AmmPriceV2Oracle.js +2 -4
- package/dist/src/tokens/TokenOracles/CoingeckoOracle.js +12 -0
- package/dist/src/tokens/TokenOracles/TokenPriceStore.js +1 -1
- package/dist/src/tokens/TokenProviders/TPChain.js +14 -7
- package/dist/src/tokens/TokenProviders/TPCoingecko.js +117 -0
- package/dist/src/tokens/TokenProviders/TPConfig.js +46 -0
- package/dist/src/tokens/TokenProviders/TPExplorer.js +35 -0
- package/dist/src/tokens/TokenService.js +5 -2
- package/dist/src/tokens/TokenTransferService.js +28 -18
- package/dist/src/tokens/TokensService.js +32 -177
- package/dist/src/tokens/TokensServiceFactory.js +13 -1
- package/dist/src/txs/TxDataBuilder.js +54 -22
- package/dist/src/txs/TxLogger.js +3 -3
- package/dist/src/txs/TxWriter.js +169 -37
- package/dist/src/txs/receipt/TxLogParser.js +11 -1
- package/dist/src/txs/receipt/TxLogsTransfer.js +14 -13
- package/dist/src/txs/receipt/TxTopicProvider.js +10 -6
- package/dist/src/txs/sig-transports/SigFileTransport.js +48 -0
- package/dist/src/utils/$abiParser.js +55 -20
- package/dist/src/utils/$abiType.js +184 -3
- package/dist/src/utils/$abiUtils.js +54 -5
- package/dist/src/utils/$account.js +30 -0
- package/dist/src/utils/$address.js +8 -0
- package/dist/src/utils/$bigint.js +52 -3
- package/dist/src/utils/$block.js +16 -0
- package/dist/src/utils/$bloom.js +42 -0
- package/dist/src/utils/$buffer.js +94 -0
- package/dist/src/utils/$cli.js +20 -0
- package/dist/src/utils/$color.js +171 -0
- package/dist/src/utils/$config.js +65 -5
- package/dist/src/utils/$const.js +4 -0
- package/dist/src/utils/$contract.js +20 -2
- package/dist/src/utils/$crypto.js +25 -0
- package/dist/src/utils/$csv.js +17 -27
- package/dist/src/utils/$date.js +129 -25
- package/dist/src/utils/$gas.js +15 -0
- package/dist/src/utils/$hex.js +77 -0
- package/dist/src/utils/$is.js +24 -21
- package/dist/src/utils/$logger.js +56 -3
- package/dist/src/utils/$machine.js +77 -0
- package/dist/src/utils/$number.js +24 -1
- package/dist/src/utils/$path.js +17 -0
- package/dist/src/utils/$promise.js +81 -0
- package/dist/src/utils/$require.js +15 -1
- package/dist/src/utils/$secret.js +29 -0
- package/dist/src/utils/$sign.js +96 -14
- package/dist/src/utils/$signRaw.js +48 -0
- package/dist/src/utils/$signSerializer.js +5 -4
- package/dist/src/utils/$txData.js +19 -0
- package/hardhat.config.js +21 -1
- package/package.json +28 -14
- package/readme.md +21 -4
- package/src/BlockchainExplorer/BlockChainExplorerFactory.ts +149 -39
- package/src/BlockchainExplorer/BlockChainExplorerProvider.ts +10 -0
- package/src/BlockchainExplorer/Bscscan.ts +1 -0
- package/src/BlockchainExplorer/Etherscan.ts +17 -5
- package/src/BlockchainExplorer/Evmscan.ts +8 -0
- package/src/BlockchainExplorer/IBlockChainExplorer.ts +3 -2
- package/src/BlockchainExplorer/Polyscan.ts +1 -0
- package/src/ChainAccountProvider.ts +84 -0
- package/src/ChainAccountsService.ts +21 -2
- package/src/Config.ts +85 -0
- package/src/blocks/BlockDateResolver.ts +10 -12
- package/src/bridges/hop/HopBridge.ts +9 -2
- package/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/models/IBridge.ts +1 -1
- package/src/chains/PlatformFactory.ts +3 -2
- package/src/chains/arbitrum/ArbWeb3Client.ts +7 -22
- package/src/chains/arbitrum/TokensServiceArbitrum.ts +19 -0
- package/src/chains/boba/BobaWeb3Client.ts +5 -33
- package/src/chains/xdai/XDaiWeb3Client.ts +6 -32
- package/src/class/SubjectKind.ts +5 -0
- package/src/class/SubjectStream.ts +111 -0
- package/src/class/Subscription.ts +7 -0
- package/src/clients/BscWeb3Client.ts +5 -22
- package/src/clients/ClientEventsStream.ts +86 -19
- package/src/clients/ClientPool.ts +145 -61
- package/src/clients/EthWeb3Client.ts +8 -21
- package/src/clients/EvmWeb3Client.ts +26 -0
- package/src/clients/HardhatWeb3Client.ts +17 -39
- package/src/clients/PolyWeb3Client.ts +5 -54
- package/src/clients/Web3Client.ts +430 -32
- package/src/clients/Web3ClientFactory.ts +17 -1
- package/src/clients/debug/ClientDebugMethods.ts +75 -0
- package/src/clients/interfaces/IWeb3Client.ts +33 -5
- package/src/clients/interfaces/IWeb3EndpointOptions.ts +6 -0
- package/src/clients/utils/ClientEndpoints.ts +6 -0
- package/src/clients/utils/TxFactory.ts +13 -13
- package/src/contracts/Contract.ts +3 -2
- package/src/contracts/ContractAbiProvider.ts +68 -0
- package/src/contracts/ContractBase.ts +205 -36
- package/src/contracts/ContractReader.ts +116 -3
- package/src/contracts/ContractStorageReaderBase.ts +26 -0
- package/src/contracts/ContractStream.ts +24 -6
- package/src/contracts/ContractWriter.ts +58 -28
- package/src/contracts/TxContract.ts +7 -4
- package/src/contracts/common/ERC20.ts +1 -1
- package/src/contracts/utils/AbiDeserializer.ts +16 -7
- package/src/contracts/utils/InputDataUtils.ts +8 -6
- package/src/env/BigIntSerializer.ts +3 -1
- package/src/evm/EVM.ts +246 -0
- package/src/evm/OpcodesWalker.ts +149 -0
- package/src/evm/Stack.ts +58 -0
- package/src/evm/interfaces/IJumps.ts +3 -0
- package/src/evm/interfaces/IMemory.ts +3 -0
- package/src/evm/interfaces/IOpcode.ts +11 -0
- package/src/evm/interfaces/IStorage.ts +3 -0
- package/src/evm/opcodes/add.ts +49 -0
- package/src/evm/opcodes/addmod.ts +19 -0
- package/src/evm/opcodes/address.ts +22 -0
- package/src/evm/opcodes/and.ts +58 -0
- package/src/evm/opcodes/balance.ts +25 -0
- package/src/evm/opcodes/blockhash.ts +25 -0
- package/src/evm/opcodes/byte.ts +34 -0
- package/src/evm/opcodes/call.ts +69 -0
- package/src/evm/opcodes/callcode.ts +69 -0
- package/src/evm/opcodes/calldatacopy.ts +36 -0
- package/src/evm/opcodes/calldataload.ts +40 -0
- package/src/evm/opcodes/calldatasize.ts +21 -0
- package/src/evm/opcodes/caller.ts +22 -0
- package/src/evm/opcodes/callvalue.ts +21 -0
- package/src/evm/opcodes/codecopy.ts +37 -0
- package/src/evm/opcodes/codesize.ts +21 -0
- package/src/evm/opcodes/coinbase.ts +21 -0
- package/src/evm/opcodes/create.ts +42 -0
- package/src/evm/opcodes/create2.ts +41 -0
- package/src/evm/opcodes/delegatecall.ts +63 -0
- package/src/evm/opcodes/difficulty.ts +21 -0
- package/src/evm/opcodes/div.ts +35 -0
- package/src/evm/opcodes/dup.ts +7 -0
- package/src/evm/opcodes/eq.ts +92 -0
- package/src/evm/opcodes/exp.ts +34 -0
- package/src/evm/opcodes/extcodecopy.ts +42 -0
- package/src/evm/opcodes/extcodehash.ts +25 -0
- package/src/evm/opcodes/extcodesize.ts +25 -0
- package/src/evm/opcodes/gas.ts +21 -0
- package/src/evm/opcodes/gaslimit.ts +21 -0
- package/src/evm/opcodes/gasprice.ts +21 -0
- package/src/evm/opcodes/gt.ts +39 -0
- package/src/evm/opcodes/invalid.ts +24 -0
- package/src/evm/opcodes/iszero.ts +48 -0
- package/src/evm/opcodes/jump.ts +66 -0
- package/src/evm/opcodes/jumpdest.ts +6 -0
- package/src/evm/opcodes/jumpi.ts +367 -0
- package/src/evm/opcodes/log.ts +89 -0
- package/src/evm/opcodes/lt.ts +39 -0
- package/src/evm/opcodes/mload.ts +30 -0
- package/src/evm/opcodes/mod.ts +33 -0
- package/src/evm/opcodes/msize.ts +21 -0
- package/src/evm/opcodes/mstore.ts +33 -0
- package/src/evm/opcodes/mul.ts +38 -0
- package/src/evm/opcodes/mulmod.ts +19 -0
- package/src/evm/opcodes/not.ts +30 -0
- package/src/evm/opcodes/number.ts +21 -0
- package/src/evm/opcodes/or.ts +33 -0
- package/src/evm/opcodes/origin.ts +21 -0
- package/src/evm/opcodes/pc.ts +7 -0
- package/src/evm/opcodes/pop.ts +6 -0
- package/src/evm/opcodes/push.ts +8 -0
- package/src/evm/opcodes/return.ts +78 -0
- package/src/evm/opcodes/returndatacopy.ts +37 -0
- package/src/evm/opcodes/returndatasize.ts +21 -0
- package/src/evm/opcodes/revert.ts +64 -0
- package/src/evm/opcodes/sar.ts +33 -0
- package/src/evm/opcodes/selfdestruct.ts +26 -0
- package/src/evm/opcodes/sha3.ts +63 -0
- package/src/evm/opcodes/shl.ts +42 -0
- package/src/evm/opcodes/shr.ts +33 -0
- package/src/evm/opcodes/signextend.ts +25 -0
- package/src/evm/opcodes/sload.ts +190 -0
- package/src/evm/opcodes/sstore.ts +259 -0
- package/src/evm/opcodes/staticcall.ts +63 -0
- package/src/evm/opcodes/stop.ts +22 -0
- package/src/evm/opcodes/sub.ts +33 -0
- package/src/evm/opcodes/swap.ts +7 -0
- package/src/evm/opcodes/timestamp.ts +21 -0
- package/src/evm/opcodes/xor.ts +33 -0
- package/src/evm/opcodes.ts +207 -0
- package/src/evm/tx.class.ts +137 -0
- package/src/evm/utils/BigNumber.ts +9 -0
- package/src/evm/utils/hex.ts +37 -0
- package/src/evm/utils/opcodes.ts +213 -0
- package/src/evm/utils/stringify.ts +12 -0
- package/src/evm/utils/stringifyEvents.ts +37 -0
- package/src/evm/utils/stringifyFunctions.ts +41 -0
- package/src/evm/utils/stringifyInstructions.ts +38 -0
- package/src/evm/utils/stringifyMappings.ts +65 -0
- package/src/evm/utils/stringifyStructs.ts +16 -0
- package/src/evm/utils/stringifyVariables.ts +32 -0
- package/src/gen/ContractStorageReaderTemplate.ts +18 -0
- package/src/gen/ContractTemplate.ts +41 -7
- package/src/gen/Generator.ts +50 -19
- package/src/gen/GeneratorFromAbi.ts +239 -67
- package/src/gen/GeneratorStorageReader.ts +113 -0
- package/src/gen/utils/$gen.ts +11 -0
- package/src/gen/utils/Str.ts +40 -0
- package/src/handlers/TokenHandler.ts +1 -1
- package/src/hardhat/HardhatProvider.ts +207 -0
- package/src/indexer/BlocksTxIndexer.ts +36 -10
- package/src/indexer/handlers/BlocksWalker.ts +81 -62
- package/src/indexer/handlers/TxQueueLoader.ts +7 -7
- package/src/json/JsonObjectStore.ts +1 -1
- package/src/loggers/LoggerService.ts +9 -5
- package/src/loggers/TxLoggerService.ts +1 -1
- package/src/models/IToken.ts +9 -0
- package/src/models/TAccount.ts +30 -0
- package/src/models/TBufferLike.ts +2 -2
- package/src/models/TPlatform.ts +1 -1
- package/src/ns/NameService.ts +3 -0
- package/src/ns/utils/$ns.ts +3 -4
- package/src/safe/$gnosis.ts +20 -0
- package/src/safe/GnosisSafeFactory.ts +40 -0
- package/src/safe/GnosisSafeHandler.ts +432 -0
- package/src/safe/transport/FileServiceTransport.ts +115 -0
- package/src/safe/transport/GnosisServiceTransport.ts +83 -0
- package/src/safe/transport/ISafeServiceTransport.ts +26 -0
- package/src/safe/transport/InMemoryServiceTransport.ts +79 -0
- package/src/solidity/SlotsParser.ts +650 -0
- package/src/solidity/SlotsStorage.ts +177 -0
- package/src/solidity/storage/Accessor.spec.ts +45 -0
- package/src/solidity/storage/Accessor.ts +136 -0
- package/src/solidity/storage/SlotDynamicArray.ts +46 -0
- package/src/solidity/storage/SlotFixedArray.ts +31 -0
- package/src/solidity/storage/SlotsStorageHandler.ts +17 -0
- package/src/solidity/storage/SlotsStorageTransport.ts +152 -0
- package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotFixedArrayHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotMappingHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotStringHandler.ts +130 -0
- package/src/solidity/storage/handlers/SlotStructHandler.ts +46 -0
- package/src/solidity/storage/handlers/SlotValueHandler.ts +36 -0
- package/src/solidity/utils/$str.ts +36 -0
- package/src/solidity/utils/$types.ts +16 -0
- package/src/structs/PackedRanges.ts +9 -3
- package/src/tokens/TokenDataProvider.ts +271 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +3 -1
- package/src/tokens/TokenExchanges/AmmV2ExchangeBase.ts +4 -3
- package/src/tokens/TokenExchanges/OneInchExchange.ts +1 -1
- package/src/tokens/TokenExchanges/PancakeswapExchange.ts +5 -10
- package/src/tokens/TokenExchanges/SushiswapPolygonExchange.ts +8 -5
- package/src/tokens/TokenExchanges/UniswapExchange.ts +6 -9
- package/src/tokens/TokenOracles/AmmPriceV2Oracle.ts +5 -5
- package/src/tokens/TokenOracles/CoingeckoOracle.ts +13 -0
- package/src/tokens/TokenOracles/TokenPriceStore.ts +1 -1
- package/src/tokens/TokenPriceService.ts +0 -1
- package/src/tokens/TokenProviders/ITokenProvider.ts +1 -1
- package/src/tokens/TokenProviders/TPChain.ts +20 -8
- package/src/tokens/TokenProviders/TPCoingecko.ts +121 -0
- package/src/tokens/TokenProviders/TPConfig.ts +53 -0
- package/src/tokens/TokenProviders/TPExplorer.ts +41 -0
- package/src/tokens/TokenService.ts +6 -3
- package/src/tokens/TokenSwapService.ts +1 -1
- package/src/tokens/TokenTransferService.ts +40 -24
- package/src/tokens/TokensService.ts +34 -179
- package/src/tokens/TokensServiceFactory.ts +13 -1
- package/src/tokens/defi/ISwapService.ts +1 -1
- package/src/tokens/defi/paraswap/Paraswap.ts +2 -1
- package/src/txs/ITxConfig.ts +1 -1
- package/src/txs/TxDataBuilder.ts +78 -34
- package/src/txs/TxLogger.ts +4 -4
- package/src/txs/TxWriter.ts +245 -48
- package/src/txs/conditional/GasWatcherTx.ts +0 -1
- package/src/txs/receipt/ITxLogItem.ts +8 -5
- package/src/txs/receipt/TxLogParser.ts +13 -2
- package/src/txs/receipt/TxLogsTransfer.ts +15 -15
- package/src/txs/receipt/TxTopicInMemoryProvider.ts +1 -1
- package/src/txs/receipt/TxTopicProvider.ts +7 -7
- package/src/txs/sig-transports/SigFileTransport.ts +52 -0
- package/src/utils/$abiParser.spec.ts +90 -0
- package/src/utils/$abiParser.ts +60 -25
- package/src/utils/$abiType.ts +195 -5
- package/src/utils/$abiUtils.ts +57 -6
- package/src/utils/$account.ts +30 -0
- package/src/utils/$address.ts +5 -0
- package/src/utils/$bigint.ts +56 -3
- package/src/utils/$block.ts +14 -1
- package/src/utils/$bloom.ts +43 -0
- package/src/utils/$buffer.ts +114 -0
- package/src/utils/$cli.ts +16 -0
- package/src/utils/$color.ts +211 -0
- package/src/utils/$config.ts +70 -7
- package/src/utils/$const.ts +1 -0
- package/src/utils/$contract.ts +21 -3
- package/src/utils/$crypto.ts +33 -0
- package/src/utils/$csv.ts +23 -7
- package/src/utils/$date.ts +194 -40
- package/src/utils/$gas.ts +17 -0
- package/src/utils/$hex.ts +72 -0
- package/src/utils/$is.ts +24 -22
- package/src/utils/$logger.ts +60 -2
- package/src/utils/$machine.ts +85 -0
- package/src/utils/$number.ts +24 -1
- package/src/utils/$path.ts +17 -1
- package/src/utils/$promise.ts +101 -0
- package/src/utils/$require.ts +15 -1
- package/src/utils/$secret.ts +27 -0
- package/src/utils/$sign.ts +115 -16
- package/src/utils/$signRaw.ts +50 -0
- package/src/utils/$signSerializer.ts +8 -6
- package/src/utils/$txData.ts +16 -0
- package/src/utils/$wallet.ts +1 -1
- package/test/Batch.spec.ts +89 -0
- package/test/BlockChainExplorer.spec.ts +33 -0
- package/test/ChainAccount.spec.ts +1 -1
- package/test/client.spec.ts +10 -11
- package/test/config.js +8 -0
- package/test/config.spec.ts +31 -0
- package/test/ecrecover.spec.ts +49 -0
- package/test/fixtures/contracts/Counter.sol +25 -0
- package/test/fixtures/contracts/Ecrecover.sol +33 -0
- package/test/fixtures/contracts/Foo.sol +32 -0
- package/test/fixtures/contracts/Foo.ts +78 -0
- package/test/fixtures/contracts/FreeToken.sol +263 -0
- package/test/fixtures/explorer/0xfbD2aa7efA2B46Ce3c58D7ab0D92C176c71499C0.html +2788 -0
- package/test/fixtures/gnosis/GnosisSafe.sol +422 -0
- package/test/fixtures/gnosis/GnosisSafeL2.sol +86 -0
- package/test/fixtures/gnosis/accessors/SimulateTxAccessor.sol +52 -0
- package/test/fixtures/gnosis/base/Executor.sol +27 -0
- package/test/fixtures/gnosis/base/FallbackManager.sol +53 -0
- package/test/fixtures/gnosis/base/GuardManager.sol +62 -0
- package/test/fixtures/gnosis/base/ModuleManager.sol +133 -0
- package/test/fixtures/gnosis/base/OwnerManager.sol +149 -0
- package/test/fixtures/gnosis/common/Enum.sol +8 -0
- package/test/fixtures/gnosis/common/EtherPaymentFallback.sol +13 -0
- package/test/fixtures/gnosis/common/SecuredTokenTransfer.sol +35 -0
- package/test/fixtures/gnosis/common/SelfAuthorized.sol +16 -0
- package/test/fixtures/gnosis/common/SignatureDecoder.sol +36 -0
- package/test/fixtures/gnosis/common/Singleton.sol +11 -0
- package/test/fixtures/gnosis/common/StorageAccessible.sol +47 -0
- package/test/fixtures/gnosis/external/GnosisSafeMath.sol +54 -0
- package/test/fixtures/gnosis/interfaces/ERC1155TokenReceiver.sol +49 -0
- package/test/fixtures/gnosis/interfaces/ERC721TokenReceiver.sol +24 -0
- package/test/fixtures/gnosis/interfaces/ERC777TokensRecipient.sol +13 -0
- package/test/fixtures/gnosis/interfaces/IERC165.sol +15 -0
- package/test/fixtures/gnosis/interfaces/ISignatureValidator.sol +20 -0
- package/test/fixtures/gnosis/interfaces/ViewStorageAccessible.sol +11 -0
- package/test/fixtures/gnosis/libraries/CreateCall.sol +30 -0
- package/test/fixtures/gnosis/libraries/GnosisSafeStorage.sol +21 -0
- package/test/fixtures/gnosis/libraries/MultiSend.sol +66 -0
- package/test/fixtures/gnosis/libraries/MultiSendCallOnly.sol +61 -0
- package/test/fixtures/gnosis/libraries/SignMessageLib.sol +34 -0
- package/test/fixtures/gnosis/proxies/GnosisSafeProxy.sol +44 -0
- package/test/fixtures/gnosis/proxies/GnosisSafeProxyFactory.sol +107 -0
- package/test/fixtures/gnosis/proxies/IProxyCreationCallback.sol +12 -0
- package/test/fixtures/scan/WETH.sol +1533 -0
- package/test/fixtures/slots/FooStorage.sol +8 -0
- package/test/fixtures/slots/FooStorageBase.sol +6 -0
- package/test/fixtures/slots/Vault.sol +85 -0
- package/test/generate/class.spec.ts +144 -6
- package/test/generate/evm.spec.ts +64 -0
- package/test/generate/openzeppelin.spec.ts +18 -0
- package/test/generate/slotreader.spec.ts +34 -0
- package/test/hardhat/TestNode.ts +37 -9
- package/test/hardhat/deploy.spec.ts +22 -0
- package/test/indexer/BlocksWalker.spec.ts +51 -0
- package/test/ns.spec.ts +4 -0
- package/test/receipt.spec.ts +1 -4
- package/test/safe/tx.act.ts +194 -0
- package/test/solidity/SlotsParser.spec.ts +186 -0
- package/test/solidity/SlotsReader.spec.ts +168 -0
- package/test/solidity/Storage.spec.ts +328 -0
- package/test/structs/PackedRanges.spec.ts +56 -0
- package/test/subscriptions.spec.ts +127 -0
- package/test/token.spec.ts +11 -0
- package/test/utils/abi-types.spec.ts +31 -0
- package/test/utils/abi-utils.spec.ts +23 -0
- package/test/utils/bigint.spec.ts +0 -1
- package/test/utils/date.spec.ts +3 -2
- package/test/utils/logbloom.spec.ts +17 -0
- package/test/utils/number.spec.ts +14 -3
- package/test/utils/sign.spec.ts +43 -7
- package/src/ChainAccounts.ts +0 -72
- package/src/structs/PackedRanges.spec.ts +0 -38
|
@@ -15,6 +15,7 @@ import { AmmVaultV2Contract } from './AmmBase/V2/AmmVaultV2Contract';
|
|
|
15
15
|
import { TokensServiceBsc } from '../TokensServiceBsc';
|
|
16
16
|
import { $is } from '@dequanto/utils/$is';
|
|
17
17
|
import { $address } from '@dequanto/utils/$address';
|
|
18
|
+
import { $require } from '@dequanto/utils/$require';
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
interface ILPPair extends IToken {
|
|
@@ -82,7 +83,7 @@ export abstract class AmmV2ExchangeBase {
|
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
async calcSwap (from: IToken, to: IToken, fromAmount: bigint): Promise<{ amount: bigint, priceImpact: number }> {
|
|
85
|
-
$
|
|
86
|
+
$require.BigInt(fromAmount);
|
|
86
87
|
|
|
87
88
|
if (fromAmount === 0n) {
|
|
88
89
|
return {
|
|
@@ -102,8 +103,8 @@ export abstract class AmmV2ExchangeBase {
|
|
|
102
103
|
return null;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
$
|
|
106
|
-
$
|
|
106
|
+
$require.BigInt(lpReserves?._reserve0, `Reserve 0 not valid for LPAddress ${lpAddress}`);
|
|
107
|
+
$require.BigInt(lpReserves?._reserve1, `Reserve 1 not valid for LPAddress ${lpAddress}`);
|
|
107
108
|
|
|
108
109
|
let [ fromI, toI] = BigInt(from.address) < BigInt(to.address) ? [0, 1] : [1, 0];
|
|
109
110
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import di from 'a-di';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { BlockChainExplorerProvider } from '@dequanto/BlockchainExplorer/BlockChainExplorerProvider';
|
|
4
|
-
import { ChainAccount } from
|
|
4
|
+
import { ChainAccount } from "@dequanto/models/TAccount";
|
|
5
5
|
import { Web3ClientFactory } from '@dequanto/clients/Web3ClientFactory';
|
|
6
6
|
import { ERC20 } from '@dequanto/contracts/common/ERC20';
|
|
7
7
|
import { IToken } from '@dequanto/models/IToken';
|
|
@@ -7,19 +7,14 @@ import { IBlockChainExplorer } from '@dequanto/BlockchainExplorer/IBlockChainExp
|
|
|
7
7
|
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
8
8
|
import { $require } from '@dequanto/utils/$require';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const config = $config.get('pancackeswap');
|
|
12
|
-
|
|
13
|
-
const factory = $require.Address(config.factory, 'Factory Address');
|
|
14
|
-
const masterChef = $require.Address(config.masterChef, 'MasterChef Address');
|
|
15
|
-
const vault = $require.Address(config.vault, 'Vault Address');
|
|
16
|
-
|
|
17
10
|
export class PancakeswapExchange extends AmmV2ExchangeBase {
|
|
18
11
|
|
|
19
12
|
name = 'pancake'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
config = $config.get('pancackeswap');
|
|
14
|
+
factoryAddress = $require.Address(this.config.factory, 'Factory Address')
|
|
15
|
+
masterChefAddress = $require.Address(this.config.masterChef, 'MasterChef Address');
|
|
16
|
+
vaultAddress = $require.Address(this.config.vault, 'Vault Address')
|
|
17
|
+
|
|
23
18
|
|
|
24
19
|
constructor(
|
|
25
20
|
public client: Web3Client = di.resolve(BscWeb3Client),
|
|
@@ -8,19 +8,22 @@ import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
|
8
8
|
import { $require } from '@dequanto/utils/$require';
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const config = $config.get('pancackeswap');
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
const masterChef = $require.Address(config.masterChef, 'MasterChef Address');
|
|
15
|
-
const vault = $require.Address(config.vault, 'Vault Address');
|
|
12
|
+
|
|
16
13
|
|
|
17
14
|
export class SushiswapPolygonExchange extends AmmV2ExchangeBase {
|
|
18
15
|
|
|
19
16
|
name = 'sushiswap'
|
|
17
|
+
config = $config.get('sushiswap');
|
|
18
|
+
|
|
20
19
|
factoryAddress = '0xc35dadb65012ec5796536bd9864ed8773abc74c4'
|
|
21
|
-
masterChefAddress = masterChef
|
|
20
|
+
masterChefAddress = $require.Address(this.config?.masterChef ?? '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F', 'MasterChef Address');
|
|
22
21
|
vaultAddress = '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506'
|
|
23
22
|
|
|
23
|
+
// private factory = $require.Address(this.config.factory, 'Factory Address');
|
|
24
|
+
// private vault = $require.Address(this.config.vault, 'Vault Address');
|
|
25
|
+
|
|
26
|
+
|
|
24
27
|
constructor(
|
|
25
28
|
public client: Web3Client = di.resolve(BscWeb3Client),
|
|
26
29
|
public explorer: IBlockChainExplorer = di.resolve(Bscscan)
|
|
@@ -9,18 +9,15 @@ import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
|
9
9
|
import { $require } from '@dequanto/utils/$require';
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const config = $config.get('uniswapV2');
|
|
13
|
-
|
|
14
|
-
const factory = $require.Address(config.factory, 'Factory Address');
|
|
15
|
-
const vault = $require.Address(config.vault, 'Vault Address');
|
|
16
|
-
const masterChef = config.masterChef;
|
|
17
|
-
|
|
18
12
|
export class UniswapExchange extends AmmV2ExchangeBase {
|
|
19
13
|
|
|
20
14
|
name = 'uniswap'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
|
|
16
|
+
config = $config.get('uniswapV2')
|
|
17
|
+
|
|
18
|
+
factoryAddress = $require.Address(this.config.factory, 'Factory Address')
|
|
19
|
+
masterChefAddress = $require.Address(this.config.vault, 'Vault Address')
|
|
20
|
+
vaultAddress = this.config.masterChef
|
|
24
21
|
|
|
25
22
|
constructor(
|
|
26
23
|
public client: Web3Client = di.resolve(EthWeb3Client),
|
|
@@ -16,7 +16,7 @@ import { TokenPriceStore } from './TokenPriceStore';
|
|
|
16
16
|
import { $bigint } from '@dequanto/utils/$bigint';
|
|
17
17
|
import { AmmPairV2Service, ISwapPool, ISwapPoolInfo } from '../TokenExchanges/AmmBase/V2/AmmPairV2Service';
|
|
18
18
|
import { SushiswapPolygonExchange } from '../TokenExchanges/SushiswapPolygonExchange';
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
interface ISwapOptions {
|
|
@@ -36,7 +36,7 @@ export class AmmPriceV2Oracle {
|
|
|
36
36
|
exchange: AmmV2ExchangeBase
|
|
37
37
|
tokensService = di.resolve(TokensService, this.client.platform, this.explorer)
|
|
38
38
|
pairService = di.resolve(AmmPairV2Service, this.client, this.explorer)
|
|
39
|
-
logger = di.resolve(LoggerService,
|
|
39
|
+
logger = di.resolve(LoggerService, 'AmmPriceV2Oracle');
|
|
40
40
|
|
|
41
41
|
constructor(public client: Web3Client, public explorer: IBlockChainExplorer) {
|
|
42
42
|
switch (client.platform) {
|
|
@@ -107,7 +107,6 @@ export class AmmPriceV2Oracle {
|
|
|
107
107
|
|
|
108
108
|
if (route == null || route.length === 0) {
|
|
109
109
|
let error = new Error(`Route not found for Token ${token.address}`);
|
|
110
|
-
this.logger.write(error.message);
|
|
111
110
|
return { error };
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -122,9 +121,10 @@ export class AmmPriceV2Oracle {
|
|
|
122
121
|
date: cacheableDate,
|
|
123
122
|
priceFrom: price
|
|
124
123
|
}
|
|
125
|
-
}
|
|
124
|
+
};
|
|
126
125
|
}
|
|
127
126
|
}
|
|
127
|
+
|
|
128
128
|
let poolPair = this.exchange.pairContract(lp.address);
|
|
129
129
|
let lpReserves = await poolPair
|
|
130
130
|
.forBlock(opts?.block ?? opts?.date)
|
|
@@ -368,7 +368,7 @@ namespace TokenPrice {
|
|
|
368
368
|
let toPrice = TokenUtils.calcPrice(amountActual, toToken, toUsd ?? fromUsd);
|
|
369
369
|
|
|
370
370
|
//console.log('FromPice', fromPrice, fromAmount, fromToken, fromUsd, toUsd);
|
|
371
|
-
|
|
371
|
+
//$logger.log(`Swap: ${fromToken.symbol}(${fromAmount})[${fromUsd}$] > ${toToken.symbol} (${amountActual})[${toUsd}$]; Price ${fromToken.symbol}: ${fromPrice}`);
|
|
372
372
|
|
|
373
373
|
|
|
374
374
|
if (lp.date) {
|
|
@@ -16,7 +16,7 @@ export class TokenPriceStore {
|
|
|
16
16
|
return stores[token] ?? (stores[token] = new TokenPriceStore(token));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
private prices =
|
|
19
|
+
private prices = [] as [number, number][]
|
|
20
20
|
private pricesIdx = {} as {
|
|
21
21
|
[day: string]: {
|
|
22
22
|
[hour: string]: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Web3Client } from '@dequanto/clients/Web3Client';
|
|
2
2
|
import { IToken } from '@dequanto/models/IToken';
|
|
3
3
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
4
4
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
5
5
|
import { ITokenProvider } from './ITokenProvider';
|
|
6
|
+
import { ContractReader } from '@dequanto/contracts/ContractReader';
|
|
6
7
|
|
|
7
8
|
export class TPChain implements ITokenProvider {
|
|
8
9
|
|
|
9
|
-
constructor (public platform: TPlatform, public
|
|
10
|
+
constructor (public platform: TPlatform, public client?: Web3Client) {
|
|
10
11
|
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -15,13 +16,24 @@ export class TPChain implements ITokenProvider {
|
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
let reader = new ContractReader(this.client)
|
|
18
20
|
try {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
let [
|
|
22
|
+
symbol,
|
|
23
|
+
name,
|
|
24
|
+
decimals,
|
|
25
|
+
] = await Promise.all([
|
|
26
|
+
reader.readAsync(address, 'function symbol() returns string'),
|
|
27
|
+
reader.readAsync(address, 'function name() returns string'),
|
|
28
|
+
reader.readAsync(address, 'function decimals() returns uint8'),
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
return <IToken> {
|
|
32
|
+
platform,
|
|
33
|
+
address,
|
|
34
|
+
symbol,
|
|
35
|
+
name,
|
|
36
|
+
decimals,
|
|
25
37
|
};
|
|
26
38
|
|
|
27
39
|
} catch (error) {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import axios, { type AxiosError } from 'axios';
|
|
2
|
+
import memd from 'memd';
|
|
3
|
+
import alot from 'alot';
|
|
4
|
+
import { File } from 'atma-io';
|
|
5
|
+
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
6
|
+
import { ITokenProvider } from './ITokenProvider';
|
|
7
|
+
import { $path } from '@dequanto/utils/$path';
|
|
8
|
+
import { JsonArrayStore } from '@dequanto/json/JsonArrayStore';
|
|
9
|
+
import { ITokenGlob } from '@dequanto/models/ITokenGlob';
|
|
10
|
+
import { ATokenProvider } from './ATokenProvider';
|
|
11
|
+
import { l } from '@dequanto/utils/$logger';
|
|
12
|
+
import { $promise } from '@dequanto/utils/$promise';
|
|
13
|
+
|
|
14
|
+
export class TPCoingecko extends ATokenProvider implements ITokenProvider {
|
|
15
|
+
|
|
16
|
+
store = new JsonArrayStore<ITokenGlob> ({
|
|
17
|
+
path: $path.resolve('/data/tokens/coingecko.json'),
|
|
18
|
+
key: x => x.symbol,
|
|
19
|
+
format: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
getTokens(): Promise<ITokenGlob[]> {
|
|
24
|
+
return this.store.getAll();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async redownloadTokens(): Promise<ITokenGlob[]> {
|
|
28
|
+
let list = await this.downloadList();
|
|
29
|
+
l`Got list of ${list.length} tokens from CoinGecko. Fetching details...`;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
let tokens = await alot(list)
|
|
33
|
+
.mapAsync(async (token, i) => {
|
|
34
|
+
|
|
35
|
+
if (i > 0 && i % 10 === 0) {
|
|
36
|
+
l`Fetched ${i}/${list.length} token details`;
|
|
37
|
+
}
|
|
38
|
+
let info = await this.downloadTokenInfoOrCache(token.id);
|
|
39
|
+
return <ITokenGlob>{
|
|
40
|
+
name: token.name,
|
|
41
|
+
symbol: token.symbol,
|
|
42
|
+
platforms: alot
|
|
43
|
+
.fromObject(info?.detail_platforms ?? {})
|
|
44
|
+
.map(entry => {
|
|
45
|
+
let platform = this.mapPlatform(entry.key);
|
|
46
|
+
return {
|
|
47
|
+
platform,
|
|
48
|
+
decimals: entry.value.decimal_place,
|
|
49
|
+
address: entry.value.contract_address,
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
.filter(x => Boolean(x.platform) && Boolean(x.address) && Boolean(x.decimals))
|
|
53
|
+
.toArray()
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
.filterAsync(x => x.platforms.length > 0)
|
|
57
|
+
.toArrayAsync();
|
|
58
|
+
|
|
59
|
+
await this.store.saveAll(tokens);
|
|
60
|
+
return tokens;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
private async downloadList () {
|
|
65
|
+
let resp = await axios.get<{id, symbol, name}[]>(`https://api.coingecko.com/api/v3/coins/list`);
|
|
66
|
+
return resp.data;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private async downloadTokenInfoOrCache (id: string): Promise<TDetails> {
|
|
70
|
+
let cachePath = `./cache/coingecko/${id}.json`;
|
|
71
|
+
if (await File.existsAsync(cachePath)) {
|
|
72
|
+
let json = await File.readAsync<{info: TDetails, timestamp}>(cachePath);
|
|
73
|
+
return json.info;
|
|
74
|
+
}
|
|
75
|
+
let info = await this._downloadTokenInfo(id);
|
|
76
|
+
await File.writeAsync(cachePath, { info, id, timestamp: Date.now() });
|
|
77
|
+
return info;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 50 per minute
|
|
81
|
+
@memd.deco.throttle(60 * 1000 / 50)
|
|
82
|
+
private async _downloadTokenInfo (id: string) {
|
|
83
|
+
|
|
84
|
+
let wait = 10_000;
|
|
85
|
+
async function fetch () {
|
|
86
|
+
try {
|
|
87
|
+
let resp = await axios.get<TDetails>(`https://api.coingecko.com/api/v3/coins/${id}`);
|
|
88
|
+
return resp.data
|
|
89
|
+
} catch (error) {
|
|
90
|
+
let e = error as AxiosError;
|
|
91
|
+
if (e.response?.status === 404) {
|
|
92
|
+
return <TDetails> { id, detail_platforms: {} };
|
|
93
|
+
}
|
|
94
|
+
if (e.response?.status === 429) {
|
|
95
|
+
l`Throttled. Wait for ${wait}ms`;
|
|
96
|
+
await $promise.wait(wait);
|
|
97
|
+
wait *= 1.2;
|
|
98
|
+
return fetch();
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return fetch();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private mapPlatform (platformName: string): TPlatform {
|
|
107
|
+
return this.mapping[platformName] ?? platformName;
|
|
108
|
+
}
|
|
109
|
+
private mapping = {
|
|
110
|
+
'ethereum': 'eth',
|
|
111
|
+
'polygon-pos': 'poly',
|
|
112
|
+
'xdai': 'xdai',
|
|
113
|
+
'binance-smart-chain': 'bsc',
|
|
114
|
+
'arbitrum-one': 'arbitrum'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type TDetails = {
|
|
119
|
+
id, symbol, name,
|
|
120
|
+
detail_platforms: Record<string, { decimal_place, contract_address }>
|
|
121
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IToken } from '@dequanto/models/IToken';
|
|
2
|
+
import { ITokenGlob } from '@dequanto/models/ITokenGlob';
|
|
3
|
+
import { ITokenProvider } from './ITokenProvider';
|
|
4
|
+
import { ATokenProvider } from './ATokenProvider';
|
|
5
|
+
import { Config, config } from '@dequanto/Config';
|
|
6
|
+
import { $require } from '@dequanto/utils/$require';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class TPConfig extends ATokenProvider implements ITokenProvider {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async getTokens(): Promise<ITokenGlob[]> {
|
|
13
|
+
return config.tokens ?? [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async addToken (token: IToken) {
|
|
17
|
+
$require.Address(token.address);
|
|
18
|
+
$require.Number(token.decimals);
|
|
19
|
+
$require.notNull(token.platform, 'Not possible to add the token - platform is undefined');
|
|
20
|
+
|
|
21
|
+
let tokens = await this.getTokens();
|
|
22
|
+
let current = tokens.find(t => t.symbol === token.symbol);
|
|
23
|
+
if (current == null) {
|
|
24
|
+
current = <ITokenGlob> {
|
|
25
|
+
symbol: token.symbol,
|
|
26
|
+
platforms: []
|
|
27
|
+
};
|
|
28
|
+
tokens.push(current);
|
|
29
|
+
}
|
|
30
|
+
if (current.platforms == null) {
|
|
31
|
+
current.platforms = [];
|
|
32
|
+
}
|
|
33
|
+
let currentPlatform = current.platforms.find(x => x.platform == token.platform);
|
|
34
|
+
if (currentPlatform == null) {
|
|
35
|
+
current.platforms.push({
|
|
36
|
+
platform: token.platform,
|
|
37
|
+
decimals: token.decimals,
|
|
38
|
+
address: token.address,
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
currentPlatform.decimals = token.decimals;
|
|
42
|
+
currentPlatform.address = token.address;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await Config.extend({
|
|
46
|
+
tokens
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async redownloadTokens(): Promise<any> {
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IBlockChainExplorer } from '@dequanto/BlockchainExplorer/IBlockChainExplorer';
|
|
2
|
+
import { IToken } from '@dequanto/models/IToken';
|
|
3
|
+
import { TAddress } from '@dequanto/models/TAddress';
|
|
4
|
+
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
5
|
+
import { ITokenProvider } from './ITokenProvider';
|
|
6
|
+
|
|
7
|
+
export class TPExplorer implements ITokenProvider {
|
|
8
|
+
|
|
9
|
+
constructor (public platform: TPlatform, public explorer?: IBlockChainExplorer) {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getByAddress(platform: TPlatform, address: TAddress) {
|
|
14
|
+
if (this.platform !== platform) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
let source = await this.explorer?.getContractSource(address);
|
|
20
|
+
return <Partial<IToken>> {
|
|
21
|
+
address: address,
|
|
22
|
+
symbol: source
|
|
23
|
+
.ContractName
|
|
24
|
+
?.replace(/bep20/i, ''),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// just ignore if not resolved
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
getBySymbol(platform: TPlatform, symbol: string) {
|
|
33
|
+
// Does not support by name
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async redownloadTokens(): Promise<any> {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import di from 'a-di';
|
|
2
|
-
import { ChainAccount } from
|
|
2
|
+
import { ChainAccount } from "@dequanto/models/TAccount";
|
|
3
3
|
import { WXDaiTokenContract } from '@dequanto/chains/xdai/tokens/WXDaiTokenContract';
|
|
4
4
|
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
5
5
|
import { IToken } from '@dequanto/models/IToken';
|
|
@@ -18,13 +18,16 @@ export class TokenService {
|
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
async balanceOf(address: TAddress, token: string | IToken): Promise<bigint> {
|
|
21
|
+
async balanceOf(address: TAddress, token: string | IToken, params?: { forBlock?: number }): Promise<bigint> {
|
|
22
22
|
token = await this.getToken(token);
|
|
23
23
|
let isNative = this.tokensProvider.isNative(token.address);
|
|
24
24
|
if (isNative) {
|
|
25
|
-
return this.client.getBalance(address);
|
|
25
|
+
return this.client.getBalance(address, params?.forBlock);
|
|
26
26
|
}
|
|
27
27
|
let erc20 = await this.tokensProvider.erc20(token);
|
|
28
|
+
if (params?.forBlock != null) {
|
|
29
|
+
erc20 = erc20.forBlock(params.forBlock);
|
|
30
|
+
}
|
|
28
31
|
let balance = await erc20.balanceOf(address);
|
|
29
32
|
return balance;
|
|
30
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainAccount } from
|
|
1
|
+
import { ChainAccount } from "@dequanto/models/TAccount";
|
|
2
2
|
import { ChainAccountsService } from '@dequanto/ChainAccountsService';
|
|
3
3
|
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
4
4
|
import { TxLoggerService } from '@dequanto/loggers/TxLoggerService';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import di from 'a-di';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { ChainAccount, SafeAccount, TAccount } from "@dequanto/models/TAccount";
|
|
3
4
|
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
4
5
|
import { IToken } from '@dequanto/models/IToken';
|
|
5
6
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
6
7
|
import { TxDataBuilder } from '@dequanto/txs/TxDataBuilder';
|
|
7
|
-
import { TxWriter } from '@dequanto/txs/TxWriter';
|
|
8
|
+
import { ITxWriterOptions, TxWriter } from '@dequanto/txs/TxWriter';
|
|
8
9
|
import { $bigint } from '@dequanto/utils/$bigint';
|
|
9
10
|
import { $is } from '@dequanto/utils/$is';
|
|
10
11
|
import { TokensService } from './TokensService';
|
|
@@ -14,20 +15,27 @@ import { ITxConfig } from '@dequanto/txs/ITxConfig';
|
|
|
14
15
|
import { $promise } from '@dequanto/utils/$promise';
|
|
15
16
|
import { LoggerService } from '@dequanto/loggers/LoggerService';
|
|
16
17
|
import { $logger } from '@dequanto/utils/$logger';
|
|
18
|
+
import { $account } from '@dequanto/utils/$account';
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
export class TokenTransferService {
|
|
20
22
|
|
|
21
23
|
private gasPriorityFee?: number
|
|
22
|
-
private
|
|
24
|
+
private builderConfig: ITxConfig
|
|
25
|
+
private writerConfig: ITxWriterOptions
|
|
23
26
|
private tokenService = di.resolve(TokensService, this.client.platform)
|
|
24
27
|
|
|
25
28
|
constructor (public client: Web3Client, private logger = di.resolve(LoggerService)) {
|
|
26
29
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
$config (
|
|
30
|
-
this.
|
|
32
|
+
$config (builderConfig: ITxConfig): this {
|
|
33
|
+
this.builderConfig = builderConfig;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
$configWriter (writerConfig: ITxWriterOptions): this {
|
|
38
|
+
this.writerConfig = writerConfig;
|
|
31
39
|
return this;
|
|
32
40
|
}
|
|
33
41
|
|
|
@@ -48,8 +56,8 @@ export class TokenTransferService {
|
|
|
48
56
|
let ANYTOKEN = 'USDC';
|
|
49
57
|
let erc20 = await TokensService.erc20(ANYTOKEN, this.client.platform);
|
|
50
58
|
let transfers = erc20.extractLogsTransfer(receipt)
|
|
51
|
-
let transfer = transfers.find(x => $address.eq(x.to, receiver));
|
|
52
|
-
return transfer?.value ?? 0n;
|
|
59
|
+
let transfer = transfers.find(x => $address.eq(x.params.to, receiver));
|
|
60
|
+
return transfer?.params.value ?? 0n;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
/** Returns NULL for transaction, if no balance to transfer */
|
|
@@ -71,7 +79,7 @@ export class TokenTransferService {
|
|
|
71
79
|
}
|
|
72
80
|
return this.transferErc20All(from, to, token, { remainder });
|
|
73
81
|
}
|
|
74
|
-
async transfer (from:
|
|
82
|
+
async transfer (from: TAccount, to: TAddress, token: string | IToken, amount: number | bigint) : Promise<TxWriter> {
|
|
75
83
|
token = await this.getToken(token);
|
|
76
84
|
amount = this.getAmount(amount, token);
|
|
77
85
|
|
|
@@ -109,13 +117,13 @@ export class TokenTransferService {
|
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
let $gasPrice = $bigint.multWithFloat(gasPrice.price, GAS_RATIO);
|
|
112
|
-
|
|
120
|
+
$logger.log(`GasPrice ${ $bigint.toGweiFromWei($gasPrice) }gwei`);
|
|
113
121
|
|
|
114
122
|
let gasConsumed = BigInt(GAS) * $gasPrice;
|
|
115
123
|
let transferValue = balance - gasConsumed;
|
|
116
124
|
if (transferValue <= 0) {
|
|
117
125
|
if (--buildTxRetries > -1) {
|
|
118
|
-
$logger.log(`No balance to transfer
|
|
126
|
+
$logger.log(`No balance to transfer. Retry in 5s`);
|
|
119
127
|
await $promise.wait(5000);
|
|
120
128
|
return buildTx();
|
|
121
129
|
}
|
|
@@ -136,7 +144,7 @@ export class TokenTransferService {
|
|
|
136
144
|
txBuilder.data.gasLimit = GAS;
|
|
137
145
|
txBuilder.data.type = 1;
|
|
138
146
|
|
|
139
|
-
txBuilder.setConfig(this.
|
|
147
|
+
txBuilder.setConfig(this.builderConfig);
|
|
140
148
|
|
|
141
149
|
await Promise.all([
|
|
142
150
|
txBuilder.setNonce({ overriding: true }),
|
|
@@ -147,6 +155,7 @@ export class TokenTransferService {
|
|
|
147
155
|
}
|
|
148
156
|
let txBuilder = await buildTx();
|
|
149
157
|
return TxWriter.write(this.client, txBuilder, from, {
|
|
158
|
+
...(this.writerConfig ?? {}),
|
|
150
159
|
retries: 3,
|
|
151
160
|
async onErrorRebuild (tx, error, errCount) {
|
|
152
161
|
// In case we got `balance` value, but that one was outdated, then all our calculations where wrong.
|
|
@@ -161,19 +170,24 @@ export class TokenTransferService {
|
|
|
161
170
|
}
|
|
162
171
|
});
|
|
163
172
|
}
|
|
164
|
-
private async transferNative (from:
|
|
165
|
-
let
|
|
173
|
+
private async transferNative (from: TAccount, to: TAddress, amount: bigint): Promise<TxWriter> {
|
|
174
|
+
let sender = $account.getSender(from);
|
|
175
|
+
|
|
176
|
+
let txBuilder = new TxDataBuilder(this.client, sender, {
|
|
166
177
|
to: to,
|
|
167
178
|
value: $bigint.toHex(amount)
|
|
168
179
|
});
|
|
169
180
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
if (sender.address) {
|
|
182
|
+
await Promise.all([
|
|
183
|
+
txBuilder.setGas({ priceRatio: this.gasPriorityFee, gasEstimation: true, gasLimitRatio: 1, }),
|
|
184
|
+
txBuilder.setNonce(),
|
|
185
|
+
]);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
txBuilder.setConfig(this.builderConfig);
|
|
190
|
+
return TxWriter.write(this.client, txBuilder, from, this.writerConfig);
|
|
177
191
|
}
|
|
178
192
|
|
|
179
193
|
private async transferErc20All (from: ChainAccount, to: TAddress, token: IToken, opts?: { remainder?: number | bigint, retryCount?: number }): Promise<TxWriter> {
|
|
@@ -193,16 +207,18 @@ export class TokenTransferService {
|
|
|
193
207
|
retryCount: 0
|
|
194
208
|
});
|
|
195
209
|
}
|
|
196
|
-
|
|
210
|
+
if (this.builderConfig.gasFunding == null) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
197
213
|
}
|
|
198
214
|
return erc20
|
|
199
|
-
.$config(this.
|
|
215
|
+
.$config(this.builderConfig, this.writerConfig)
|
|
200
216
|
.transfer(from, to, balance);
|
|
201
217
|
}
|
|
202
|
-
private async transferErc20 (from:
|
|
218
|
+
private async transferErc20 (from: TAccount, to: TAddress, token: IToken, amount: bigint): Promise<TxWriter> {
|
|
203
219
|
let erc20 = await TokensService.erc20(token, this.client.platform);
|
|
204
220
|
return erc20
|
|
205
|
-
.$config(this.
|
|
221
|
+
.$config(this.builderConfig, this.writerConfig)
|
|
206
222
|
.transfer(from, to, amount);
|
|
207
223
|
}
|
|
208
224
|
private getAmount (amount: number | bigint, token: IToken): bigint
|