From 9c4551f013e0f7783cb5b728ab024c67c1a44ece Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 27 May 2024 19:29:04 +0300 Subject: [PATCH] Generate contract docs with forge doc --- docs/.gitignore | 1 + docs/book.css | 13 + docs/book.toml | 12 + docs/solidity.min.js | 74 +++ docs/src/README.md | 90 ++++ docs/src/SUMMARY.md | 72 +++ docs/src/contracts/README.md | 5 + .../ERC20Custody.sol/contract.ERC20Custody.md | 328 ++++++++++++ docs/src/contracts/evm/README.md | 12 + .../evm/Zeta.eth.sol/contract.ZetaEth.md | 17 + .../Zeta.non-eth.sol/contract.ZetaNonEth.md | 104 ++++ .../contract.ZetaConnectorBase.md | 235 +++++++++ .../contract.ZetaConnectorEth.md | 74 +++ .../contract.ZetaConnectorNonEth.md | 98 ++++ .../interface.ConnectorErrors.md | 43 ++ docs/src/contracts/evm/interfaces/README.md | 12 + .../ZetaErrors.sol/interface.ZetaErrors.md | 43 ++ .../interface.ZetaInteractorErrors.md | 31 ++ .../interface.ZetaCommonErrors.md | 11 + .../interface.ZetaConnector.md | 14 + .../interface.ZetaInterfaces.md | 49 ++ .../interface.ZetaReceiver.md | 24 + .../interface.ZetaTokenConsumer.md | 85 ++++ .../interface.ZetaNonEthInterface.md | 24 + .../contract.AttackerContract.md | 76 +++ .../AttackerContract.sol/interface.Victim.md | 19 + .../ERC20Mock.sol/contract.ERC20Mock.md | 17 + docs/src/contracts/evm/testing/README.md | 10 + .../interface.INonfungiblePositionManager.md | 288 +++++++++++ .../interface.IPoolInitializer.md | 34 ++ .../contract.ZetaInteractorMock.md | 32 ++ .../contract.ZetaReceiverMock.md | 35 ++ .../contract.ImmutableCreate2Factory.md | 177 +++++++ .../interface.Ownable.md | 12 + docs/src/contracts/evm/tools/README.md | 19 + .../abstract.ZetaInteractor.md | 87 ++++ .../contract.ZetaTokenConsumerPancakeV3.md | 143 ++++++ .../interface.ISwapRouterPancake.md | 76 +++ .../interface.WETH9.md | 12 + .../interface.ZetaTokenConsumerUniV3Errors.md | 23 + .../contract.ZetaTokenConsumerTrident.md | 129 +++++ .../interface.WETH9.md | 33 ++ ...nterface.ZetaTokenConsumerTridentErrors.md | 23 + .../contract.ZetaTokenConsumerUniV2.md | 94 ++++ .../interface.ZetaTokenConsumerUniV2Errors.md | 11 + .../contract.ZetaTokenConsumerUniV3.md | 143 ++++++ .../interface.WETH9.md | 12 + .../interface.ZetaTokenConsumerUniV3Errors.md | 23 + .../contracts/evm/tools/interfaces/README.md | 5 + ...erface.ConcentratedLiquidityPoolFactory.md | 15 + .../interface.IPoolRouter.md | 127 +++++ .../zevm/Interfaces.sol/enum.CoinType.md | 14 + .../zevm/Interfaces.sol/interface.ISystem.md | 49 ++ .../zevm/Interfaces.sol/interface.IZRC20.md | 111 +++++ .../interface.IZRC20Metadata.md | 29 ++ docs/src/contracts/zevm/README.md | 19 + .../contract.SystemContract.md | 277 +++++++++++ .../interface.SystemContractErrors.md | 37 ++ .../Uniswap.sol/contract.UniswapImports.md | 4 + .../contract.UniswapImports.md | 4 + .../zevm/WZETA.sol/contract.WETH9.md | 115 +++++ .../zevm/ZRC20.sol/contract.ZRC20.md | 470 ++++++++++++++++++ .../zevm/ZRC20.sol/interface.ZRC20Errors.md | 55 ++ .../contract.ZetaConnectorZEVM.md | 191 +++++++ .../interface.ZetaInterfaces.md | 49 ++ .../interface.ZetaReceiver.md | 24 + .../interface.IUniswapV2Router01.md | 228 +++++++++ .../interface.IUniswapV2Router02.md | 78 +++ .../interfaces/IWZETA.sol/interface.IWETH9.md | 86 ++++ .../interfaces/IZRC20.sol/interface.IZRC20.md | 139 ++++++ docs/src/contracts/zevm/interfaces/README.md | 9 + .../zContract.sol/interface.zContract.md | 12 + .../zContract.sol/struct.zContext.md | 12 + docs/src/contracts/zevm/testing/README.md | 5 + .../contract.SystemContractMock.md | 131 +++++ .../interface.SystemContractErrors.md | 29 ++ 76 files changed, 5323 insertions(+) create mode 100644 docs/.gitignore create mode 100644 docs/book.css create mode 100644 docs/book.toml create mode 100644 docs/solidity.min.js create mode 100644 docs/src/README.md create mode 100644 docs/src/SUMMARY.md create mode 100644 docs/src/contracts/README.md create mode 100644 docs/src/contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md create mode 100644 docs/src/contracts/evm/README.md create mode 100644 docs/src/contracts/evm/Zeta.eth.sol/contract.ZetaEth.md create mode 100644 docs/src/contracts/evm/Zeta.non-eth.sol/contract.ZetaNonEth.md create mode 100644 docs/src/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md create mode 100644 docs/src/contracts/evm/ZetaConnector.eth.sol/contract.ZetaConnectorEth.md create mode 100644 docs/src/contracts/evm/ZetaConnector.non-eth.sol/contract.ZetaConnectorNonEth.md create mode 100644 docs/src/contracts/evm/interfaces/ConnectorErrors.sol/interface.ConnectorErrors.md create mode 100644 docs/src/contracts/evm/interfaces/README.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaErrors.sol/interface.ZetaErrors.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaCommonErrors.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaConnector.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaInterfaces.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaReceiver.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md create mode 100644 docs/src/contracts/evm/interfaces/ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md create mode 100644 docs/src/contracts/evm/testing/AttackerContract.sol/contract.AttackerContract.md create mode 100644 docs/src/contracts/evm/testing/AttackerContract.sol/interface.Victim.md create mode 100644 docs/src/contracts/evm/testing/ERC20Mock.sol/contract.ERC20Mock.md create mode 100644 docs/src/contracts/evm/testing/README.md create mode 100644 docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.INonfungiblePositionManager.md create mode 100644 docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.IPoolInitializer.md create mode 100644 docs/src/contracts/evm/testing/ZetaInteractorMock.sol/contract.ZetaInteractorMock.md create mode 100644 docs/src/contracts/evm/testing/ZetaReceiverMock.sol/contract.ZetaReceiverMock.md create mode 100644 docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/contract.ImmutableCreate2Factory.md create mode 100644 docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/interface.Ownable.md create mode 100644 docs/src/contracts/evm/tools/README.md create mode 100644 docs/src/contracts/evm/tools/ZetaInteractor.sol/abstract.ZetaInteractor.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/contract.ZetaTokenConsumerPancakeV3.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ISwapRouterPancake.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.WETH9.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/contract.ZetaTokenConsumerTrident.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.WETH9.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/contract.ZetaTokenConsumerUniV2.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/contract.ZetaTokenConsumerUniV3.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.WETH9.md create mode 100644 docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md create mode 100644 docs/src/contracts/evm/tools/interfaces/README.md create mode 100644 docs/src/contracts/evm/tools/interfaces/TridentConcentratedLiquidityPoolFactory.sol/interface.ConcentratedLiquidityPoolFactory.md create mode 100644 docs/src/contracts/evm/tools/interfaces/TridentIPoolRouter.sol/interface.IPoolRouter.md create mode 100644 docs/src/contracts/zevm/Interfaces.sol/enum.CoinType.md create mode 100644 docs/src/contracts/zevm/Interfaces.sol/interface.ISystem.md create mode 100644 docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md create mode 100644 docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20Metadata.md create mode 100644 docs/src/contracts/zevm/README.md create mode 100644 docs/src/contracts/zevm/SystemContract.sol/contract.SystemContract.md create mode 100644 docs/src/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md create mode 100644 docs/src/contracts/zevm/Uniswap.sol/contract.UniswapImports.md create mode 100644 docs/src/contracts/zevm/UniswapPeriphery.sol/contract.UniswapImports.md create mode 100644 docs/src/contracts/zevm/WZETA.sol/contract.WETH9.md create mode 100644 docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md create mode 100644 docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md create mode 100644 docs/src/contracts/zevm/ZetaConnectorZEVM.sol/contract.ZetaConnectorZEVM.md create mode 100644 docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaInterfaces.md create mode 100644 docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md create mode 100644 docs/src/contracts/zevm/interfaces/IUniswapV2Router01.sol/interface.IUniswapV2Router01.md create mode 100644 docs/src/contracts/zevm/interfaces/IUniswapV2Router02.sol/interface.IUniswapV2Router02.md create mode 100644 docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md create mode 100644 docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md create mode 100644 docs/src/contracts/zevm/interfaces/README.md create mode 100644 docs/src/contracts/zevm/interfaces/zContract.sol/interface.zContract.md create mode 100644 docs/src/contracts/zevm/interfaces/zContract.sol/struct.zContext.md create mode 100644 docs/src/contracts/zevm/testing/README.md create mode 100644 docs/src/contracts/zevm/testing/SystemContractMock.sol/contract.SystemContractMock.md create mode 100644 docs/src/contracts/zevm/testing/SystemContractMock.sol/interface.SystemContractErrors.md diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..4e42a1bc --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book/ \ No newline at end of file diff --git a/docs/book.css b/docs/book.css new file mode 100644 index 00000000..b5ce903f --- /dev/null +++ b/docs/book.css @@ -0,0 +1,13 @@ +table { + margin: 0 auto; + border-collapse: collapse; + width: 100%; +} + +table td:first-child { + width: 15%; +} + +table td:nth-child(2) { + width: 25%; +} \ No newline at end of file diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 00000000..9fe0d553 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,12 @@ +[book] +src = "src" +title = "" + +[output.html] +no-section-label = true +additional-js = ["solidity.min.js"] +additional-css = ["book.css"] +git-repository-url = "https://github.com/zeta-chain/protocol-contracts" + +[output.html.fold] +enable = true diff --git a/docs/solidity.min.js b/docs/solidity.min.js new file mode 100644 index 00000000..19249329 --- /dev/null +++ b/docs/solidity.min.js @@ -0,0 +1,74 @@ +hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0 +}catch(e){return!1}} +var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/ +;e()&&(a=a.source.replace(/\\b/g,"(?{ +var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{ +begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params", +begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n, +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={ +className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c, +contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{ +className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0, +contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}}, +solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i, +HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e} +;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o +;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1 +;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i +;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={ +keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly", +literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years", +built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4" +},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/ +},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/, +excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p, +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={ +begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{ +built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max" +},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/, +lexemes:C,keywords:p}),w={className:"built_in", +begin:(E()?"(? true/false. + + +```solidity +mapping(IERC20 => bool) public whitelisted; +``` + + +## Functions +### onlyTSS + +*Only TSS address allowed modifier.* + + +```solidity +modifier onlyTSS(); +``` + +### onlyTSSUpdater + +*Only TSS address updater allowed modifier.* + + +```solidity +modifier onlyTSSUpdater(); +``` + +### constructor + + +```solidity +constructor(address TSSAddress_, address TSSAddressUpdater_, uint256 zetaFee_, uint256 zetaMaxFee_, IERC20 zeta_); +``` + +### updateTSSAddress + +*Update the TSSAddress in case of Zeta blockchain validator nodes churn.* + + +```solidity +function updateTSSAddress(address TSSAddress_) external onlyTSSUpdater; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`TSSAddress_`|`address`|| + + +### updateZetaFee + +*Update zeta fee* + + +```solidity +function updateZetaFee(uint256 zetaFee_) external onlyTSS; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`zetaFee_`|`uint256`|| + + +### renounceTSSAddressUpdater + +*Change the ownership of TSSAddressUpdater to the Zeta blockchain TSS nodes. +Effectively, only Zeta blockchain validators collectively can update TSSAddress afterwards.* + + +```solidity +function renounceTSSAddressUpdater() external onlyTSSUpdater; +``` + +### pause + +*Pause custody operations.* + + +```solidity +function pause() external onlyTSS; +``` + +### unpause + +*Unpause custody operations.* + + +```solidity +function unpause() external onlyTSS; +``` + +### whitelist + +*Whitelist asset.* + + +```solidity +function whitelist(IERC20 asset) external onlyTSS; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`asset`|`IERC20`|| + + +### unwhitelist + +*Unwhitelist asset.* + + +```solidity +function unwhitelist(IERC20 asset) external onlyTSS; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`asset`|`IERC20`|| + + +### deposit + +*Deposit asset amount to recipient with message that encodes additional zetachain evm call or message.* + + +```solidity +function deposit(bytes calldata recipient, IERC20 asset, uint256 amount, bytes calldata message) + external + nonReentrant; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`recipient`|`bytes`|| +|`asset`|`IERC20`|| +|`amount`|`uint256`|| +|`message`|`bytes`|| + + +### withdraw + +*Withdraw asset amount to recipient by custody TSS owner.* + + +```solidity +function withdraw(address recipient, IERC20 asset, uint256 amount) external nonReentrant onlyTSS; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`recipient`|`address`|| +|`asset`|`IERC20`|| +|`amount`|`uint256`|| + + +## Events +### Paused + +```solidity +event Paused(address sender); +``` + +### Unpaused + +```solidity +event Unpaused(address sender); +``` + +### Whitelisted + +```solidity +event Whitelisted(IERC20 indexed asset); +``` + +### Unwhitelisted + +```solidity +event Unwhitelisted(IERC20 indexed asset); +``` + +### Deposited + +```solidity +event Deposited(bytes recipient, IERC20 indexed asset, uint256 amount, bytes message); +``` + +### Withdrawn + +```solidity +event Withdrawn(address indexed recipient, IERC20 indexed asset, uint256 amount); +``` + +### RenouncedTSSUpdater + +```solidity +event RenouncedTSSUpdater(address TSSAddressUpdater_); +``` + +### UpdatedTSSAddress + +```solidity +event UpdatedTSSAddress(address TSSAddress_); +``` + +### UpdatedZetaFee + +```solidity +event UpdatedZetaFee(uint256 zetaFee_); +``` + +## Errors +### NotWhitelisted + +```solidity +error NotWhitelisted(); +``` + +### NotPaused + +```solidity +error NotPaused(); +``` + +### InvalidSender + +```solidity +error InvalidSender(); +``` + +### InvalidTSSUpdater + +```solidity +error InvalidTSSUpdater(); +``` + +### ZeroAddress + +```solidity +error ZeroAddress(); +``` + +### IsPaused + +```solidity +error IsPaused(); +``` + +### ZetaMaxFeeExceeded + +```solidity +error ZetaMaxFeeExceeded(); +``` + +### ZeroFee + +```solidity +error ZeroFee(); +``` + diff --git a/docs/src/contracts/evm/README.md b/docs/src/contracts/evm/README.md new file mode 100644 index 00000000..f3503d0e --- /dev/null +++ b/docs/src/contracts/evm/README.md @@ -0,0 +1,12 @@ + + +# Contents +- [interfaces](/contracts/evm/interfaces) +- [testing](/contracts/evm/testing) +- [tools](/contracts/evm/tools) +- [ERC20Custody](ERC20Custody.sol/contract.ERC20Custody.md) +- [ZetaEth](Zeta.eth.sol/contract.ZetaEth.md) +- [ZetaNonEth](Zeta.non-eth.sol/contract.ZetaNonEth.md) +- [ZetaConnectorBase](ZetaConnector.base.sol/contract.ZetaConnectorBase.md) +- [ZetaConnectorEth](ZetaConnector.eth.sol/contract.ZetaConnectorEth.md) +- [ZetaConnectorNonEth](ZetaConnector.non-eth.sol/contract.ZetaConnectorNonEth.md) diff --git a/docs/src/contracts/evm/Zeta.eth.sol/contract.ZetaEth.md b/docs/src/contracts/evm/Zeta.eth.sol/contract.ZetaEth.md new file mode 100644 index 00000000..47d958a1 --- /dev/null +++ b/docs/src/contracts/evm/Zeta.eth.sol/contract.ZetaEth.md @@ -0,0 +1,17 @@ +# ZetaEth +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/Zeta.eth.sol) + +**Inherits:** +ERC20 + +*ZetaEth is an implementation of OpenZeppelin's ERC20* + + +## Functions +### constructor + + +```solidity +constructor(address creator, uint256 initialSupply); +``` + diff --git a/docs/src/contracts/evm/Zeta.non-eth.sol/contract.ZetaNonEth.md b/docs/src/contracts/evm/Zeta.non-eth.sol/contract.ZetaNonEth.md new file mode 100644 index 00000000..17d5018b --- /dev/null +++ b/docs/src/contracts/evm/Zeta.non-eth.sol/contract.ZetaNonEth.md @@ -0,0 +1,104 @@ +# ZetaNonEth +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/Zeta.non-eth.sol) + +**Inherits:** +[ZetaNonEthInterface](/contracts/evm/interfaces/ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md), ERC20Burnable, [ZetaErrors](/contracts/evm/interfaces/ZetaErrors.sol/interface.ZetaErrors.md) + + +## State Variables +### connectorAddress + +```solidity +address public connectorAddress; +``` + + +### tssAddress +*Collectively held by Zeta blockchain validators* + + +```solidity +address public tssAddress; +``` + + +### tssAddressUpdater +*Initially a multi-sig, eventually held by Zeta blockchain validators (via renounceTssAddressUpdater)* + + +```solidity +address public tssAddressUpdater; +``` + + +## Functions +### constructor + + +```solidity +constructor(address tssAddress_, address tssAddressUpdater_) ERC20("Zeta", "ZETA"); +``` + +### updateTssAndConnectorAddresses + + +```solidity +function updateTssAndConnectorAddresses(address tssAddress_, address connectorAddress_) external; +``` + +### renounceTssAddressUpdater + +*Sets tssAddressUpdater to be tssAddress* + + +```solidity +function renounceTssAddressUpdater() external; +``` + +### mint + + +```solidity +function mint(address mintee, uint256 value, bytes32 internalSendHash) external override; +``` + +### burnFrom + +*Only Connector can mint. Minting requires burning the equivalent amount on another chain* + + +```solidity +function burnFrom(address account, uint256 amount) public override(ZetaNonEthInterface, ERC20Burnable); +``` + +## Events +### Minted + +```solidity +event Minted(address indexed mintee, uint256 amount, bytes32 indexed internalSendHash); +``` + +### Burnt + +```solidity +event Burnt(address indexed burnee, uint256 amount); +``` + +### TSSAddressUpdated + +```solidity +event TSSAddressUpdated(address callerAddress, address newTssAddress); +``` + +### TSSAddressUpdaterUpdated + +```solidity +event TSSAddressUpdaterUpdated(address callerAddress, address newTssUpdaterAddress); +``` + +### ConnectorAddressUpdated + +```solidity +event ConnectorAddressUpdated(address callerAddress, address newConnectorAddress); +``` + diff --git a/docs/src/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md b/docs/src/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md new file mode 100644 index 00000000..b7b7454d --- /dev/null +++ b/docs/src/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md @@ -0,0 +1,235 @@ +# ZetaConnectorBase +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/ZetaConnector.base.sol) + +**Inherits:** +[ConnectorErrors](/contracts/evm/interfaces/ConnectorErrors.sol/interface.ConnectorErrors.md), Pausable + +*Main abstraction of ZetaConnector. +This contract manages interactions between TSS and different chains. +There's an instance of this contract on each chain supported by ZetaChain.* + + +## State Variables +### zetaToken + +```solidity +address public immutable zetaToken; +``` + + +### pauserAddress +*Multisig contract to pause incoming transactions. +The responsibility of pausing outgoing transactions is left to the protocol for more flexibility.* + + +```solidity +address public pauserAddress; +``` + + +### tssAddress +*Collectively held by ZetaChain validators.* + + +```solidity +address public tssAddress; +``` + + +### tssAddressUpdater +*This address will start pointing to a multisig contract, then it will become the TSS address itself.* + + +```solidity +address public tssAddressUpdater; +``` + + +## Functions +### constructor + +*Constructor requires initial addresses. +zetaToken address is the only immutable one, while others can be updated.* + + +```solidity +constructor(address zetaToken_, address tssAddress_, address tssAddressUpdater_, address pauserAddress_); +``` + +### onlyPauser + +*Modifier to restrict actions to pauser address.* + + +```solidity +modifier onlyPauser(); +``` + +### onlyTssAddress + +*Modifier to restrict actions to TSS address.* + + +```solidity +modifier onlyTssAddress(); +``` + +### onlyTssUpdater + +*Modifier to restrict actions to TSS updater address.* + + +```solidity +modifier onlyTssUpdater(); +``` + +### updatePauserAddress + +*Update the pauser address. The only address allowed to do that is the current pauser.* + + +```solidity +function updatePauserAddress(address pauserAddress_) external onlyPauser; +``` + +### updateTssAddress + +*Update the TSS address. The address can be updated by the TSS updater or the TSS address itself.* + + +```solidity +function updateTssAddress(address tssAddress_) external; +``` + +### renounceTssAddressUpdater + +*Changes the ownership of tssAddressUpdater to be the one held by the ZetaChain TSS Signer nodes.* + + +```solidity +function renounceTssAddressUpdater() external onlyTssUpdater; +``` + +### pause + +*Pause the input (send) transactions.* + + +```solidity +function pause() external onlyPauser; +``` + +### unpause + +*Unpause the contract to allow transactions again.* + + +```solidity +function unpause() external onlyPauser; +``` + +### send + +*Entrypoint to send data and value through ZetaChain.* + + +```solidity +function send(ZetaInterfaces.SendInput calldata input) external virtual; +``` + +### onReceive + +*Handler to receive data from other chain. +This method can be called only by TSS. Access validation is in implementation.* + + +```solidity +function onReceive( + bytes calldata zetaTxSenderAddress, + uint256 sourceChainId, + address destinationAddress, + uint256 zetaValue, + bytes calldata message, + bytes32 internalSendHash +) external virtual; +``` + +### onRevert + +*Handler to receive errors from other chain. +This method can be called only by TSS. Access validation is in implementation.* + + +```solidity +function onRevert( + address zetaTxSenderAddress, + uint256 sourceChainId, + bytes calldata destinationAddress, + uint256 destinationChainId, + uint256 remainingZetaValue, + bytes calldata message, + bytes32 internalSendHash +) external virtual; +``` + +## Events +### ZetaSent + +```solidity +event ZetaSent( + address sourceTxOriginAddress, + address indexed zetaTxSenderAddress, + uint256 indexed destinationChainId, + bytes destinationAddress, + uint256 zetaValueAndGas, + uint256 destinationGasLimit, + bytes message, + bytes zetaParams +); +``` + +### ZetaReceived + +```solidity +event ZetaReceived( + bytes zetaTxSenderAddress, + uint256 indexed sourceChainId, + address indexed destinationAddress, + uint256 zetaValue, + bytes message, + bytes32 indexed internalSendHash +); +``` + +### ZetaReverted + +```solidity +event ZetaReverted( + address zetaTxSenderAddress, + uint256 sourceChainId, + uint256 indexed destinationChainId, + bytes destinationAddress, + uint256 remainingZetaValue, + bytes message, + bytes32 indexed internalSendHash +); +``` + +### TSSAddressUpdated + +```solidity +event TSSAddressUpdated(address callerAddress, address newTssAddress); +``` + +### TSSAddressUpdaterUpdated + +```solidity +event TSSAddressUpdaterUpdated(address callerAddress, address newTssUpdaterAddress); +``` + +### PauserAddressUpdated + +```solidity +event PauserAddressUpdated(address callerAddress, address newTssAddress); +``` + diff --git a/docs/src/contracts/evm/ZetaConnector.eth.sol/contract.ZetaConnectorEth.md b/docs/src/contracts/evm/ZetaConnector.eth.sol/contract.ZetaConnectorEth.md new file mode 100644 index 00000000..0b8b1155 --- /dev/null +++ b/docs/src/contracts/evm/ZetaConnector.eth.sol/contract.ZetaConnectorEth.md @@ -0,0 +1,74 @@ +# ZetaConnectorEth +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/ZetaConnector.eth.sol) + +**Inherits:** +[ZetaConnectorBase](/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md) + +*ETH implementation of ZetaConnector. +This contract manages interactions between TSS and different chains. +This version is only for Ethereum network because in the other chains we mint and burn and in this one we lock and unlock.* + + +## Functions +### constructor + + +```solidity +constructor(address zetaToken_, address tssAddress_, address tssAddressUpdater_, address pauserAddress_) + ZetaConnectorBase(zetaToken_, tssAddress_, tssAddressUpdater_, pauserAddress_); +``` + +### getLockedAmount + + +```solidity +function getLockedAmount() external view returns (uint256); +``` + +### send + +*Entrypoint to send data through ZetaChain +This call locks the token on the contract and emits an event with all the data needed by the protocol.* + + +```solidity +function send(ZetaInterfaces.SendInput calldata input) external override whenNotPaused; +``` + +### onReceive + +*Handler to receive data from other chain. +This method can be called only by TSS. +Transfers the Zeta tokens to destination and calls onZetaMessage if it's needed.* + + +```solidity +function onReceive( + bytes calldata zetaTxSenderAddress, + uint256 sourceChainId, + address destinationAddress, + uint256 zetaValue, + bytes calldata message, + bytes32 internalSendHash +) external override onlyTssAddress; +``` + +### onRevert + +*Handler to receive errors from other chain. +This method can be called only by TSS. +Transfers the Zeta tokens to destination and calls onZetaRevert if it's needed.* + + +```solidity +function onRevert( + address zetaTxSenderAddress, + uint256 sourceChainId, + bytes calldata destinationAddress, + uint256 destinationChainId, + uint256 remainingZetaValue, + bytes calldata message, + bytes32 internalSendHash +) external override whenNotPaused onlyTssAddress; +``` + diff --git a/docs/src/contracts/evm/ZetaConnector.non-eth.sol/contract.ZetaConnectorNonEth.md b/docs/src/contracts/evm/ZetaConnector.non-eth.sol/contract.ZetaConnectorNonEth.md new file mode 100644 index 00000000..5b34034b --- /dev/null +++ b/docs/src/contracts/evm/ZetaConnector.non-eth.sol/contract.ZetaConnectorNonEth.md @@ -0,0 +1,98 @@ +# ZetaConnectorNonEth +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/ZetaConnector.non-eth.sol) + +**Inherits:** +[ZetaConnectorBase](/contracts/evm/ZetaConnector.base.sol/contract.ZetaConnectorBase.md) + +*Non ETH implementation of ZetaConnector. +This contract manages interactions between TSS and different chains. +This version is for every chain but Etherum network because in the other chains we mint and burn and in Etherum we lock and unlock* + + +## State Variables +### maxSupply + +```solidity +uint256 public maxSupply = 2 ** 256 - 1; +``` + + +## Functions +### constructor + + +```solidity +constructor(address zetaTokenAddress_, address tssAddress_, address tssAddressUpdater_, address pauserAddress_) + ZetaConnectorBase(zetaTokenAddress_, tssAddress_, tssAddressUpdater_, pauserAddress_); +``` + +### getLockedAmount + + +```solidity +function getLockedAmount() external view returns (uint256); +``` + +### setMaxSupply + + +```solidity +function setMaxSupply(uint256 maxSupply_) external onlyTssAddress; +``` + +### send + +*Entry point to send data to protocol +This call burn the token and emit an event with all the data needed by the protocol* + + +```solidity +function send(ZetaInterfaces.SendInput calldata input) external override whenNotPaused; +``` + +### onReceive + +*Handler to receive data from other chain. +This method can be called only by TSS. +Transfer the Zeta tokens to destination and calls onZetaMessage if it's needed. +To perform the transfer mint new tokens, validating first the maxSupply allowed in the current chain.* + + +```solidity +function onReceive( + bytes calldata zetaTxSenderAddress, + uint256 sourceChainId, + address destinationAddress, + uint256 zetaValue, + bytes calldata message, + bytes32 internalSendHash +) external override onlyTssAddress; +``` + +### onRevert + +*Handler to receive errors from other chain. +This method can be called only by TSS. +Transfer the Zeta tokens to destination and calls onZetaRevert if it's needed. +To perform the transfer mint new tokens, validating first the maxSupply allowed in the current chain.* + + +```solidity +function onRevert( + address zetaTxSenderAddress, + uint256 sourceChainId, + bytes calldata destinationAddress, + uint256 destinationChainId, + uint256 remainingZetaValue, + bytes calldata message, + bytes32 internalSendHash +) external override whenNotPaused onlyTssAddress; +``` + +## Events +### MaxSupplyUpdated + +```solidity +event MaxSupplyUpdated(address callerAddress, uint256 newMaxSupply); +``` + diff --git a/docs/src/contracts/evm/interfaces/ConnectorErrors.sol/interface.ConnectorErrors.md b/docs/src/contracts/evm/interfaces/ConnectorErrors.sol/interface.ConnectorErrors.md new file mode 100644 index 00000000..a3f6a8d9 --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ConnectorErrors.sol/interface.ConnectorErrors.md @@ -0,0 +1,43 @@ +# ConnectorErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ConnectorErrors.sol) + +*Interface with connector custom errors* + + +## Errors +### CallerIsNotPauser + +```solidity +error CallerIsNotPauser(address caller); +``` + +### CallerIsNotTss + +```solidity +error CallerIsNotTss(address caller); +``` + +### CallerIsNotTssUpdater + +```solidity +error CallerIsNotTssUpdater(address caller); +``` + +### CallerIsNotTssOrUpdater + +```solidity +error CallerIsNotTssOrUpdater(address caller); +``` + +### ZetaTransferError + +```solidity +error ZetaTransferError(); +``` + +### ExceedsMaxSupply + +```solidity +error ExceedsMaxSupply(uint256 maxSupply); +``` + diff --git a/docs/src/contracts/evm/interfaces/README.md b/docs/src/contracts/evm/interfaces/README.md new file mode 100644 index 00000000..825ccb3b --- /dev/null +++ b/docs/src/contracts/evm/interfaces/README.md @@ -0,0 +1,12 @@ + + +# Contents +- [ConnectorErrors](ConnectorErrors.sol/interface.ConnectorErrors.md) +- [ZetaErrors](ZetaErrors.sol/interface.ZetaErrors.md) +- [ZetaInteractorErrors](ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md) +- [ZetaInterfaces](ZetaInterfaces.sol/interface.ZetaInterfaces.md) +- [ZetaConnector](ZetaInterfaces.sol/interface.ZetaConnector.md) +- [ZetaReceiver](ZetaInterfaces.sol/interface.ZetaReceiver.md) +- [ZetaTokenConsumer](ZetaInterfaces.sol/interface.ZetaTokenConsumer.md) +- [ZetaCommonErrors](ZetaInterfaces.sol/interface.ZetaCommonErrors.md) +- [ZetaNonEthInterface](ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md) diff --git a/docs/src/contracts/evm/interfaces/ZetaErrors.sol/interface.ZetaErrors.md b/docs/src/contracts/evm/interfaces/ZetaErrors.sol/interface.ZetaErrors.md new file mode 100644 index 00000000..6855b0b7 --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaErrors.sol/interface.ZetaErrors.md @@ -0,0 +1,43 @@ +# ZetaErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaErrors.sol) + +*Common custom errors* + + +## Errors +### CallerIsNotTss + +```solidity +error CallerIsNotTss(address caller); +``` + +### CallerIsNotConnector + +```solidity +error CallerIsNotConnector(address caller); +``` + +### CallerIsNotTssUpdater + +```solidity +error CallerIsNotTssUpdater(address caller); +``` + +### CallerIsNotTssOrUpdater + +```solidity +error CallerIsNotTssOrUpdater(address caller); +``` + +### InvalidAddress + +```solidity +error InvalidAddress(); +``` + +### ZetaTransferError + +```solidity +error ZetaTransferError(); +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md b/docs/src/contracts/evm/interfaces/ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md new file mode 100644 index 00000000..10f39389 --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md @@ -0,0 +1,31 @@ +# ZetaInteractorErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInteractorErrors.sol) + +*Interface with Zeta Interactor errors* + + +## Errors +### InvalidDestinationChainId + +```solidity +error InvalidDestinationChainId(); +``` + +### InvalidCaller + +```solidity +error InvalidCaller(address caller); +``` + +### InvalidZetaMessageCall + +```solidity +error InvalidZetaMessageCall(); +``` + +### InvalidZetaRevertCall + +```solidity +error InvalidZetaRevertCall(); +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaCommonErrors.md b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaCommonErrors.md new file mode 100644 index 00000000..13b95cbe --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaCommonErrors.md @@ -0,0 +1,11 @@ +# ZetaCommonErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInterfaces.sol) + + +## Errors +### InvalidAddress + +```solidity +error InvalidAddress(); +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaConnector.md b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaConnector.md new file mode 100644 index 00000000..3565c19e --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaConnector.md @@ -0,0 +1,14 @@ +# ZetaConnector +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInterfaces.sol) + + +## Functions +### send + +*Sending value and data cross-chain is as easy as calling connector.send(SendInput)* + + +```solidity +function send(ZetaInterfaces.SendInput calldata input) external; +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaInterfaces.md b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaInterfaces.md new file mode 100644 index 00000000..f035012e --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaInterfaces.md @@ -0,0 +1,49 @@ +# ZetaInterfaces +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInterfaces.sol) + + +## Structs +### SendInput +*Use SendInput to interact with the Connector: connector.send(SendInput)* + + +```solidity +struct SendInput { + uint256 destinationChainId; + bytes destinationAddress; + uint256 destinationGasLimit; + bytes message; + uint256 zetaValueAndGas; + bytes zetaParams; +} +``` + +### ZetaMessage +*Our Connector calls onZetaMessage with this struct as argument* + + +```solidity +struct ZetaMessage { + bytes zetaTxSenderAddress; + uint256 sourceChainId; + address destinationAddress; + uint256 zetaValue; + bytes message; +} +``` + +### ZetaRevert +*Our Connector calls onZetaRevert with this struct as argument* + + +```solidity +struct ZetaRevert { + address zetaTxSenderAddress; + uint256 sourceChainId; + bytes destinationAddress; + uint256 destinationChainId; + uint256 remainingZetaValue; + bytes message; +} +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaReceiver.md b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaReceiver.md new file mode 100644 index 00000000..11798eca --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaReceiver.md @@ -0,0 +1,24 @@ +# ZetaReceiver +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInterfaces.sol) + + +## Functions +### onZetaMessage + +*onZetaMessage is called when a cross-chain message reaches a contract* + + +```solidity +function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) external; +``` + +### onZetaRevert + +*onZetaRevert is called when a cross-chain message reverts. +It's useful to rollback to the original state* + + +```solidity +function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external; +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md new file mode 100644 index 00000000..6e62d594 --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md @@ -0,0 +1,85 @@ +# ZetaTokenConsumer +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaInterfaces.sol) + +*ZetaTokenConsumer makes it easier to handle the following situations: +- Getting Zeta using native coin (to pay for destination gas while using `connector.send`) +- Getting Zeta using a token (to pay for destination gas while using `connector.send`) +- Getting native coin using Zeta (to return unused destination gas when `onZetaRevert` is executed) +- Getting a token using Zeta (to return unused destination gas when `onZetaRevert` is executed)* + +*The interface can be implemented using different strategies, like UniswapV2, UniswapV3, etc* + + +## Functions +### getZetaFromEth + + +```solidity +function getZetaFromEth(address destinationAddress, uint256 minAmountOut) external payable returns (uint256); +``` + +### getZetaFromToken + + +```solidity +function getZetaFromToken( + address destinationAddress, + uint256 minAmountOut, + address inputToken, + uint256 inputTokenAmount +) external returns (uint256); +``` + +### getEthFromZeta + + +```solidity +function getEthFromZeta(address destinationAddress, uint256 minAmountOut, uint256 zetaTokenAmount) + external + returns (uint256); +``` + +### getTokenFromZeta + + +```solidity +function getTokenFromZeta( + address destinationAddress, + uint256 minAmountOut, + address outputToken, + uint256 zetaTokenAmount +) external returns (uint256); +``` + +### hasZetaLiquidity + + +```solidity +function hasZetaLiquidity() external view returns (bool); +``` + +## Events +### EthExchangedForZeta + +```solidity +event EthExchangedForZeta(uint256 amountIn, uint256 amountOut); +``` + +### TokenExchangedForZeta + +```solidity +event TokenExchangedForZeta(address token, uint256 amountIn, uint256 amountOut); +``` + +### ZetaExchangedForEth + +```solidity +event ZetaExchangedForEth(uint256 amountIn, uint256 amountOut); +``` + +### ZetaExchangedForToken + +```solidity +event ZetaExchangedForToken(address token, uint256 amountIn, uint256 amountOut); +``` + diff --git a/docs/src/contracts/evm/interfaces/ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md b/docs/src/contracts/evm/interfaces/ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md new file mode 100644 index 00000000..a7469d01 --- /dev/null +++ b/docs/src/contracts/evm/interfaces/ZetaNonEthInterface.sol/interface.ZetaNonEthInterface.md @@ -0,0 +1,24 @@ +# ZetaNonEthInterface +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/interfaces/ZetaNonEthInterface.sol) + +**Inherits:** +IERC20 + +*ZetaNonEthInterface is a mintable / burnable version of IERC20* + + +## Functions +### burnFrom + + +```solidity +function burnFrom(address account, uint256 amount) external; +``` + +### mint + + +```solidity +function mint(address mintee, uint256 value, bytes32 internalSendHash) external; +``` + diff --git a/docs/src/contracts/evm/testing/AttackerContract.sol/contract.AttackerContract.md b/docs/src/contracts/evm/testing/AttackerContract.sol/contract.AttackerContract.md new file mode 100644 index 00000000..6eaae501 --- /dev/null +++ b/docs/src/contracts/evm/testing/AttackerContract.sol/contract.AttackerContract.md @@ -0,0 +1,76 @@ +# AttackerContract +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/AttackerContract.sol) + + +## State Variables +### victimContractAddress + +```solidity +address public victimContractAddress; +``` + + +### _victimMethod + +```solidity +uint256 private _victimMethod; +``` + + +## Functions +### constructor + + +```solidity +constructor(address victimContractAddress_, address wzeta, uint256 victimMethod); +``` + +### receive + + +```solidity +receive() external payable; +``` + +### attackDeposit + + +```solidity +function attackDeposit() internal; +``` + +### attackWidrawal + + +```solidity +function attackWidrawal() internal; +``` + +### attack + + +```solidity +function attack() internal; +``` + +### balanceOf + + +```solidity +function balanceOf(address account) external returns (uint256); +``` + +### transferFrom + + +```solidity +function transferFrom(address from, address to, uint256 amount) public returns (bool); +``` + +### transfer + + +```solidity +function transfer(address to, uint256 amount) public returns (bool); +``` + diff --git a/docs/src/contracts/evm/testing/AttackerContract.sol/interface.Victim.md b/docs/src/contracts/evm/testing/AttackerContract.sol/interface.Victim.md new file mode 100644 index 00000000..d99198a8 --- /dev/null +++ b/docs/src/contracts/evm/testing/AttackerContract.sol/interface.Victim.md @@ -0,0 +1,19 @@ +# Victim +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/AttackerContract.sol) + + +## Functions +### deposit + + +```solidity +function deposit(bytes calldata recipient, address asset, uint256 amount, bytes calldata message) external; +``` + +### withdraw + + +```solidity +function withdraw(address recipient, address asset, uint256 amount) external; +``` + diff --git a/docs/src/contracts/evm/testing/ERC20Mock.sol/contract.ERC20Mock.md b/docs/src/contracts/evm/testing/ERC20Mock.sol/contract.ERC20Mock.md new file mode 100644 index 00000000..0e863c06 --- /dev/null +++ b/docs/src/contracts/evm/testing/ERC20Mock.sol/contract.ERC20Mock.md @@ -0,0 +1,17 @@ +# ERC20Mock +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/ERC20Mock.sol) + +**Inherits:** +ERC20 + +*ZetaEth is an implementation of OpenZeppelin's ERC20* + + +## Functions +### constructor + + +```solidity +constructor(string memory name, string memory symbol, address creator, uint256 initialSupply) ERC20(name, symbol); +``` + diff --git a/docs/src/contracts/evm/testing/README.md b/docs/src/contracts/evm/testing/README.md new file mode 100644 index 00000000..18d008be --- /dev/null +++ b/docs/src/contracts/evm/testing/README.md @@ -0,0 +1,10 @@ + + +# Contents +- [Victim](AttackerContract.sol/interface.Victim.md) +- [AttackerContract](AttackerContract.sol/contract.AttackerContract.md) +- [ERC20Mock](ERC20Mock.sol/contract.ERC20Mock.md) +- [INonfungiblePositionManager](TestUniswapV3Contracts.sol/interface.INonfungiblePositionManager.md) +- [IPoolInitializer](TestUniswapV3Contracts.sol/interface.IPoolInitializer.md) +- [ZetaInteractorMock](ZetaInteractorMock.sol/contract.ZetaInteractorMock.md) +- [ZetaReceiverMock](ZetaReceiverMock.sol/contract.ZetaReceiverMock.md) diff --git a/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.INonfungiblePositionManager.md b/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.INonfungiblePositionManager.md new file mode 100644 index 00000000..e2c28aa1 --- /dev/null +++ b/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.INonfungiblePositionManager.md @@ -0,0 +1,288 @@ +# INonfungiblePositionManager +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/TestUniswapV3Contracts.sol) + +Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred +and authorized. + + +## Functions +### positions + +Returns the position information associated with a given token ID. + +*Throws if the token ID is not valid.* + + +```solidity +function positions(uint256 tokenId) + external + view + returns ( + uint96 nonce, + address operator, + address token0, + address token1, + uint24 fee, + int24 tickLower, + int24 tickUpper, + uint128 liquidity, + uint256 feeGrowthInside0LastX128, + uint256 feeGrowthInside1LastX128, + uint128 tokensOwed0, + uint128 tokensOwed1 + ); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token that represents the position| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`nonce`|`uint96`|The nonce for permits| +|`operator`|`address`|The address that is approved for spending| +|`token0`|`address`|The address of the token0 for a specific pool| +|`token1`|`address`|The address of the token1 for a specific pool| +|`fee`|`uint24`|The fee associated with the pool| +|`tickLower`|`int24`|The lower end of the tick range for the position| +|`tickUpper`|`int24`|The higher end of the tick range for the position| +|`liquidity`|`uint128`|The liquidity of the position| +|`feeGrowthInside0LastX128`|`uint256`|The fee growth of token0 as of the last action on the individual position| +|`feeGrowthInside1LastX128`|`uint256`|The fee growth of token1 as of the last action on the individual position| +|`tokensOwed0`|`uint128`|The uncollected amount of token0 owed to the position as of the last computation| +|`tokensOwed1`|`uint128`|The uncollected amount of token1 owed to the position as of the last computation| + + +### mint + +Creates a new position wrapped in a NFT + +*Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized +a method does not exist, i.e. the pool is assumed to be initialized.* + + +```solidity +function mint(MintParams calldata params) + external + payable + returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`MintParams`|The params necessary to mint a position, encoded as `MintParams` in calldata| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token that represents the minted position| +|`liquidity`|`uint128`|The amount of liquidity for this position| +|`amount0`|`uint256`|The amount of token0| +|`amount1`|`uint256`|The amount of token1| + + +### increaseLiquidity + +Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` + + +```solidity +function increaseLiquidity(IncreaseLiquidityParams calldata params) + external + payable + returns (uint128 liquidity, uint256 amount0, uint256 amount1); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`IncreaseLiquidityParams`|tokenId The ID of the token for which liquidity is being increased, amount0Desired The desired amount of token0 to be spent, amount1Desired The desired amount of token1 to be spent, amount0Min The minimum amount of token0 to spend, which serves as a slippage check, amount1Min The minimum amount of token1 to spend, which serves as a slippage check, deadline The time by which the transaction must be included to effect the change| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`liquidity`|`uint128`|The new liquidity amount as a result of the increase| +|`amount0`|`uint256`|The amount of token0 to acheive resulting liquidity| +|`amount1`|`uint256`|The amount of token1 to acheive resulting liquidity| + + +### decreaseLiquidity + +Decreases the amount of liquidity in a position and accounts it to the position + + +```solidity +function decreaseLiquidity(DecreaseLiquidityParams calldata params) + external + payable + returns (uint256 amount0, uint256 amount1); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`DecreaseLiquidityParams`|tokenId The ID of the token for which liquidity is being decreased, amount The amount by which liquidity will be decreased, amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, deadline The time by which the transaction must be included to effect the change| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`amount0`|`uint256`|The amount of token0 accounted to the position's tokens owed| +|`amount1`|`uint256`|The amount of token1 accounted to the position's tokens owed| + + +### collect + +Collects up to a maximum amount of fees owed to a specific position to the recipient + + +```solidity +function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`CollectParams`|tokenId The ID of the NFT for which tokens are being collected, recipient The account that should receive the tokens, amount0Max The maximum amount of token0 to collect, amount1Max The maximum amount of token1 to collect| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`amount0`|`uint256`|The amount of fees collected in token0| +|`amount1`|`uint256`|The amount of fees collected in token1| + + +### burn + +Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens +must be collected first. + + +```solidity +function burn(uint256 tokenId) external payable; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token that is being burned| + + +## Events +### IncreaseLiquidity +Emitted when liquidity is increased for a position NFT + +*Also emitted when a token is minted* + + +```solidity +event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); +``` + +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token for which liquidity was increased| +|`liquidity`|`uint128`|The amount by which liquidity for the NFT position was increased| +|`amount0`|`uint256`|The amount of token0 that was paid for the increase in liquidity| +|`amount1`|`uint256`|The amount of token1 that was paid for the increase in liquidity| + +### DecreaseLiquidity +Emitted when liquidity is decreased for a position NFT + + +```solidity +event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); +``` + +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token for which liquidity was decreased| +|`liquidity`|`uint128`|The amount by which liquidity for the NFT position was decreased| +|`amount0`|`uint256`|The amount of token0 that was accounted for the decrease in liquidity| +|`amount1`|`uint256`|The amount of token1 that was accounted for the decrease in liquidity| + +### Collect +Emitted when tokens are collected for a position NFT + +*The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior* + + +```solidity +event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); +``` + +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenId`|`uint256`|The ID of the token for which underlying tokens were collected| +|`recipient`|`address`|The address of the account that received the collected tokens| +|`amount0`|`uint256`|The amount of token0 owed to the position that was collected| +|`amount1`|`uint256`|The amount of token1 owed to the position that was collected| + +## Structs +### MintParams + +```solidity +struct MintParams { + address token0; + address token1; + uint24 fee; + int24 tickLower; + int24 tickUpper; + uint256 amount0Desired; + uint256 amount1Desired; + uint256 amount0Min; + uint256 amount1Min; + address recipient; + uint256 deadline; +} +``` + +### IncreaseLiquidityParams + +```solidity +struct IncreaseLiquidityParams { + uint256 tokenId; + uint256 amount0Desired; + uint256 amount1Desired; + uint256 amount0Min; + uint256 amount1Min; + uint256 deadline; +} +``` + +### DecreaseLiquidityParams + +```solidity +struct DecreaseLiquidityParams { + uint256 tokenId; + uint128 liquidity; + uint256 amount0Min; + uint256 amount1Min; + uint256 deadline; +} +``` + +### CollectParams + +```solidity +struct CollectParams { + uint256 tokenId; + address recipient; + uint128 amount0Max; + uint128 amount1Max; +} +``` + diff --git a/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.IPoolInitializer.md b/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.IPoolInitializer.md new file mode 100644 index 00000000..24f2213a --- /dev/null +++ b/docs/src/contracts/evm/testing/TestUniswapV3Contracts.sol/interface.IPoolInitializer.md @@ -0,0 +1,34 @@ +# IPoolInitializer +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/TestUniswapV3Contracts.sol) + + +## Functions +### createAndInitializePoolIfNecessary + +Creates a new pool if it does not exist, then initializes if not initialized + +*This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool* + + +```solidity +function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) + external + payable + returns (address pool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`token0`|`address`|The contract address of token0 of the pool| +|`token1`|`address`|The contract address of token1 of the pool| +|`fee`|`uint24`|The fee amount of the v3 pool for the specified token pair| +|`sqrtPriceX96`|`uint160`|The initial square root price of the pool as a Q64.96 value| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`pool`|`address`|Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary| + + diff --git a/docs/src/contracts/evm/testing/ZetaInteractorMock.sol/contract.ZetaInteractorMock.md b/docs/src/contracts/evm/testing/ZetaInteractorMock.sol/contract.ZetaInteractorMock.md new file mode 100644 index 00000000..c16679f5 --- /dev/null +++ b/docs/src/contracts/evm/testing/ZetaInteractorMock.sol/contract.ZetaInteractorMock.md @@ -0,0 +1,32 @@ +# ZetaInteractorMock +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/ZetaInteractorMock.sol) + +**Inherits:** +Ownable2Step, [ZetaInteractor](/contracts/evm/tools/ZetaInteractor.sol/abstract.ZetaInteractor.md), [ZetaReceiver](/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md) + + +## Functions +### constructor + + +```solidity +constructor(address zetaConnectorAddress) ZetaInteractor(zetaConnectorAddress); +``` + +### onZetaMessage + + +```solidity +function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) + external + override + isValidMessageCall(zetaMessage); +``` + +### onZetaRevert + + +```solidity +function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external override isValidRevertCall(zetaRevert); +``` + diff --git a/docs/src/contracts/evm/testing/ZetaReceiverMock.sol/contract.ZetaReceiverMock.md b/docs/src/contracts/evm/testing/ZetaReceiverMock.sol/contract.ZetaReceiverMock.md new file mode 100644 index 00000000..55b41147 --- /dev/null +++ b/docs/src/contracts/evm/testing/ZetaReceiverMock.sol/contract.ZetaReceiverMock.md @@ -0,0 +1,35 @@ +# ZetaReceiverMock +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/testing/ZetaReceiverMock.sol) + +**Inherits:** +[ZetaReceiver](/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md) + + +## Functions +### onZetaMessage + + +```solidity +function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) external override; +``` + +### onZetaRevert + + +```solidity +function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external override; +``` + +## Events +### MockOnZetaMessage + +```solidity +event MockOnZetaMessage(address destinationAddress); +``` + +### MockOnZetaRevert + +```solidity +event MockOnZetaRevert(address zetaTxSenderAddress); +``` + diff --git a/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/contract.ImmutableCreate2Factory.md b/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/contract.ImmutableCreate2Factory.md new file mode 100644 index 00000000..044115b2 --- /dev/null +++ b/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/contract.ImmutableCreate2Factory.md @@ -0,0 +1,177 @@ +# ImmutableCreate2Factory +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ImmutableCreate2Factory.sol) + +**Author:** +0age + +This contract provides a safeCreate2 function that takes a salt value +and a block of initialization code as arguments and passes them into inline +assembly. The contract prevents redeploys by maintaining a mapping of all +contracts that have already been deployed, and prevents frontrunning or other +collisions by requiring that the first 20 bytes of the salt are equal to the +address of the caller (this can be bypassed by setting the first 20 bytes to +the null address). There is also a view function that computes the address of +the contract that will be created when submitting a given salt or nonce along +with a given block of initialization code. + +*This contract has not yet been fully tested or audited - proceed with +caution and please share any exploits or optimizations you discover.* + + +## State Variables +### _deployed + +```solidity +mapping(address => bool) private _deployed; +``` + + +## Functions +### safeCreate2Internal + + +```solidity +function safeCreate2Internal(bytes32 salt, bytes memory initializationCode) + internal + returns (address deploymentAddress); +``` + +### safeCreate2 + +*Create a contract using CREATE2 by submitting a given salt or nonce +along with the initialization code for the contract. Note that the first 20 +bytes of the salt must match those of the calling address, which prevents +contract creation events from being submitted by unintended parties.* + + +```solidity +function safeCreate2(bytes32 salt, bytes memory initializationCode) + public + payable + containsCaller(salt) + returns (address deploymentAddress); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|bytes32 The nonce that will be passed into the CREATE2 call.| +|`initializationCode`|`bytes`|bytes The initialization code that will be passed into the CREATE2 call.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`deploymentAddress`|`address`|Address of the contract that will be created, or the null address if a contract already exists at that address.| + + +### findCreate2Address + +*Compute the address of the contract that will be created when +submitting a given salt or nonce to the contract along with the contract's +initialization code. The CREATE2 address is computed in accordance with +EIP-1014, and adheres to the formula therein of +`keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when +performing the computation. The computed address is then checked for any +existing contract code - if so, the null address will be returned instead.* + + +```solidity +function findCreate2Address(bytes32 salt, bytes calldata initCode) external view returns (address deploymentAddress); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|bytes32 The nonce passed into the CREATE2 address calculation.| +|`initCode`|`bytes`|bytes The contract initialization code to be used. that will be passed into the CREATE2 address calculation.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`deploymentAddress`|`address`|Address of the contract that will be created, or the null address if a contract has already been deployed to that address.| + + +### findCreate2AddressViaHash + +*Compute the address of the contract that will be created when +submitting a given salt or nonce to the contract along with the keccak256 +hash of the contract's initialization code. The CREATE2 address is computed +in accordance with EIP-1014, and adheres to the formula therein of +`keccak256( 0xff ++ address ++ salt ++ keccak256(init_code)))[12:]` when +performing the computation. The computed address is then checked for any +existing contract code - if so, the null address will be returned instead.* + + +```solidity +function findCreate2AddressViaHash(bytes32 salt, bytes32 initCodeHash) + external + view + returns (address deploymentAddress); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|bytes32 The nonce passed into the CREATE2 address calculation.| +|`initCodeHash`|`bytes32`|bytes32 The keccak256 hash of the initialization code that will be passed into the CREATE2 address calculation.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`deploymentAddress`|`address`|Address of the contract that will be created, or the null address if a contract has already been deployed to that address.| + + +### hasBeenDeployed + +*Determine if a contract has already been deployed by the factory to a +given address.* + + +```solidity +function hasBeenDeployed(address deploymentAddress) external view returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`deploymentAddress`|`address`|address The contract address to check.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|True if the contract has been deployed, false otherwise.| + + +### containsCaller + +*Modifier to ensure that the first 20 bytes of a submitted salt match +those of the calling account. This provides protection against the salt +being stolen by frontrunners or other attackers. The protection can also be +bypassed if desired by setting each of the first 20 bytes to zero.* + + +```solidity +modifier containsCaller(bytes32 salt); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|bytes32 The salt value to check against the calling address.| + + +### safeCreate2AndTransfer + + +```solidity +function safeCreate2AndTransfer(bytes32 salt, bytes calldata initializationCode) + external + payable + containsCaller(salt) + returns (address deploymentAddress); +``` + diff --git a/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/interface.Ownable.md b/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/interface.Ownable.md new file mode 100644 index 00000000..b07fd77c --- /dev/null +++ b/docs/src/contracts/evm/tools/ImmutableCreate2Factory.sol/interface.Ownable.md @@ -0,0 +1,12 @@ +# Ownable +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ImmutableCreate2Factory.sol) + + +## Functions +### transferOwnership + + +```solidity +function transferOwnership(address newOwner) external; +``` + diff --git a/docs/src/contracts/evm/tools/README.md b/docs/src/contracts/evm/tools/README.md new file mode 100644 index 00000000..740a8471 --- /dev/null +++ b/docs/src/contracts/evm/tools/README.md @@ -0,0 +1,19 @@ + + +# Contents +- [interfaces](/contracts/evm/tools/interfaces) +- [Ownable](ImmutableCreate2Factory.sol/interface.Ownable.md) +- [ImmutableCreate2Factory](ImmutableCreate2Factory.sol/contract.ImmutableCreate2Factory.md) +- [ZetaInteractor](ZetaInteractor.sol/abstract.ZetaInteractor.md) +- [ZetaTokenConsumerUniV3Errors](ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md) +- [WETH9](ZetaTokenConsumerPancakeV3.strategy.sol/interface.WETH9.md) +- [ISwapRouterPancake](ZetaTokenConsumerPancakeV3.strategy.sol/interface.ISwapRouterPancake.md) +- [ZetaTokenConsumerPancakeV3](ZetaTokenConsumerPancakeV3.strategy.sol/contract.ZetaTokenConsumerPancakeV3.md) +- [ZetaTokenConsumerTridentErrors](ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md) +- [WETH9](ZetaTokenConsumerTrident.strategy.sol/interface.WETH9.md) +- [ZetaTokenConsumerTrident](ZetaTokenConsumerTrident.strategy.sol/contract.ZetaTokenConsumerTrident.md) +- [ZetaTokenConsumerUniV2Errors](ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md) +- [ZetaTokenConsumerUniV2](ZetaTokenConsumerUniV2.strategy.sol/contract.ZetaTokenConsumerUniV2.md) +- [ZetaTokenConsumerUniV3Errors](ZetaTokenConsumerUniV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md) +- [WETH9](ZetaTokenConsumerUniV3.strategy.sol/interface.WETH9.md) +- [ZetaTokenConsumerUniV3](ZetaTokenConsumerUniV3.strategy.sol/contract.ZetaTokenConsumerUniV3.md) diff --git a/docs/src/contracts/evm/tools/ZetaInteractor.sol/abstract.ZetaInteractor.md b/docs/src/contracts/evm/tools/ZetaInteractor.sol/abstract.ZetaInteractor.md new file mode 100644 index 00000000..4b4a7a7b --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaInteractor.sol/abstract.ZetaInteractor.md @@ -0,0 +1,87 @@ +# ZetaInteractor +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaInteractor.sol) + +**Inherits:** +Ownable2Step, [ZetaInteractorErrors](/contracts/evm/interfaces/ZetaInteractorErrors.sol/interface.ZetaInteractorErrors.md) + + +## State Variables +### ZERO_BYTES + +```solidity +bytes32 constant ZERO_BYTES = keccak256(new bytes(0)); +``` + + +### currentChainId + +```solidity +uint256 internal immutable currentChainId; +``` + + +### connector + +```solidity +ZetaConnector public immutable connector; +``` + + +### interactorsByChainId +*Maps a chain id to its corresponding address of the MultiChainSwap contract +The address is expressed in bytes to allow non-EVM chains +This mapping is useful, mainly, for two reasons: +- Given a chain id, the contract is able to route a transaction to its corresponding address +- To check that the messages (onZetaMessage, onZetaRevert) come from a trusted source* + + +```solidity +mapping(uint256 => bytes) public interactorsByChainId; +``` + + +## Functions +### isValidMessageCall + + +```solidity +modifier isValidMessageCall(ZetaInterfaces.ZetaMessage calldata zetaMessage); +``` + +### isValidRevertCall + + +```solidity +modifier isValidRevertCall(ZetaInterfaces.ZetaRevert calldata zetaRevert); +``` + +### constructor + + +```solidity +constructor(address zetaConnectorAddress); +``` + +### _isValidCaller + + +```solidity +function _isValidCaller() private view; +``` + +### _isValidChainId + +*Useful for contracts that inherit from this one* + + +```solidity +function _isValidChainId(uint256 chainId) internal view returns (bool); +``` + +### setInteractorByChainId + + +```solidity +function setInteractorByChainId(uint256 destinationChainId, bytes calldata contractAddress) external onlyOwner; +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/contract.ZetaTokenConsumerPancakeV3.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/contract.ZetaTokenConsumerPancakeV3.md new file mode 100644 index 00000000..b572b03e --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/contract.ZetaTokenConsumerPancakeV3.md @@ -0,0 +1,143 @@ +# ZetaTokenConsumerPancakeV3 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol) + +**Inherits:** +[ZetaTokenConsumer](/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md), [ZetaTokenConsumerUniV3Errors](/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md) + +*Uniswap V3 strategy for ZetaTokenConsumer* + + +## State Variables +### MAX_DEADLINE + +```solidity +uint256 internal constant MAX_DEADLINE = 200; +``` + + +### zetaPoolFee + +```solidity +uint24 public immutable zetaPoolFee; +``` + + +### tokenPoolFee + +```solidity +uint24 public immutable tokenPoolFee; +``` + + +### WETH9Address + +```solidity +address public immutable WETH9Address; +``` + + +### zetaToken + +```solidity +address public immutable zetaToken; +``` + + +### pancakeV3Router + +```solidity +ISwapRouterPancake public immutable pancakeV3Router; +``` + + +### uniswapV3Factory + +```solidity +IUniswapV3Factory public immutable uniswapV3Factory; +``` + + +### _locked + +```solidity +bool internal _locked; +``` + + +## Functions +### constructor + + +```solidity +constructor( + address zetaToken_, + address pancakeV3Router_, + address uniswapV3Factory_, + address WETH9Address_, + uint24 zetaPoolFee_, + uint24 tokenPoolFee_ +); +``` + +### nonReentrant + + +```solidity +modifier nonReentrant(); +``` + +### receive + + +```solidity +receive() external payable; +``` + +### getZetaFromEth + + +```solidity +function getZetaFromEth(address destinationAddress, uint256 minAmountOut) external payable override returns (uint256); +``` + +### getZetaFromToken + + +```solidity +function getZetaFromToken( + address destinationAddress, + uint256 minAmountOut, + address inputToken, + uint256 inputTokenAmount +) external override returns (uint256); +``` + +### getEthFromZeta + + +```solidity +function getEthFromZeta(address destinationAddress, uint256 minAmountOut, uint256 zetaTokenAmount) + external + override + returns (uint256); +``` + +### getTokenFromZeta + + +```solidity +function getTokenFromZeta( + address destinationAddress, + uint256 minAmountOut, + address outputToken, + uint256 zetaTokenAmount +) external override nonReentrant returns (uint256); +``` + +### hasZetaLiquidity + + +```solidity +function hasZetaLiquidity() external view override returns (bool); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ISwapRouterPancake.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ISwapRouterPancake.md new file mode 100644 index 00000000..e68f0e66 --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ISwapRouterPancake.md @@ -0,0 +1,76 @@ +# ISwapRouterPancake +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol) + +**Inherits:** +IUniswapV3SwapCallback + + +## Functions +### exactInputSingle + +Swaps `amountIn` of one token for as much as possible of another token + + +```solidity +function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactInputSingleParams`|The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`amountOut`|`uint256`|The amount of the received token| + + +### exactInput + +Swaps `amountIn` of one token for as much as possible of another along the specified path + + +```solidity +function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactInputParams`|The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`amountOut`|`uint256`|The amount of the received token| + + +## Structs +### ExactInputSingleParams + +```solidity +struct ExactInputSingleParams { + address tokenIn; + address tokenOut; + uint24 fee; + address recipient; + uint256 amountIn; + uint256 amountOutMinimum; + uint160 sqrtPriceLimitX96; +} +``` + +### ExactInputParams + +```solidity +struct ExactInputParams { + bytes path; + address recipient; + uint256 amountIn; + uint256 amountOutMinimum; +} +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.WETH9.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.WETH9.md new file mode 100644 index 00000000..d053100f --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.WETH9.md @@ -0,0 +1,12 @@ +# WETH9 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol) + + +## Functions +### withdraw + + +```solidity +function withdraw(uint256 wad) external; +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md new file mode 100644 index 00000000..20d7269b --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md @@ -0,0 +1,23 @@ +# ZetaTokenConsumerUniV3Errors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol) + + +## Errors +### InputCantBeZero + +```solidity +error InputCantBeZero(); +``` + +### ErrorSendingETH + +```solidity +error ErrorSendingETH(); +``` + +### ReentrancyError + +```solidity +error ReentrancyError(); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/contract.ZetaTokenConsumerTrident.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/contract.ZetaTokenConsumerTrident.md new file mode 100644 index 00000000..2b67a4fa --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/contract.ZetaTokenConsumerTrident.md @@ -0,0 +1,129 @@ +# ZetaTokenConsumerTrident +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol) + +**Inherits:** +[ZetaTokenConsumer](/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md), [ZetaTokenConsumerTridentErrors](/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md) + +*Trident strategy for ZetaTokenConsumer* + + +## State Variables +### MAX_DEADLINE + +```solidity +uint256 internal constant MAX_DEADLINE = 200; +``` + + +### WETH9Address + +```solidity +address internal immutable WETH9Address; +``` + + +### zetaToken + +```solidity +address public immutable zetaToken; +``` + + +### tridentRouter + +```solidity +IPoolRouter public immutable tridentRouter; +``` + + +### poolFactory + +```solidity +ConcentratedLiquidityPoolFactory public immutable poolFactory; +``` + + +### _locked + +```solidity +bool internal _locked; +``` + + +## Functions +### constructor + + +```solidity +constructor(address zetaToken_, address uniswapV3Router_, address WETH9Address_, address poolFactory_); +``` + +### nonReentrant + + +```solidity +modifier nonReentrant(); +``` + +### receive + + +```solidity +receive() external payable; +``` + +### getPair + + +```solidity +function getPair(address token0, address token1) internal pure returns (address, address); +``` + +### getZetaFromEth + + +```solidity +function getZetaFromEth(address destinationAddress, uint256 minAmountOut) external payable override returns (uint256); +``` + +### getZetaFromToken + + +```solidity +function getZetaFromToken( + address destinationAddress, + uint256 minAmountOut, + address inputToken, + uint256 inputTokenAmount +) external override returns (uint256); +``` + +### getEthFromZeta + + +```solidity +function getEthFromZeta(address destinationAddress, uint256 minAmountOut, uint256 zetaTokenAmount) + external + override + returns (uint256); +``` + +### getTokenFromZeta + + +```solidity +function getTokenFromZeta( + address destinationAddress, + uint256 minAmountOut, + address outputToken, + uint256 zetaTokenAmount +) external override nonReentrant returns (uint256); +``` + +### hasZetaLiquidity + + +```solidity +function hasZetaLiquidity() external view override returns (bool); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.WETH9.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.WETH9.md new file mode 100644 index 00000000..8e6a7177 --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.WETH9.md @@ -0,0 +1,33 @@ +# WETH9 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol) + + +## Functions +### deposit + + +```solidity +function deposit() external payable; +``` + +### withdraw + + +```solidity +function withdraw(uint256 wad) external; +``` + +### depositTo + + +```solidity +function depositTo(address to) external payable; +``` + +### withdrawTo + + +```solidity +function withdrawTo(address payable to, uint256 value) external; +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md new file mode 100644 index 00000000..e9adc33c --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol/interface.ZetaTokenConsumerTridentErrors.md @@ -0,0 +1,23 @@ +# ZetaTokenConsumerTridentErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol) + + +## Errors +### InputCantBeZero + +```solidity +error InputCantBeZero(); +``` + +### ErrorSendingETH + +```solidity +error ErrorSendingETH(); +``` + +### ReentrancyError + +```solidity +error ReentrancyError(); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/contract.ZetaTokenConsumerUniV2.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/contract.ZetaTokenConsumerUniV2.md new file mode 100644 index 00000000..42c5f89c --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/contract.ZetaTokenConsumerUniV2.md @@ -0,0 +1,94 @@ +# ZetaTokenConsumerUniV2 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol) + +**Inherits:** +[ZetaTokenConsumer](/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md), [ZetaTokenConsumerUniV2Errors](/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md) + +*Uniswap V2 strategy for ZetaTokenConsumer* + + +## State Variables +### MAX_DEADLINE + +```solidity +uint256 internal constant MAX_DEADLINE = 200; +``` + + +### wETH + +```solidity +address internal immutable wETH; +``` + + +### zetaToken + +```solidity +address public immutable zetaToken; +``` + + +### uniswapV2Router + +```solidity +IUniswapV2Router02 internal immutable uniswapV2Router; +``` + + +## Functions +### constructor + + +```solidity +constructor(address zetaToken_, address uniswapV2Router_); +``` + +### getZetaFromEth + + +```solidity +function getZetaFromEth(address destinationAddress, uint256 minAmountOut) external payable override returns (uint256); +``` + +### getZetaFromToken + + +```solidity +function getZetaFromToken( + address destinationAddress, + uint256 minAmountOut, + address inputToken, + uint256 inputTokenAmount +) external override returns (uint256); +``` + +### getEthFromZeta + + +```solidity +function getEthFromZeta(address destinationAddress, uint256 minAmountOut, uint256 zetaTokenAmount) + external + override + returns (uint256); +``` + +### getTokenFromZeta + + +```solidity +function getTokenFromZeta( + address destinationAddress, + uint256 minAmountOut, + address outputToken, + uint256 zetaTokenAmount +) external override returns (uint256); +``` + +### hasZetaLiquidity + + +```solidity +function hasZetaLiquidity() external view override returns (bool); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md new file mode 100644 index 00000000..96d77911 --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol/interface.ZetaTokenConsumerUniV2Errors.md @@ -0,0 +1,11 @@ +# ZetaTokenConsumerUniV2Errors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerUniV2.strategy.sol) + + +## Errors +### InputCantBeZero + +```solidity +error InputCantBeZero(); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/contract.ZetaTokenConsumerUniV3.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/contract.ZetaTokenConsumerUniV3.md new file mode 100644 index 00000000..10a9ba79 --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/contract.ZetaTokenConsumerUniV3.md @@ -0,0 +1,143 @@ +# ZetaTokenConsumerUniV3 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol) + +**Inherits:** +[ZetaTokenConsumer](/contracts/evm/interfaces/ZetaInterfaces.sol/interface.ZetaTokenConsumer.md), [ZetaTokenConsumerUniV3Errors](/contracts/evm/tools/ZetaTokenConsumerPancakeV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md) + +*Uniswap V3 strategy for ZetaTokenConsumer* + + +## State Variables +### MAX_DEADLINE + +```solidity +uint256 internal constant MAX_DEADLINE = 200; +``` + + +### zetaPoolFee + +```solidity +uint24 public immutable zetaPoolFee; +``` + + +### tokenPoolFee + +```solidity +uint24 public immutable tokenPoolFee; +``` + + +### WETH9Address + +```solidity +address public immutable WETH9Address; +``` + + +### zetaToken + +```solidity +address public immutable zetaToken; +``` + + +### uniswapV3Router + +```solidity +ISwapRouter public immutable uniswapV3Router; +``` + + +### uniswapV3Factory + +```solidity +IUniswapV3Factory public immutable uniswapV3Factory; +``` + + +### _locked + +```solidity +bool internal _locked; +``` + + +## Functions +### constructor + + +```solidity +constructor( + address zetaToken_, + address uniswapV3Router_, + address uniswapV3Factory_, + address WETH9Address_, + uint24 zetaPoolFee_, + uint24 tokenPoolFee_ +); +``` + +### nonReentrant + + +```solidity +modifier nonReentrant(); +``` + +### receive + + +```solidity +receive() external payable; +``` + +### getZetaFromEth + + +```solidity +function getZetaFromEth(address destinationAddress, uint256 minAmountOut) external payable override returns (uint256); +``` + +### getZetaFromToken + + +```solidity +function getZetaFromToken( + address destinationAddress, + uint256 minAmountOut, + address inputToken, + uint256 inputTokenAmount +) external override returns (uint256); +``` + +### getEthFromZeta + + +```solidity +function getEthFromZeta(address destinationAddress, uint256 minAmountOut, uint256 zetaTokenAmount) + external + override + returns (uint256); +``` + +### getTokenFromZeta + + +```solidity +function getTokenFromZeta( + address destinationAddress, + uint256 minAmountOut, + address outputToken, + uint256 zetaTokenAmount +) external override nonReentrant returns (uint256); +``` + +### hasZetaLiquidity + + +```solidity +function hasZetaLiquidity() external view override returns (bool); +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.WETH9.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.WETH9.md new file mode 100644 index 00000000..fc738e6c --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.WETH9.md @@ -0,0 +1,12 @@ +# WETH9 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol) + + +## Functions +### withdraw + + +```solidity +function withdraw(uint256 wad) external; +``` + diff --git a/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md new file mode 100644 index 00000000..5f2e2795 --- /dev/null +++ b/docs/src/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol/interface.ZetaTokenConsumerUniV3Errors.md @@ -0,0 +1,23 @@ +# ZetaTokenConsumerUniV3Errors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/ZetaTokenConsumerUniV3.strategy.sol) + + +## Errors +### InputCantBeZero + +```solidity +error InputCantBeZero(); +``` + +### ErrorSendingETH + +```solidity +error ErrorSendingETH(); +``` + +### ReentrancyError + +```solidity +error ReentrancyError(); +``` + diff --git a/docs/src/contracts/evm/tools/interfaces/README.md b/docs/src/contracts/evm/tools/interfaces/README.md new file mode 100644 index 00000000..849b1d5a --- /dev/null +++ b/docs/src/contracts/evm/tools/interfaces/README.md @@ -0,0 +1,5 @@ + + +# Contents +- [ConcentratedLiquidityPoolFactory](TridentConcentratedLiquidityPoolFactory.sol/interface.ConcentratedLiquidityPoolFactory.md) +- [IPoolRouter](TridentIPoolRouter.sol/interface.IPoolRouter.md) diff --git a/docs/src/contracts/evm/tools/interfaces/TridentConcentratedLiquidityPoolFactory.sol/interface.ConcentratedLiquidityPoolFactory.md b/docs/src/contracts/evm/tools/interfaces/TridentConcentratedLiquidityPoolFactory.sol/interface.ConcentratedLiquidityPoolFactory.md new file mode 100644 index 00000000..c2c7dff4 --- /dev/null +++ b/docs/src/contracts/evm/tools/interfaces/TridentConcentratedLiquidityPoolFactory.sol/interface.ConcentratedLiquidityPoolFactory.md @@ -0,0 +1,15 @@ +# ConcentratedLiquidityPoolFactory +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/interfaces/TridentConcentratedLiquidityPoolFactory.sol) + + +## Functions +### getPools + + +```solidity +function getPools(address token0, address token1, uint256 startIndex, uint256 count) + external + view + returns (address[] memory pairPools); +``` + diff --git a/docs/src/contracts/evm/tools/interfaces/TridentIPoolRouter.sol/interface.IPoolRouter.md b/docs/src/contracts/evm/tools/interfaces/TridentIPoolRouter.sol/interface.IPoolRouter.md new file mode 100644 index 00000000..1ef1aa4f --- /dev/null +++ b/docs/src/contracts/evm/tools/interfaces/TridentIPoolRouter.sol/interface.IPoolRouter.md @@ -0,0 +1,127 @@ +# IPoolRouter +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/evm/tools/interfaces/TridentIPoolRouter.sol) + + +## Functions +### exactInputSingle + +Swap amountIn of one token for as much as possible of another token + + +```solidity +function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactInputSingleParams`|The parameters necessary for the swap, encoded as ExactInputSingleParams in calldata| + + +### exactInput + +Swap amountIn of one token for as much as possible of another along the specified path + + +```solidity +function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactInputParams`|The parameters necessary for the multi-hop swap, encoded as ExactInputParams in calldata| + + +### exactOutputSingle + +Swaps as little as possible of one token for `amountOut` of another token + + +```solidity +function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactOutputSingleParams`|The parameters necessary for the swap, encoded as ExactOutputSingleParams in calldata| + + +### exactOutput + +Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) + + +```solidity +function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`params`|`ExactOutputParams`|The parameters necessary for the multi-hop swap, encoded as ExactOutputParams in calldata| + + +### sweep + +Recover mistakenly sent tokens + + +```solidity +function sweep(address token, uint256 amount, address recipient) external payable; +``` + +## Structs +### ExactInputSingleParams + +```solidity +struct ExactInputSingleParams { + address tokenIn; + uint256 amountIn; + uint256 amountOutMinimum; + address pool; + address to; + bool unwrap; +} +``` + +### ExactInputParams + +```solidity +struct ExactInputParams { + address tokenIn; + uint256 amountIn; + uint256 amountOutMinimum; + address[] path; + address to; + bool unwrap; +} +``` + +### ExactOutputSingleParams + +```solidity +struct ExactOutputSingleParams { + address tokenIn; + uint256 amountOut; + uint256 amountInMaximum; + address pool; + address to; + bool unwrap; +} +``` + +### ExactOutputParams + +```solidity +struct ExactOutputParams { + address tokenIn; + uint256 amountOut; + uint256 amountInMaximum; + address[] path; + address to; + bool unwrap; +} +``` + diff --git a/docs/src/contracts/zevm/Interfaces.sol/enum.CoinType.md b/docs/src/contracts/zevm/Interfaces.sol/enum.CoinType.md new file mode 100644 index 00000000..a093e87f --- /dev/null +++ b/docs/src/contracts/zevm/Interfaces.sol/enum.CoinType.md @@ -0,0 +1,14 @@ +# CoinType +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/Interfaces.sol) + +*Coin types for ZRC20. Zeta value should not be used.* + + +```solidity +enum CoinType { + Zeta, + Gas, + ERC20 +} +``` + diff --git a/docs/src/contracts/zevm/Interfaces.sol/interface.ISystem.md b/docs/src/contracts/zevm/Interfaces.sol/interface.ISystem.md new file mode 100644 index 00000000..8de54cbd --- /dev/null +++ b/docs/src/contracts/zevm/Interfaces.sol/interface.ISystem.md @@ -0,0 +1,49 @@ +# ISystem +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/Interfaces.sol) + +*Interfaces of SystemContract and ZRC20 to make easier to import.* + + +## Functions +### FUNGIBLE_MODULE_ADDRESS + + +```solidity +function FUNGIBLE_MODULE_ADDRESS() external view returns (address); +``` + +### wZetaContractAddress + + +```solidity +function wZetaContractAddress() external view returns (address); +``` + +### uniswapv2FactoryAddress + + +```solidity +function uniswapv2FactoryAddress() external view returns (address); +``` + +### gasPriceByChainId + + +```solidity +function gasPriceByChainId(uint256 chainID) external view returns (uint256); +``` + +### gasCoinZRC20ByChainId + + +```solidity +function gasCoinZRC20ByChainId(uint256 chainID) external view returns (address); +``` + +### gasZetaPoolByChainId + + +```solidity +function gasZetaPoolByChainId(uint256 chainID) external view returns (address); +``` + diff --git a/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md b/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md new file mode 100644 index 00000000..4ced735f --- /dev/null +++ b/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20.md @@ -0,0 +1,111 @@ +# IZRC20 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/Interfaces.sol) + + +## Functions +### totalSupply + + +```solidity +function totalSupply() external view returns (uint256); +``` + +### balanceOf + + +```solidity +function balanceOf(address account) external view returns (uint256); +``` + +### transfer + + +```solidity +function transfer(address recipient, uint256 amount) external returns (bool); +``` + +### allowance + + +```solidity +function allowance(address owner, address spender) external view returns (uint256); +``` + +### approve + + +```solidity +function approve(address spender, uint256 amount) external returns (bool); +``` + +### transferFrom + + +```solidity +function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); +``` + +### deposit + + +```solidity +function deposit(address to, uint256 amount) external returns (bool); +``` + +### withdraw + + +```solidity +function withdraw(bytes memory to, uint256 amount) external returns (bool); +``` + +### withdrawGasFee + + +```solidity +function withdrawGasFee() external view returns (address, uint256); +``` + +## Events +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value); +``` + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value); +``` + +### Deposit + +```solidity +event Deposit(bytes from, address indexed to, uint256 value); +``` + +### Withdrawal + +```solidity +event Withdrawal(address indexed from, bytes to, uint256 value, uint256 gasfee, uint256 protocolFlatFee); +``` + +### UpdatedSystemContract + +```solidity +event UpdatedSystemContract(address systemContract); +``` + +### UpdatedGasLimit + +```solidity +event UpdatedGasLimit(uint256 gasLimit); +``` + +### UpdatedProtocolFlatFee + +```solidity +event UpdatedProtocolFlatFee(uint256 protocolFlatFee); +``` + diff --git a/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20Metadata.md b/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20Metadata.md new file mode 100644 index 00000000..fd5ae013 --- /dev/null +++ b/docs/src/contracts/zevm/Interfaces.sol/interface.IZRC20Metadata.md @@ -0,0 +1,29 @@ +# IZRC20Metadata +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/Interfaces.sol) + +**Inherits:** +[IZRC20](/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md) + + +## Functions +### name + + +```solidity +function name() external view returns (string memory); +``` + +### symbol + + +```solidity +function symbol() external view returns (string memory); +``` + +### decimals + + +```solidity +function decimals() external view returns (uint8); +``` + diff --git a/docs/src/contracts/zevm/README.md b/docs/src/contracts/zevm/README.md new file mode 100644 index 00000000..5de453b6 --- /dev/null +++ b/docs/src/contracts/zevm/README.md @@ -0,0 +1,19 @@ + + +# Contents +- [interfaces](/contracts/zevm/interfaces) +- [testing](/contracts/zevm/testing) +- [ISystem](Interfaces.sol/interface.ISystem.md) +- [IZRC20](Interfaces.sol/interface.IZRC20.md) +- [IZRC20Metadata](Interfaces.sol/interface.IZRC20Metadata.md) +- [CoinType](Interfaces.sol/enum.CoinType.md) +- [SystemContractErrors](SystemContract.sol/interface.SystemContractErrors.md) +- [SystemContract](SystemContract.sol/contract.SystemContract.md) +- [UniswapImports](Uniswap.sol/contract.UniswapImports.md) +- [UniswapImports](UniswapPeriphery.sol/contract.UniswapImports.md) +- [WETH9](WZETA.sol/contract.WETH9.md) +- [ZRC20Errors](ZRC20.sol/interface.ZRC20Errors.md) +- [ZRC20](ZRC20.sol/contract.ZRC20.md) +- [ZetaInterfaces](ZetaConnectorZEVM.sol/interface.ZetaInterfaces.md) +- [ZetaReceiver](ZetaConnectorZEVM.sol/interface.ZetaReceiver.md) +- [ZetaConnectorZEVM](ZetaConnectorZEVM.sol/contract.ZetaConnectorZEVM.md) diff --git a/docs/src/contracts/zevm/SystemContract.sol/contract.SystemContract.md b/docs/src/contracts/zevm/SystemContract.sol/contract.SystemContract.md new file mode 100644 index 00000000..e8939c66 --- /dev/null +++ b/docs/src/contracts/zevm/SystemContract.sol/contract.SystemContract.md @@ -0,0 +1,277 @@ +# SystemContract +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/SystemContract.sol) + +**Inherits:** +[SystemContractErrors](/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md) + +*The system contract it's called by the protocol to interact with the blockchain. +Also includes a lot of tools to make easier to interact with ZetaChain.* + + +## State Variables +### gasPriceByChainId +Map to know the gas price of each chain given a chain id. + + +```solidity +mapping(uint256 => uint256) public gasPriceByChainId; +``` + + +### gasCoinZRC20ByChainId +Map to know the ZRC20 address of a token given a chain id, ex zETH, zBNB etc. + + +```solidity +mapping(uint256 => address) public gasCoinZRC20ByChainId; +``` + + +### gasZetaPoolByChainId + +```solidity +mapping(uint256 => address) public gasZetaPoolByChainId; +``` + + +### FUNGIBLE_MODULE_ADDRESS +Fungible address is always the same, it's on protocol level. + + +```solidity +address public constant FUNGIBLE_MODULE_ADDRESS = 0x735b14BB79463307AAcBED86DAf3322B1e6226aB; +``` + + +### uniswapv2FactoryAddress +Uniswap V2 addresses. + + +```solidity +address public immutable uniswapv2FactoryAddress; +``` + + +### uniswapv2Router02Address + +```solidity +address public immutable uniswapv2Router02Address; +``` + + +### wZetaContractAddress +Address of the wrapped ZETA to interact with Uniswap V2. + + +```solidity +address public wZetaContractAddress; +``` + + +### zetaConnectorZEVMAddress +Address of ZEVM Zeta Connector. + + +```solidity +address public zetaConnectorZEVMAddress; +``` + + +## Functions +### constructor + +*Only fungible module can deploy a system contract.* + + +```solidity +constructor(address wzeta_, address uniswapv2Factory_, address uniswapv2Router02_); +``` + +### depositAndCall + +*Deposit foreign coins into ZRC20 and call user specified contract on zEVM.* + + +```solidity +function depositAndCall( + zContext calldata context, + address zrc20, + uint256 amount, + address target, + bytes calldata message +) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`context`|`zContext`|| +|`zrc20`|`address`|| +|`amount`|`uint256`|| +|`target`|`address`|| +|`message`|`bytes`|| + + +### sortTokens + +*Sort token addresses lexicographically. Used to handle return values from pairs sorted in the order.* + + +```solidity +function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`tokenA`|`address`|| +|`tokenB`|`address`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`token0`|`address`|token1, returns sorted token addresses,.| +|`token1`|`address`|| + + +### uniswapv2PairFor + +*Calculates the CREATE2 address for a pair without making any external calls.* + + +```solidity +function uniswapv2PairFor(address factory, address tokenA, address tokenB) public pure returns (address pair); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`factory`|`address`|| +|`tokenA`|`address`|| +|`tokenB`|`address`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`pair`|`address`|tokens pair address.| + + +### setGasPrice + +*Fungible module updates the gas price oracle periodically.* + + +```solidity +function setGasPrice(uint256 chainID, uint256 price) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`chainID`|`uint256`|| +|`price`|`uint256`|| + + +### setGasCoinZRC20 + +*Setter for gasCoinZRC20ByChainId map.* + + +```solidity +function setGasCoinZRC20(uint256 chainID, address zrc20) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`chainID`|`uint256`|| +|`zrc20`|`address`|| + + +### setGasZetaPool + +*Set the pool wzeta/erc20 address.* + + +```solidity +function setGasZetaPool(uint256 chainID, address erc20) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`chainID`|`uint256`|| +|`erc20`|`address`|| + + +### setWZETAContractAddress + +*Setter for wrapped ZETA address.* + + +```solidity +function setWZETAContractAddress(address addr) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`addr`|`address`|| + + +### setConnectorZEVMAddress + +*Setter for zetaConnector ZEVM Address* + + +```solidity +function setConnectorZEVMAddress(address addr) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`addr`|`address`|| + + +## Events +### SystemContractDeployed +Custom SystemContract errors. + + +```solidity +event SystemContractDeployed(); +``` + +### SetGasPrice + +```solidity +event SetGasPrice(uint256, uint256); +``` + +### SetGasCoin + +```solidity +event SetGasCoin(uint256, address); +``` + +### SetGasZetaPool + +```solidity +event SetGasZetaPool(uint256, address); +``` + +### SetWZeta + +```solidity +event SetWZeta(address); +``` + +### SetConnectorZEVM + +```solidity +event SetConnectorZEVM(address); +``` + diff --git a/docs/src/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md b/docs/src/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md new file mode 100644 index 00000000..53b68572 --- /dev/null +++ b/docs/src/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md @@ -0,0 +1,37 @@ +# SystemContractErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/SystemContract.sol) + +*Custom errors for SystemContract* + + +## Errors +### CallerIsNotFungibleModule + +```solidity +error CallerIsNotFungibleModule(); +``` + +### InvalidTarget + +```solidity +error InvalidTarget(); +``` + +### CantBeIdenticalAddresses + +```solidity +error CantBeIdenticalAddresses(); +``` + +### CantBeZeroAddress + +```solidity +error CantBeZeroAddress(); +``` + +### ZeroAddress + +```solidity +error ZeroAddress(); +``` + diff --git a/docs/src/contracts/zevm/Uniswap.sol/contract.UniswapImports.md b/docs/src/contracts/zevm/Uniswap.sol/contract.UniswapImports.md new file mode 100644 index 00000000..c05dbbee --- /dev/null +++ b/docs/src/contracts/zevm/Uniswap.sol/contract.UniswapImports.md @@ -0,0 +1,4 @@ +# UniswapImports +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/Uniswap.sol) + + diff --git a/docs/src/contracts/zevm/UniswapPeriphery.sol/contract.UniswapImports.md b/docs/src/contracts/zevm/UniswapPeriphery.sol/contract.UniswapImports.md new file mode 100644 index 00000000..1bb6ef5f --- /dev/null +++ b/docs/src/contracts/zevm/UniswapPeriphery.sol/contract.UniswapImports.md @@ -0,0 +1,4 @@ +# UniswapImports +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/UniswapPeriphery.sol) + + diff --git a/docs/src/contracts/zevm/WZETA.sol/contract.WETH9.md b/docs/src/contracts/zevm/WZETA.sol/contract.WETH9.md new file mode 100644 index 00000000..a239c45c --- /dev/null +++ b/docs/src/contracts/zevm/WZETA.sol/contract.WETH9.md @@ -0,0 +1,115 @@ +# WETH9 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/WZETA.sol) + + +## State Variables +### name + +```solidity +string public name = "Wrapped Zeta"; +``` + + +### symbol + +```solidity +string public symbol = "WZETA"; +``` + + +### decimals + +```solidity +uint8 public decimals = 18; +``` + + +### balanceOf + +```solidity +mapping(address => uint256) public balanceOf; +``` + + +### allowance + +```solidity +mapping(address => mapping(address => uint256)) public allowance; +``` + + +## Functions +### function + + +```solidity +function() public payable; +``` + +### deposit + + +```solidity +function deposit() public payable; +``` + +### withdraw + + +```solidity +function withdraw(uint256 wad) public; +``` + +### totalSupply + + +```solidity +function totalSupply() public view returns (uint256); +``` + +### approve + + +```solidity +function approve(address guy, uint256 wad) public returns (bool); +``` + +### transfer + + +```solidity +function transfer(address dst, uint256 wad) public returns (bool); +``` + +### transferFrom + + +```solidity +function transferFrom(address src, address dst, uint256 wad) public returns (bool); +``` + +## Events +### Approval + +```solidity +event Approval(address indexed src, address indexed guy, uint256 wad); +``` + +### Transfer + +```solidity +event Transfer(address indexed src, address indexed dst, uint256 wad); +``` + +### Deposit + +```solidity +event Deposit(address indexed dst, uint256 wad); +``` + +### Withdrawal + +```solidity +event Withdrawal(address indexed src, uint256 wad); +``` + diff --git a/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md b/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md new file mode 100644 index 00000000..2b772188 --- /dev/null +++ b/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md @@ -0,0 +1,470 @@ +# ZRC20 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/ZRC20.sol) + +**Inherits:** +[IZRC20](/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md), [IZRC20Metadata](/contracts/zevm/Interfaces.sol/interface.IZRC20Metadata.md), [ZRC20Errors](/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md) + + +## State Variables +### FUNGIBLE_MODULE_ADDRESS +Fungible address is always the same, maintained at the protocol level + + +```solidity +address public constant FUNGIBLE_MODULE_ADDRESS = 0x735b14BB79463307AAcBED86DAf3322B1e6226aB; +``` + + +### CHAIN_ID +Chain id.abi + + +```solidity +uint256 public immutable CHAIN_ID; +``` + + +### COIN_TYPE +Coin type, checkout Interfaces.sol. + + +```solidity +CoinType public immutable COIN_TYPE; +``` + + +### SYSTEM_CONTRACT_ADDRESS +System contract address. + + +```solidity +address public SYSTEM_CONTRACT_ADDRESS; +``` + + +### GAS_LIMIT +Gas limit. + + +```solidity +uint256 public GAS_LIMIT; +``` + + +### PROTOCOL_FLAT_FEE +Protocol flat fee. + + +```solidity +uint256 public PROTOCOL_FLAT_FEE; +``` + + +### _balances + +```solidity +mapping(address => uint256) private _balances; +``` + + +### _allowances + +```solidity +mapping(address => mapping(address => uint256)) private _allowances; +``` + + +### _totalSupply + +```solidity +uint256 private _totalSupply; +``` + + +### _name + +```solidity +string private _name; +``` + + +### _symbol + +```solidity +string private _symbol; +``` + + +### _decimals + +```solidity +uint8 private _decimals; +``` + + +## Functions +### _msgSender + + +```solidity +function _msgSender() internal view virtual returns (address); +``` + +### _msgData + + +```solidity +function _msgData() internal view virtual returns (bytes calldata); +``` + +### onlyFungible + +*Only fungible module modifier.* + + +```solidity +modifier onlyFungible(); +``` + +### constructor + +*The only one allowed to deploy new ZRC20 is fungible address.* + + +```solidity +constructor( + string memory name_, + string memory symbol_, + uint8 decimals_, + uint256 chainid_, + CoinType coinType_, + uint256 gasLimit_, + address systemContractAddress_ +); +``` + +### name + +*ZRC20 name* + + +```solidity +function name() public view virtual override returns (string memory); +``` +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`string`|name as string| + + +### symbol + +*ZRC20 symbol.* + + +```solidity +function symbol() public view virtual override returns (string memory); +``` +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`string`|symbol as string.| + + +### decimals + +*ZRC20 decimals.* + + +```solidity +function decimals() public view virtual override returns (uint8); +``` +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`uint8`|returns uint8 decimals.| + + +### totalSupply + +*ZRC20 total supply.* + + +```solidity +function totalSupply() public view virtual override returns (uint256); +``` +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`uint256`|returns uint256 total supply.| + + +### balanceOf + +*Returns ZRC20 balance of an account.* + + +```solidity +function balanceOf(address account) public view virtual override returns (uint256); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`account`|`address`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`uint256`|uint256 account balance.| + + +### transfer + +*Returns ZRC20 balance of an account.* + + +```solidity +function transfer(address recipient, uint256 amount) public virtual override returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`recipient`|`address`|| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if transfer succeeded/failed.| + + +### allowance + +*Returns token allowance from owner to spender.* + + +```solidity +function allowance(address owner, address spender) public view virtual override returns (uint256); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`owner`|`address`|| +|`spender`|`address`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`uint256`|uint256 allowance.| + + +### approve + +*Approves amount transferFrom for spender.* + + +```solidity +function approve(address spender, uint256 amount) public virtual override returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`spender`|`address`|| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if succeeded/failed.| + + +### transferFrom + +*Transfers tokens from sender to recipient.* + + +```solidity +function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`sender`|`address`|| +|`recipient`|`address`|| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if succeeded/failed.| + + +### burn + +*Burns an amount of tokens.* + + +```solidity +function burn(uint256 amount) external returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if succeeded/failed.| + + +### _transfer + + +```solidity +function _transfer(address sender, address recipient, uint256 amount) internal virtual; +``` + +### _mint + + +```solidity +function _mint(address account, uint256 amount) internal virtual; +``` + +### _burn + + +```solidity +function _burn(address account, uint256 amount) internal virtual; +``` + +### _approve + + +```solidity +function _approve(address owner, address spender, uint256 amount) internal virtual; +``` + +### deposit + +*Deposits corresponding tokens from external chain, only callable by Fungible module.* + + +```solidity +function deposit(address to, uint256 amount) external override returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`to`|`address`|| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if succeeded/failed.| + + +### withdrawGasFee + +*Withdraws gas fees.* + + +```solidity +function withdrawGasFee() public view override returns (address, uint256); +``` +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`address`|returns the ZRC20 address for gas on the same chain of this ZRC20, and calculates the gas fee for withdraw()| +|``|`uint256`|| + + +### withdraw + +*Withraws ZRC20 tokens to external chains, this function causes cctx module to send out outbound tx to the outbound chain +this contract should be given enough allowance of the gas ZRC20 to pay for outbound tx gas fee.* + + +```solidity +function withdraw(bytes memory to, uint256 amount) external override returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`to`|`bytes`|| +|`amount`|`uint256`|| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true/false if succeeded/failed.| + + +### updateSystemContractAddress + +*Updates system contract address. Can only be updated by the fungible module.* + + +```solidity +function updateSystemContractAddress(address addr) external onlyFungible; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`addr`|`address`|| + + +### updateGasLimit + +*Updates gas limit. Can only be updated by the fungible module.* + + +```solidity +function updateGasLimit(uint256 gasLimit) external onlyFungible; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`gasLimit`|`uint256`|| + + +### updateProtocolFlatFee + +*Updates protocol flat fee. Can only be updated by the fungible module.* + + +```solidity +function updateProtocolFlatFee(uint256 protocolFlatFee) external onlyFungible; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`protocolFlatFee`|`uint256`|| + + diff --git a/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md b/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md new file mode 100644 index 00000000..6706369d --- /dev/null +++ b/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md @@ -0,0 +1,55 @@ +# ZRC20Errors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/ZRC20.sol) + +*Custom errors for ZRC20* + + +## Errors +### CallerIsNotFungibleModule + +```solidity +error CallerIsNotFungibleModule(); +``` + +### InvalidSender + +```solidity +error InvalidSender(); +``` + +### GasFeeTransferFailed + +```solidity +error GasFeeTransferFailed(); +``` + +### ZeroGasCoin + +```solidity +error ZeroGasCoin(); +``` + +### ZeroGasPrice + +```solidity +error ZeroGasPrice(); +``` + +### LowAllowance + +```solidity +error LowAllowance(); +``` + +### LowBalance + +```solidity +error LowBalance(); +``` + +### ZeroAddress + +```solidity +error ZeroAddress(); +``` + diff --git a/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/contract.ZetaConnectorZEVM.md b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/contract.ZetaConnectorZEVM.md new file mode 100644 index 00000000..ad3abc79 --- /dev/null +++ b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/contract.ZetaConnectorZEVM.md @@ -0,0 +1,191 @@ +# ZetaConnectorZEVM +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/ZetaConnectorZEVM.sol) + + +## State Variables +### wzeta +WZETA token address. + + +```solidity +address public wzeta; +``` + + +### FUNGIBLE_MODULE_ADDRESS +Fungible module address. + + +```solidity +address public constant FUNGIBLE_MODULE_ADDRESS = payable(0x735b14BB79463307AAcBED86DAf3322B1e6226aB); +``` + + +## Functions +### onlyFungibleModule + +*Modifier to restrict actions to fungible module.* + + +```solidity +modifier onlyFungibleModule(); +``` + +### constructor + + +```solidity +constructor(address wzeta_); +``` + +### receive + +*Receive function to receive ZETA from WETH9.withdraw().* + + +```solidity +receive() external payable; +``` + +### setWzetaAddress + + +```solidity +function setWzetaAddress(address wzeta_) external onlyFungibleModule; +``` + +### send + +*Sends ZETA and bytes messages (to execute it) crosschain.* + + +```solidity +function send(ZetaInterfaces.SendInput calldata input) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`input`|`ZetaInterfaces.SendInput`|| + + +### onReceive + +*Handler to receive data from other chain. +This method can be called only by Fungible Module. +Transfer the Zeta tokens to destination and calls onZetaMessage if it's needed. +To perform the transfer wrap the new tokens* + + +```solidity +function onReceive( + bytes calldata zetaTxSenderAddress, + uint256 sourceChainId, + address destinationAddress, + uint256 zetaValue, + bytes calldata message, + bytes32 internalSendHash +) external payable onlyFungibleModule; +``` + +### onRevert + +*Handler to receive errors from other chain. +This method can be called only by Fungible Module. +Transfer the Zeta tokens to destination and calls onZetaRevert if it's needed.* + + +```solidity +function onRevert( + address zetaTxSenderAddress, + uint256 sourceChainId, + bytes calldata destinationAddress, + uint256 destinationChainId, + uint256 remainingZetaValue, + bytes calldata message, + bytes32 internalSendHash +) external payable onlyFungibleModule; +``` + +## Events +### SetWZETA + +```solidity +event SetWZETA(address wzeta_); +``` + +### ZetaSent + +```solidity +event ZetaSent( + address sourceTxOriginAddress, + address indexed zetaTxSenderAddress, + uint256 indexed destinationChainId, + bytes destinationAddress, + uint256 zetaValueAndGas, + uint256 destinationGasLimit, + bytes message, + bytes zetaParams +); +``` + +### ZetaReceived + +```solidity +event ZetaReceived( + bytes zetaTxSenderAddress, + uint256 indexed sourceChainId, + address indexed destinationAddress, + uint256 zetaValue, + bytes message, + bytes32 indexed internalSendHash +); +``` + +### ZetaReverted + +```solidity +event ZetaReverted( + address zetaTxSenderAddress, + uint256 sourceChainId, + uint256 indexed destinationChainId, + bytes destinationAddress, + uint256 remainingZetaValue, + bytes message, + bytes32 indexed internalSendHash +); +``` + +## Errors +### OnlyWZETAOrFungible +Contract custom errors. + + +```solidity +error OnlyWZETAOrFungible(); +``` + +### WZETATransferFailed + +```solidity +error WZETATransferFailed(); +``` + +### OnlyFungibleModule + +```solidity +error OnlyFungibleModule(); +``` + +### FailedZetaSent + +```solidity +error FailedZetaSent(); +``` + +### WrongValue + +```solidity +error WrongValue(); +``` + diff --git a/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaInterfaces.md b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaInterfaces.md new file mode 100644 index 00000000..22104db3 --- /dev/null +++ b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaInterfaces.md @@ -0,0 +1,49 @@ +# ZetaInterfaces +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/ZetaConnectorZEVM.sol) + + +## Structs +### SendInput +*Use SendInput to interact with the Connector: connector.send(SendInput)* + + +```solidity +struct SendInput { + uint256 destinationChainId; + bytes destinationAddress; + uint256 destinationGasLimit; + bytes message; + uint256 zetaValueAndGas; + bytes zetaParams; +} +``` + +### ZetaMessage +*Our Connector calls onZetaMessage with this struct as argument* + + +```solidity +struct ZetaMessage { + bytes zetaTxSenderAddress; + uint256 sourceChainId; + address destinationAddress; + uint256 zetaValue; + bytes message; +} +``` + +### ZetaRevert +*Our Connector calls onZetaRevert with this struct as argument* + + +```solidity +struct ZetaRevert { + address zetaTxSenderAddress; + uint256 sourceChainId; + bytes destinationAddress; + uint256 destinationChainId; + uint256 remainingZetaValue; + bytes message; +} +``` + diff --git a/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md new file mode 100644 index 00000000..945d0361 --- /dev/null +++ b/docs/src/contracts/zevm/ZetaConnectorZEVM.sol/interface.ZetaReceiver.md @@ -0,0 +1,24 @@ +# ZetaReceiver +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/ZetaConnectorZEVM.sol) + + +## Functions +### onZetaMessage + +*onZetaMessage is called when a cross-chain message reaches a contract* + + +```solidity +function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) external; +``` + +### onZetaRevert + +*onZetaRevert is called when a cross-chain message reverts. +It's useful to rollback to the original state* + + +```solidity +function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external; +``` + diff --git a/docs/src/contracts/zevm/interfaces/IUniswapV2Router01.sol/interface.IUniswapV2Router01.md b/docs/src/contracts/zevm/interfaces/IUniswapV2Router01.sol/interface.IUniswapV2Router01.md new file mode 100644 index 00000000..538c274b --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/IUniswapV2Router01.sol/interface.IUniswapV2Router01.md @@ -0,0 +1,228 @@ +# IUniswapV2Router01 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/IUniswapV2Router01.sol) + + +## Functions +### factory + + +```solidity +function factory() external pure returns (address); +``` + +### WETH + + +```solidity +function WETH() external pure returns (address); +``` + +### addLiquidity + + +```solidity +function addLiquidity( + address tokenA, + address tokenB, + uint256 amountADesired, + uint256 amountBDesired, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline +) external returns (uint256 amountA, uint256 amountB, uint256 liquidity); +``` + +### addLiquidityETH + + +```solidity +function addLiquidityETH( + address token, + uint256 amountTokenDesired, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline +) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); +``` + +### removeLiquidity + + +```solidity +function removeLiquidity( + address tokenA, + address tokenB, + uint256 liquidity, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline +) external returns (uint256 amountA, uint256 amountB); +``` + +### removeLiquidityETH + + +```solidity +function removeLiquidityETH( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline +) external returns (uint256 amountToken, uint256 amountETH); +``` + +### removeLiquidityWithPermit + + +```solidity +function removeLiquidityWithPermit( + address tokenA, + address tokenB, + uint256 liquidity, + uint256 amountAMin, + uint256 amountBMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s +) external returns (uint256 amountA, uint256 amountB); +``` + +### removeLiquidityETHWithPermit + + +```solidity +function removeLiquidityETHWithPermit( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s +) external returns (uint256 amountToken, uint256 amountETH); +``` + +### swapExactTokensForTokens + + +```solidity +function swapExactTokensForTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline +) external returns (uint256[] memory amounts); +``` + +### swapTokensForExactTokens + + +```solidity +function swapTokensForExactTokens( + uint256 amountOut, + uint256 amountInMax, + address[] calldata path, + address to, + uint256 deadline +) external returns (uint256[] memory amounts); +``` + +### swapExactETHForTokens + + +```solidity +function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline) + external + payable + returns (uint256[] memory amounts); +``` + +### swapTokensForExactETH + + +```solidity +function swapTokensForExactETH( + uint256 amountOut, + uint256 amountInMax, + address[] calldata path, + address to, + uint256 deadline +) external returns (uint256[] memory amounts); +``` + +### swapExactTokensForETH + + +```solidity +function swapExactTokensForETH( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline +) external returns (uint256[] memory amounts); +``` + +### swapETHForExactTokens + + +```solidity +function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline) + external + payable + returns (uint256[] memory amounts); +``` + +### quote + + +```solidity +function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB); +``` + +### getAmountOut + + +```solidity +function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) + external + pure + returns (uint256 amountOut); +``` + +### getAmountIn + + +```solidity +function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut) + external + pure + returns (uint256 amountIn); +``` + +### getAmountsOut + + +```solidity +function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); +``` + +### getAmountsIn + + +```solidity +function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); +``` + diff --git a/docs/src/contracts/zevm/interfaces/IUniswapV2Router02.sol/interface.IUniswapV2Router02.md b/docs/src/contracts/zevm/interfaces/IUniswapV2Router02.sol/interface.IUniswapV2Router02.md new file mode 100644 index 00000000..06719e4d --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/IUniswapV2Router02.sol/interface.IUniswapV2Router02.md @@ -0,0 +1,78 @@ +# IUniswapV2Router02 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/IUniswapV2Router02.sol) + +**Inherits:** +[IUniswapV2Router01](/contracts/zevm/interfaces/IUniswapV2Router01.sol/interface.IUniswapV2Router01.md) + + +## Functions +### removeLiquidityETHSupportingFeeOnTransferTokens + + +```solidity +function removeLiquidityETHSupportingFeeOnTransferTokens( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline +) external returns (uint256 amountETH); +``` + +### removeLiquidityETHWithPermitSupportingFeeOnTransferTokens + + +```solidity +function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( + address token, + uint256 liquidity, + uint256 amountTokenMin, + uint256 amountETHMin, + address to, + uint256 deadline, + bool approveMax, + uint8 v, + bytes32 r, + bytes32 s +) external returns (uint256 amountETH); +``` + +### swapExactTokensForTokensSupportingFeeOnTransferTokens + + +```solidity +function swapExactTokensForTokensSupportingFeeOnTransferTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline +) external; +``` + +### swapExactETHForTokensSupportingFeeOnTransferTokens + + +```solidity +function swapExactETHForTokensSupportingFeeOnTransferTokens( + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline +) external payable; +``` + +### swapExactTokensForETHSupportingFeeOnTransferTokens + + +```solidity +function swapExactTokensForETHSupportingFeeOnTransferTokens( + uint256 amountIn, + uint256 amountOutMin, + address[] calldata path, + address to, + uint256 deadline +) external; +``` + diff --git a/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md b/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md new file mode 100644 index 00000000..00d7a5c2 --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md @@ -0,0 +1,86 @@ +# IWETH9 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/IWZETA.sol) + + +## Functions +### totalSupply + + +```solidity +function totalSupply() external view returns (uint256); +``` + +### balanceOf + + +```solidity +function balanceOf(address owner) external view returns (uint256); +``` + +### allowance + + +```solidity +function allowance(address owner, address spender) external view returns (uint256); +``` + +### approve + + +```solidity +function approve(address spender, uint256 wad) external returns (bool); +``` + +### transfer + + +```solidity +function transfer(address to, uint256 wad) external returns (bool); +``` + +### transferFrom + + +```solidity +function transferFrom(address from, address to, uint256 wad) external returns (bool); +``` + +### deposit + + +```solidity +function deposit() external payable; +``` + +### withdraw + + +```solidity +function withdraw(uint256 wad) external; +``` + +## Events +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value); +``` + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value); +``` + +### Deposit + +```solidity +event Deposit(address indexed dst, uint256 wad); +``` + +### Withdrawal + +```solidity +event Withdrawal(address indexed src, uint256 wad); +``` + diff --git a/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md b/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md new file mode 100644 index 00000000..6c211c96 --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md @@ -0,0 +1,139 @@ +# IZRC20 +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/IZRC20.sol) + + +## Functions +### totalSupply + + +```solidity +function totalSupply() external view returns (uint256); +``` + +### balanceOf + + +```solidity +function balanceOf(address account) external view returns (uint256); +``` + +### transfer + + +```solidity +function transfer(address recipient, uint256 amount) external returns (bool); +``` + +### allowance + + +```solidity +function allowance(address owner, address spender) external view returns (uint256); +``` + +### approve + + +```solidity +function approve(address spender, uint256 amount) external returns (bool); +``` + +### decreaseAllowance + + +```solidity +function decreaseAllowance(address spender, uint256 amount) external returns (bool); +``` + +### increaseAllowance + + +```solidity +function increaseAllowance(address spender, uint256 amount) external returns (bool); +``` + +### transferFrom + + +```solidity +function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); +``` + +### deposit + + +```solidity +function deposit(address to, uint256 amount) external returns (bool); +``` + +### burn + + +```solidity +function burn(address account, uint256 amount) external returns (bool); +``` + +### withdraw + + +```solidity +function withdraw(bytes memory to, uint256 amount) external returns (bool); +``` + +### withdrawGasFee + + +```solidity +function withdrawGasFee() external view returns (address, uint256); +``` + +### PROTOCOL_FEE + + +```solidity +function PROTOCOL_FEE() external view returns (uint256); +``` + +## Events +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value); +``` + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value); +``` + +### Deposit + +```solidity +event Deposit(bytes from, address indexed to, uint256 value); +``` + +### Withdrawal + +```solidity +event Withdrawal(address indexed from, bytes to, uint256 value, uint256 gasFee, uint256 protocolFlatFee); +``` + +### UpdatedSystemContract + +```solidity +event UpdatedSystemContract(address systemContract); +``` + +### UpdatedGasLimit + +```solidity +event UpdatedGasLimit(uint256 gasLimit); +``` + +### UpdatedProtocolFlatFee + +```solidity +event UpdatedProtocolFlatFee(uint256 protocolFlatFee); +``` + diff --git a/docs/src/contracts/zevm/interfaces/README.md b/docs/src/contracts/zevm/interfaces/README.md new file mode 100644 index 00000000..5368237e --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/README.md @@ -0,0 +1,9 @@ + + +# Contents +- [IUniswapV2Router01](IUniswapV2Router01.sol/interface.IUniswapV2Router01.md) +- [IUniswapV2Router02](IUniswapV2Router02.sol/interface.IUniswapV2Router02.md) +- [IWETH9](IWZETA.sol/interface.IWETH9.md) +- [IZRC20](IZRC20.sol/interface.IZRC20.md) +- [zContext](zContract.sol/struct.zContext.md) +- [zContract](zContract.sol/interface.zContract.md) diff --git a/docs/src/contracts/zevm/interfaces/zContract.sol/interface.zContract.md b/docs/src/contracts/zevm/interfaces/zContract.sol/interface.zContract.md new file mode 100644 index 00000000..39801a33 --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/zContract.sol/interface.zContract.md @@ -0,0 +1,12 @@ +# zContract +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/zContract.sol) + + +## Functions +### onCrossChainCall + + +```solidity +function onCrossChainCall(zContext calldata context, address zrc20, uint256 amount, bytes calldata message) external; +``` + diff --git a/docs/src/contracts/zevm/interfaces/zContract.sol/struct.zContext.md b/docs/src/contracts/zevm/interfaces/zContract.sol/struct.zContext.md new file mode 100644 index 00000000..fceec54a --- /dev/null +++ b/docs/src/contracts/zevm/interfaces/zContract.sol/struct.zContext.md @@ -0,0 +1,12 @@ +# zContext +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/interfaces/zContract.sol) + + +```solidity +struct zContext { + bytes origin; + address sender; + uint256 chainID; +} +``` + diff --git a/docs/src/contracts/zevm/testing/README.md b/docs/src/contracts/zevm/testing/README.md new file mode 100644 index 00000000..8ebe4e10 --- /dev/null +++ b/docs/src/contracts/zevm/testing/README.md @@ -0,0 +1,5 @@ + + +# Contents +- [SystemContractErrors](SystemContractMock.sol/interface.SystemContractErrors.md) +- [SystemContractMock](SystemContractMock.sol/contract.SystemContractMock.md) diff --git a/docs/src/contracts/zevm/testing/SystemContractMock.sol/contract.SystemContractMock.md b/docs/src/contracts/zevm/testing/SystemContractMock.sol/contract.SystemContractMock.md new file mode 100644 index 00000000..101721eb --- /dev/null +++ b/docs/src/contracts/zevm/testing/SystemContractMock.sol/contract.SystemContractMock.md @@ -0,0 +1,131 @@ +# SystemContractMock +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/testing/SystemContractMock.sol) + +**Inherits:** +[SystemContractErrors](/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md) + + +## State Variables +### gasPriceByChainId + +```solidity +mapping(uint256 => uint256) public gasPriceByChainId; +``` + + +### gasCoinZRC20ByChainId + +```solidity +mapping(uint256 => address) public gasCoinZRC20ByChainId; +``` + + +### gasZetaPoolByChainId + +```solidity +mapping(uint256 => address) public gasZetaPoolByChainId; +``` + + +### wZetaContractAddress + +```solidity +address public wZetaContractAddress; +``` + + +### uniswapv2FactoryAddress + +```solidity +address public uniswapv2FactoryAddress; +``` + + +### uniswapv2Router02Address + +```solidity +address public uniswapv2Router02Address; +``` + + +## Functions +### constructor + + +```solidity +constructor(address wzeta_, address uniswapv2Factory_, address uniswapv2Router02_); +``` + +### setGasPrice + + +```solidity +function setGasPrice(uint256 chainID, uint256 price) external; +``` + +### setGasCoinZRC20 + + +```solidity +function setGasCoinZRC20(uint256 chainID, address zrc20) external; +``` + +### setWZETAContractAddress + + +```solidity +function setWZETAContractAddress(address addr) external; +``` + +### sortTokens + + +```solidity +function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1); +``` + +### uniswapv2PairFor + + +```solidity +function uniswapv2PairFor(address factory, address tokenA, address tokenB) public pure returns (address pair); +``` + +### onCrossChainCall + + +```solidity +function onCrossChainCall(address target, address zrc20, uint256 amount, bytes calldata message) external; +``` + +## Events +### SystemContractDeployed + +```solidity +event SystemContractDeployed(); +``` + +### SetGasPrice + +```solidity +event SetGasPrice(uint256, uint256); +``` + +### SetGasCoin + +```solidity +event SetGasCoin(uint256, address); +``` + +### SetGasZetaPool + +```solidity +event SetGasZetaPool(uint256, address); +``` + +### SetWZeta + +```solidity +event SetWZeta(address); +``` + diff --git a/docs/src/contracts/zevm/testing/SystemContractMock.sol/interface.SystemContractErrors.md b/docs/src/contracts/zevm/testing/SystemContractMock.sol/interface.SystemContractErrors.md new file mode 100644 index 00000000..62e35e40 --- /dev/null +++ b/docs/src/contracts/zevm/testing/SystemContractMock.sol/interface.SystemContractErrors.md @@ -0,0 +1,29 @@ +# SystemContractErrors +[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/211e1d1303ec9b17c54dd015449852d1d240bf4f/contracts/zevm/testing/SystemContractMock.sol) + + +## Errors +### CallerIsNotFungibleModule + +```solidity +error CallerIsNotFungibleModule(); +``` + +### InvalidTarget + +```solidity +error InvalidTarget(); +``` + +### CantBeIdenticalAddresses + +```solidity +error CantBeIdenticalAddresses(); +``` + +### CantBeZeroAddress + +```solidity +error CantBeZeroAddress(); +``` +