diff --git a/contracts/bindings/feeoraclev1.go b/contracts/bindings/feeoraclev1.go index a1a6e0ff1..add98ff6c 100644 --- a/contracts/bindings/feeoraclev1.go +++ b/contracts/bindings/feeoraclev1.go @@ -40,7 +40,7 @@ type IFeeOracleV1ChainFeeParams struct { // FeeOracleV1MetaData contains all meta data concerning the FeeOracleV1 contract. var FeeOracleV1MetaData = &bind.MetaData{ ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"CONVERSION_RATE_DENOM\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"baseGasLimit\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"bulkSetFeeParams\",\"inputs\":[{\"name\":\"params\",\"type\":\"tuple[]\",\"internalType\":\"structIFeeOracleV1.ChainFeeParams[]\",\"components\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"postsTo\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"toNativeRate\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"feeFor\",\"inputs\":[{\"name\":\"destChainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"feeParams\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIFeeOracleV1.ChainFeeParams\",\"components\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"postsTo\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"toNativeRate\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"gasPriceOn\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"owner_\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"manager_\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"baseGasLimit_\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"protocolFee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"params\",\"type\":\"tuple[]\",\"internalType\":\"structIFeeOracleV1.ChainFeeParams[]\",\"components\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"postsTo\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"toNativeRate\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"manager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"postsTo\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"protocolFee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setBaseGasLimit\",\"inputs\":[{\"name\":\"gasLimit\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setGasPrice\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setManager\",\"inputs\":[{\"name\":\"manager_\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setProtocolFee\",\"inputs\":[{\"name\":\"fee\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setToNativeRate\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"rate\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"toNativeRate\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"BaseGasLimitSet\",\"inputs\":[{\"name\":\"baseGasLimit\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"FeeParamsSet\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"postsTo\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"toNativeRate\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"GasPriceSet\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"gasPrice\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ManagerSet\",\"inputs\":[{\"name\":\"manager\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ProtocolFeeSet\",\"inputs\":[{\"name\":\"protocolFee\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ToNativeRateSet\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"toNativeRate\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]}]", - Bin: "0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6111f7806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80638f9d6ace116100ad578063b48ec86111610071578063b48ec86114610344578063d070415714610377578063d0ebdbe7146103a3578063ee590a53146103b6578063f2fde38b146103c957600080fd5b80638f9d6ace146102f857806393a871881461030257806398563b0314610315578063a34e7abb14610328578063b0e21e8a1461033b57600080fd5b8063787dce3d116100f4578063787dce3d1461023d5780638b7bfd70146102505780638da5cb5b1461028a5780638dd9523c146102ba5780638df66e34146102cd57600080fd5b80632d4634a414610126578063361c019f146101f5578063481c6a751461020a578063715018a614610235575b600080fd5b6101a7610134366004610e22565b60408051608080820183526000808352602080840182905283850182905260609384018290526001600160401b03958616825260038152908490208451928301855280548087168452600160401b9004909516908201526001840154928101929092526002909201549181019190915290565b6040516101ec919060006080820190506001600160401b0380845116835280602085015116602084015250604083015160408301526060830151606083015292915050565b60405180910390f35b610208610203366004610ea6565b6103dc565b005b60025461021d906001600160a01b031681565b6040516001600160a01b0390911681526020016101ec565b610208610514565b61020861024b366004610f24565b610528565b61027c61025e366004610e22565b6001600160401b031660009081526003602052604090206002015490565b6040519081526020016101ec565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031661021d565b61027c6102c8366004610f3d565b61053c565b6000546102e0906001600160401b031681565b6040516001600160401b0390911681526020016101ec565b61027c620f424081565b610208610310366004610fd0565b6106f3565b610208610323366004611011565b61072b565b610208610336366004611011565b61075f565b61027c60015481565b6102e0610352366004610e22565b6001600160401b03908116600090815260036020526040902054600160401b90041690565b61027c610385366004610e22565b6001600160401b031660009081526003602052604090206001015490565b6102086103b136600461103b565b610793565b6102086103c4366004610e22565b6107fa565b6102086103d736600461103b565b61080b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03166000811580156104215750825b90506000826001600160401b0316600114801561043d5750303b155b90508115801561044b575080155b156104695760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561049357845460ff60401b1916600160401b1785555b61049c8b610846565b6104a58a610857565b6104ae896108ac565b6104b7886108fb565b6104c18787610930565b831561050757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b61051c610b4b565b6105266000610ba6565b565b610530610b4b565b610539816108fb565b50565b6001600160401b038085166000908152600360205260408082208054600160401b900490931682528120600183015491929115801590610580575060008260020154115b6105d15760405162461bcd60e51b815260206004820152601a60248201527f4665654f7261636c6556313a206e6f2066656520706172616d7300000000000060448201526064015b60405180910390fd5b600081600101541180156105e9575060008160020154115b6106355760405162461bcd60e51b815260206004820152601a60248201527f4665654f7261636c6556313a206e6f2066656520706172616d7300000000000060448201526064016105c8565b6000620f42408360020154846001015461064f919061106c565b6106599190611089565b90506000620f424083600201548460010154610675919061106c565b61067f9190611089565b9050600061068e88601061106c565b905061069a828261106c565b6106ad846001600160401b038a1661106c565b6000546106c49086906001600160401b031661106c565b6001546106d191906110ab565b6106db91906110ab565b6106e591906110ab565b9a9950505050505050505050565b6002546001600160a01b0316331461071d5760405162461bcd60e51b81526004016105c8906110be565b6107278282610930565b5050565b6002546001600160a01b031633146107555760405162461bcd60e51b81526004016105c8906110be565b6107278282610c17565b6002546001600160a01b031633146107895760405162461bcd60e51b81526004016105c8906110be565b6107278282610cec565b61079b610b4b565b6001600160a01b0381166107f15760405162461bcd60e51b815260206004820152601c60248201527f4665654f7261636c6556313a206e6f207a65726f206d616e616765720000000060448201526064016105c8565b61053981610857565b610802610b4b565b610539816108ac565b610813610b4b565b6001600160a01b03811661083d57604051631e4fbdf760e01b8152600060048201526024016105c8565b61053981610ba6565b61084e610db5565b61053981610dfe565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f60a0f5b9f9e81e98216071b85826681c796256fe3d1354ecb675580fba64fa69906020015b60405180910390a150565b6000805467ffffffffffffffff19166001600160401b0383169081179091556040519081527f6185fbe062d94552cf644f5cb643f583db7b2e7e66fdc4b4c75ff8876a257ba6906020016108a1565b60018190556040518181527fdb5aafdb29539329e37d4e3ee869bc4031941fd55a5dfc92824fbe34b204e30d906020016108a1565b60005b81811015610b4657600083838381811061094f5761094f6110f5565b905060800201803603810190610965919061110b565b905060008160400151116109bb5760405162461bcd60e51b815260206004820152601e60248201527f4665654f7261636c6556313a206e6f207a65726f20676173207072696365000060448201526064016105c8565b6000816060015111610a0b5760405162461bcd60e51b81526020600482015260196024820152784665654f7261636c6556313a206e6f207a65726f207261746560381b60448201526064016105c8565b80516001600160401b0316600003610a355760405162461bcd60e51b81526004016105c89061118a565b80602001516001600160401b0316600003610a925760405162461bcd60e51b815260206004820152601c60248201527f4665654f7261636c6556313a206e6f207a65726f20706f737473546f0000000060448201526064016105c8565b80516001600160401b0390811660009081526003602090815260409182902084518154838701519186166fffffffffffffffffffffffffffffffff199091168117600160401b92909616918202959095178255838601516001830181905560608088015160029094018490558551968752938601919091528484015290830152517ff378a0dd98429494eb2e26894562949c4d6e7cef5eb893b1d4c0052078d92fe59181900360800190a150600101610933565b505050565b33610b7d7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105265760405163118cdaa760e01b81523360048201526024016105c8565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60008111610c675760405162461bcd60e51b815260206004820152601e60248201527f4665654f7261636c6556313a206e6f207a65726f20676173207072696365000060448201526064016105c8565b816001600160401b0316600003610c905760405162461bcd60e51b81526004016105c89061118a565b6001600160401b038216600081815260036020908152604091829020600101849055815192835282018390527f3b196e45eaa29099834d3d912ac550e4f3e13fef2e2a998100368e506a44d8ff91015b60405180910390a15050565b60008111610d385760405162461bcd60e51b81526020600482015260196024820152784665654f7261636c6556313a206e6f207a65726f207261746560381b60448201526064016105c8565b816001600160401b0316600003610d615760405162461bcd60e51b81526004016105c89061118a565b6001600160401b038216600081815260036020908152604091829020600201849055815192835282018390527f4b4594c9f06af25bc504eead96f7f0eaa3f1577f8d9b075b236520ec712e13089101610ce0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661052657604051631afcd79f60e31b815260040160405180910390fd5b610813610db5565b80356001600160401b0381168114610e1d57600080fd5b919050565b600060208284031215610e3457600080fd5b610e3d82610e06565b9392505050565b80356001600160a01b0381168114610e1d57600080fd5b60008083601f840112610e6d57600080fd5b5081356001600160401b03811115610e8457600080fd5b6020830191508360208260071b8501011115610e9f57600080fd5b9250929050565b60008060008060008060a08789031215610ebf57600080fd5b610ec887610e44565b9550610ed660208801610e44565b9450610ee460408801610e06565b93506060870135925060808701356001600160401b03811115610f0657600080fd5b610f1289828a01610e5b565b979a9699509497509295939492505050565b600060208284031215610f3657600080fd5b5035919050565b60008060008060608587031215610f5357600080fd5b610f5c85610e06565b935060208501356001600160401b0380821115610f7857600080fd5b818701915087601f830112610f8c57600080fd5b813581811115610f9b57600080fd5b886020828501011115610fad57600080fd5b602083019550809450505050610fc560408601610e06565b905092959194509250565b60008060208385031215610fe357600080fd5b82356001600160401b03811115610ff957600080fd5b61100585828601610e5b565b90969095509350505050565b6000806040838503121561102457600080fd5b61102d83610e06565b946020939093013593505050565b60006020828403121561104d57600080fd5b610e3d82610e44565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761108357611083611056565b92915050565b6000826110a657634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561108357611083611056565b60208082526018908201527f4665654f7261636c6556313a206e6f74206d616e616765720000000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006080828403121561111d57600080fd5b604051608081018181106001600160401b038211171561114d57634e487b7160e01b600052604160045260246000fd5b60405261115983610e06565b815261116760208401610e06565b602082015260408301356040820152606083013560608201528091505092915050565b6020808252601d908201527f4665654f7261636c6556313a206e6f207a65726f20636861696e20696400000060408201526060019056fea2646970667358221220ac9ecc240ceb7122de5225ec8c42619ed0612e89c406aff2a1188f499c9c249264736f6c63430008180033", + Bin: "0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6111f7806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80638f9d6ace116100ad578063b48ec86111610071578063b48ec86114610344578063d070415714610377578063d0ebdbe7146103a3578063ee590a53146103b6578063f2fde38b146103c957600080fd5b80638f9d6ace146102f857806393a871881461030257806398563b0314610315578063a34e7abb14610328578063b0e21e8a1461033b57600080fd5b8063787dce3d116100f4578063787dce3d1461023d5780638b7bfd70146102505780638da5cb5b1461028a5780638dd9523c146102ba5780638df66e34146102cd57600080fd5b80632d4634a414610126578063361c019f146101f5578063481c6a751461020a578063715018a614610235575b600080fd5b6101a7610134366004610e22565b60408051608080820183526000808352602080840182905283850182905260609384018290526001600160401b03958616825260038152908490208451928301855280548087168452600160401b9004909516908201526001840154928101929092526002909201549181019190915290565b6040516101ec919060006080820190506001600160401b0380845116835280602085015116602084015250604083015160408301526060830151606083015292915050565b60405180910390f35b610208610203366004610ea6565b6103dc565b005b60025461021d906001600160a01b031681565b6040516001600160a01b0390911681526020016101ec565b610208610514565b61020861024b366004610f24565b610528565b61027c61025e366004610e22565b6001600160401b031660009081526003602052604090206002015490565b6040519081526020016101ec565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031661021d565b61027c6102c8366004610f3d565b61053c565b6000546102e0906001600160401b031681565b6040516001600160401b0390911681526020016101ec565b61027c620f424081565b610208610310366004610fd0565b6106f3565b610208610323366004611011565b61072b565b610208610336366004611011565b61075f565b61027c60015481565b6102e0610352366004610e22565b6001600160401b03908116600090815260036020526040902054600160401b90041690565b61027c610385366004610e22565b6001600160401b031660009081526003602052604090206001015490565b6102086103b136600461103b565b610793565b6102086103c4366004610e22565b6107fa565b6102086103d736600461103b565b61080b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03166000811580156104215750825b90506000826001600160401b0316600114801561043d5750303b155b90508115801561044b575080155b156104695760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561049357845460ff60401b1916600160401b1785555b61049c8b610846565b6104a58a610857565b6104ae896108ac565b6104b7886108fb565b6104c18787610930565b831561050757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b61051c610b4b565b6105266000610ba6565b565b610530610b4b565b610539816108fb565b50565b6001600160401b038085166000908152600360205260408082208054600160401b900490931682528120600183015491929115801590610580575060008260020154115b6105d15760405162461bcd60e51b815260206004820152601a60248201527f4665654f7261636c6556313a206e6f2066656520706172616d7300000000000060448201526064015b60405180910390fd5b600081600101541180156105e9575060008160020154115b6106355760405162461bcd60e51b815260206004820152601a60248201527f4665654f7261636c6556313a206e6f2066656520706172616d7300000000000060448201526064016105c8565b6000620f42408360020154846001015461064f919061106c565b6106599190611089565b90506000620f424083600201548460010154610675919061106c565b61067f9190611089565b9050600061068e88601061106c565b905061069a828261106c565b6106ad846001600160401b038a1661106c565b6000546106c49086906001600160401b031661106c565b6001546106d191906110ab565b6106db91906110ab565b6106e591906110ab565b9a9950505050505050505050565b6002546001600160a01b0316331461071d5760405162461bcd60e51b81526004016105c8906110be565b6107278282610930565b5050565b6002546001600160a01b031633146107555760405162461bcd60e51b81526004016105c8906110be565b6107278282610c17565b6002546001600160a01b031633146107895760405162461bcd60e51b81526004016105c8906110be565b6107278282610cec565b61079b610b4b565b6001600160a01b0381166107f15760405162461bcd60e51b815260206004820152601c60248201527f4665654f7261636c6556313a206e6f207a65726f206d616e616765720000000060448201526064016105c8565b61053981610857565b610802610b4b565b610539816108ac565b610813610b4b565b6001600160a01b03811661083d57604051631e4fbdf760e01b8152600060048201526024016105c8565b61053981610ba6565b61084e610db5565b61053981610dfe565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f60a0f5b9f9e81e98216071b85826681c796256fe3d1354ecb675580fba64fa69906020015b60405180910390a150565b6000805467ffffffffffffffff19166001600160401b0383169081179091556040519081527f6185fbe062d94552cf644f5cb643f583db7b2e7e66fdc4b4c75ff8876a257ba6906020016108a1565b60018190556040518181527fdb5aafdb29539329e37d4e3ee869bc4031941fd55a5dfc92824fbe34b204e30d906020016108a1565b60005b81811015610b4657600083838381811061094f5761094f6110f5565b905060800201803603810190610965919061110b565b905060008160400151116109bb5760405162461bcd60e51b815260206004820152601e60248201527f4665654f7261636c6556313a206e6f207a65726f20676173207072696365000060448201526064016105c8565b6000816060015111610a0b5760405162461bcd60e51b81526020600482015260196024820152784665654f7261636c6556313a206e6f207a65726f207261746560381b60448201526064016105c8565b80516001600160401b0316600003610a355760405162461bcd60e51b81526004016105c89061118a565b80602001516001600160401b0316600003610a925760405162461bcd60e51b815260206004820152601c60248201527f4665654f7261636c6556313a206e6f207a65726f20706f737473546f0000000060448201526064016105c8565b80516001600160401b0390811660009081526003602090815260409182902084518154838701519186166fffffffffffffffffffffffffffffffff199091168117600160401b92909616918202959095178255838601516001830181905560608088015160029094018490558551968752938601919091528484015290830152517ff378a0dd98429494eb2e26894562949c4d6e7cef5eb893b1d4c0052078d92fe59181900360800190a150600101610933565b505050565b33610b7d7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105265760405163118cdaa760e01b81523360048201526024016105c8565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60008111610c675760405162461bcd60e51b815260206004820152601e60248201527f4665654f7261636c6556313a206e6f207a65726f20676173207072696365000060448201526064016105c8565b816001600160401b0316600003610c905760405162461bcd60e51b81526004016105c89061118a565b6001600160401b038216600081815260036020908152604091829020600101849055815192835282018390527f3b196e45eaa29099834d3d912ac550e4f3e13fef2e2a998100368e506a44d8ff91015b60405180910390a15050565b60008111610d385760405162461bcd60e51b81526020600482015260196024820152784665654f7261636c6556313a206e6f207a65726f207261746560381b60448201526064016105c8565b816001600160401b0316600003610d615760405162461bcd60e51b81526004016105c89061118a565b6001600160401b038216600081815260036020908152604091829020600201849055815192835282018390527f4b4594c9f06af25bc504eead96f7f0eaa3f1577f8d9b075b236520ec712e13089101610ce0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661052657604051631afcd79f60e31b815260040160405180910390fd5b610813610db5565b80356001600160401b0381168114610e1d57600080fd5b919050565b600060208284031215610e3457600080fd5b610e3d82610e06565b9392505050565b80356001600160a01b0381168114610e1d57600080fd5b60008083601f840112610e6d57600080fd5b5081356001600160401b03811115610e8457600080fd5b6020830191508360208260071b8501011115610e9f57600080fd5b9250929050565b60008060008060008060a08789031215610ebf57600080fd5b610ec887610e44565b9550610ed660208801610e44565b9450610ee460408801610e06565b93506060870135925060808701356001600160401b03811115610f0657600080fd5b610f1289828a01610e5b565b979a9699509497509295939492505050565b600060208284031215610f3657600080fd5b5035919050565b60008060008060608587031215610f5357600080fd5b610f5c85610e06565b935060208501356001600160401b0380821115610f7857600080fd5b818701915087601f830112610f8c57600080fd5b813581811115610f9b57600080fd5b886020828501011115610fad57600080fd5b602083019550809450505050610fc560408601610e06565b905092959194509250565b60008060208385031215610fe357600080fd5b82356001600160401b03811115610ff957600080fd5b61100585828601610e5b565b90969095509350505050565b6000806040838503121561102457600080fd5b61102d83610e06565b946020939093013593505050565b60006020828403121561104d57600080fd5b610e3d82610e44565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761108357611083611056565b92915050565b6000826110a657634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561108357611083611056565b60208082526018908201527f4665654f7261636c6556313a206e6f74206d616e616765720000000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006080828403121561111d57600080fd5b604051608081018181106001600160401b038211171561114d57634e487b7160e01b600052604160045260246000fd5b60405261115983610e06565b815261116760208401610e06565b602082015260408301356040820152606083013560608201528091505092915050565b6020808252601d908201527f4665654f7261636c6556313a206e6f207a65726f20636861696e20696400000060408201526060019056fea264697066735822122079511be7b9d650ebfdcc3b5d7e0ce26c8ba8b32ec761805937eba73a2864831064736f6c63430008180033", } // FeeOracleV1ABI is the input ABI used to generate the binding from. diff --git a/contracts/core/.gas-snapshot b/contracts/core/.gas-snapshot index c8220adcc..bac18e8ca 100644 --- a/contracts/core/.gas-snapshot +++ b/contracts/core/.gas-snapshot @@ -24,6 +24,12 @@ OmniBridgeNative_Test:test_pauseAll() (gas: 42776) OmniBridgeNative_Test:test_pauseBridging() (gas: 36477) OmniBridgeNative_Test:test_pauseWithdraws() (gas: 52062) OmniBridgeNative_Test:test_withdraw() (gas: 262456) +OmniGasPump_Test:test_fillUp() (gas: 230967) +OmniGasPump_Test:test_pause() (gas: 62653) +OmniGasPump_Test:test_setMaxSwap() (gas: 34771) +OmniGasPump_Test:test_setOmniGasStation() (gas: 36697) +OmniGasPump_Test:test_setOracle() (gas: 35014) +OmniGasPump_Test:test_setToll() (gas: 34880) OmniGasStation_Test:test_pause() (gas: 65258) OmniGasStation_Test:test_setPump() (gas: 83832) OmniGasStation_Test:test_settleUp() (gas: 364838) diff --git a/contracts/core/src/interfaces/IConversionRateOracle.sol b/contracts/core/src/interfaces/IConversionRateOracle.sol new file mode 100644 index 000000000..506d9125d --- /dev/null +++ b/contracts/core/src/interfaces/IConversionRateOracle.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.12; + +/** + * @title IConversionRateOracle + * @notice Provides conversion rate from other chain's native token to this chain's native token. + */ +interface IConversionRateOracle { + /** + * @notice Returns the conversion rate (as a numerator over CONVERSION_RATE_DENOM) from `chainId`'s + * native token to this chain's native token. + */ + function toNativeRate(uint64 chainId) external view returns (uint256); + + /** + * @notice Denominator used in to conversion rate calculations. + */ + function CONVERSION_RATE_DENOM() external view returns (uint256); +} diff --git a/contracts/core/src/interfaces/IFeeOracleV1.sol b/contracts/core/src/interfaces/IFeeOracleV1.sol index a7cf84964..1fe3b0df7 100644 --- a/contracts/core/src/interfaces/IFeeOracleV1.sol +++ b/contracts/core/src/interfaces/IFeeOracleV1.sol @@ -2,12 +2,13 @@ pragma solidity ^0.8.12; import { IFeeOracle } from "./IFeeOracle.sol"; +import { IConversionRateOracle } from "./IConversionRateOracle.sol"; /** * @title IFeeOracleV1 * @notice Extends IFeeOracle with FeeOracleV1 methods */ -interface IFeeOracleV1 is IFeeOracle { +interface IFeeOracleV1 is IFeeOracle, IConversionRateOracle { /** * @notice Emitted when fee parameters for a chain are set. */ @@ -83,9 +84,4 @@ interface IFeeOracleV1 is IFeeOracle { * @notice Set the manager admin account. */ function setManager(address manager_) external; - - /** - * @notice returns the conversion rate denominator, used in to - */ - function CONVERSION_RATE_DENOM() external view returns (uint256); } diff --git a/contracts/core/src/token/OmniGasPump.sol b/contracts/core/src/token/OmniGasPump.sol index 446a26969..685b1bc6a 100644 --- a/contracts/core/src/token/OmniGasPump.sol +++ b/contracts/core/src/token/OmniGasPump.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.24; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { XAppUpgradeable } from "src/pkg/XAppUpgradeable.sol"; -import { FeeOracleV1 } from "src/xchain/FeeOracleV1.sol"; +import { IConversionRateOracle } from "src/interfaces/IConversionRateOracle.sol"; import { ConfLevel } from "src/libraries/ConfLevel.sol"; import { OmniGasStation } from "./OmniGasStation.sol"; @@ -19,6 +19,9 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable /// @notice Emitted when the gas station is set event GasStationSet(address station); + /// @notice Emitted when the fee oracle is set + event OracleSet(address oracle); + /// @notice Emitted when the toll is set event TollSet(uint256 pct); @@ -34,10 +37,13 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable event FilledUp(address indexed recipient, uint256 owed, uint256 amtETH, uint256 fee, uint256 toll, uint256 amtOMNI); /// @notice Gas limit passed to OmniGasStation.settleUp xcall - uint64 internal constant SETTLE_GAS = 100_000; + uint64 public constant SETTLE_GAS = 100_000; /// @notice Denominator for toll percentage calculations - uint256 internal constant TOLL_DENOM = 1000; + uint256 public constant TOLL_DENOM = 1000; + + /// @notice Native token conversion rate oracle + IConversionRateOracle public oracle; /// @notice Address of OmniGasStation on Omni address public gasStation; @@ -57,6 +63,7 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable struct InitParams { address gasStation; + address oracle; address portal; address owner; uint256 maxSwap; @@ -64,9 +71,11 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable } function initialize(InitParams calldata p) external initializer { + _setOracle(p.oracle); _setGasStation(p.gasStation); _setMaxSwap(p.maxSwap); _setToll(p.toll); + __XApp_init(p.portal, ConfLevel.Latest); __Ownable_init(p.owner); } @@ -160,14 +169,15 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable /// @notice Converts `amtOMNI` to ETH, using the current conversion rate function _toEth(uint256 amtOMNI) internal view returns (uint256) { - FeeOracleV1 o = FeeOracleV1(omni.feeOracle()); - return amtOMNI * o.CONVERSION_RATE_DENOM() / o.toNativeRate(omniChainId()); + // toNativeRate(omniChainId()) == ETH per OMNI + return amtOMNI * oracle.toNativeRate(omniChainId()) / oracle.CONVERSION_RATE_DENOM(); } /// @notice Converts `amtETH` to OMNI, using the current conversion rate function _toOmni(uint256 amtETH) internal view returns (uint256) { - FeeOracleV1 o = FeeOracleV1(omni.feeOracle()); - return amtETH * o.toNativeRate(omniChainId()) / o.CONVERSION_RATE_DENOM(); + // toNativeRate(omniChainId()) == ETH per OMNI + // to convert ETH to OMNI, we use 1 / toNativeRate(omniChainId()) + return amtETH * oracle.CONVERSION_RATE_DENOM() / oracle.toNativeRate(omniChainId()); } ////////////////////////////////////////////////////////////////////////////// @@ -196,10 +206,15 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable } /// @notice Set the address of the OmniGasStation, on Omni - function setOmniGasStation(address station) external onlyOwner { + function setGasStation(address station) external onlyOwner { _setGasStation(station); } + /// @notice Set the conversion rate oracle + function setOracle(address oracle_) external onlyOwner { + _setOracle(oracle_); + } + /// @notice Set the toll (as a percentage over PCT_DENOM) function setToll(uint256 pct) external onlyOwner { _setToll(pct); @@ -222,4 +237,11 @@ contract OmniGasPump is XAppUpgradeable, OwnableUpgradeable, PausableUpgradeable gasStation = station; emit GasStationSet(station); } + + function _setOracle(address oracle_) internal { + require(oracle_ != address(0), "OmniGasPump: zero oracle"); + oracle = IConversionRateOracle(oracle_); + + emit OracleSet(oracle_); + } } diff --git a/contracts/core/test/token/OmniGasPump.t.sol b/contracts/core/test/token/OmniGasPump.t.sol new file mode 100644 index 000000000..386858c9c --- /dev/null +++ b/contracts/core/test/token/OmniGasPump.t.sol @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity 0.8.24; + +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { FeeOracleV1, IFeeOracleV1 } from "src/xchain/FeeOracleV1.sol"; +import { MockPortal, IOmniPortal } from "test/utils/MockPortal.sol"; +import { ConfLevel } from "src/libraries/ConfLevel.sol"; +import { OmniGasStation } from "src/token/OmniGasStation.sol"; +import { OmniGasPump } from "src/token/OmniGasPump.sol"; +import { Test } from "forge-std/Test.sol"; + +/** + * @title OmniGasPump_Test + * @notice Test suite for OmniGasPump + */ +contract OmniGasPump_Test is Test { + OmniGasPump pump; + MockPortal portal; + FeeOracleV1 feeOracle; + + address owner; + address gasStation; + address feeOracleMngr; + uint256 maxSwap = 2 ether; + uint256 toll = 50; // 5% + + function setUp() public { + portal = new MockPortal(); + owner = makeAddr("owner"); + gasStation = makeAddr("gasStation"); + feeOracleMngr = makeAddr("feeOracleMngr"); + address proxyAdminOwner = makeAddr("padmin"); + + // We use a FeeOracleV1 as our IConversionRateOracle for the gas pump + address feeOracleImpl = address(new FeeOracleV1()); + IFeeOracleV1.ChainFeeParams[] memory chainFeeParams = new IFeeOracleV1.ChainFeeParams[](1); + + // Omni's fee params - only one that's needed + chainFeeParams[0] = IFeeOracleV1.ChainFeeParams({ + chainId: portal.omniChainId(), + gasPrice: 1e9, // 1 Gwei + postsTo: portal.omniChainId(), + toNativeRate: 1e5 // 10 OMNI * (1e5 / 1e6) = 1 ETH + }); + + feeOracle = FeeOracleV1( + address( + new TransparentUpgradeableProxy( + feeOracleImpl, + proxyAdminOwner, + abi.encodeCall( + FeeOracleV1.initialize, + ( + owner, + feeOracleMngr, + 100_000, // baseGasLimit + 0, // protocolFee + chainFeeParams + ) + ) + ) + ) + ); + + address pumpImpl = address(new OmniGasPump()); + pump = OmniGasPump( + payable( + address( + new TransparentUpgradeableProxy( + pumpImpl, + proxyAdminOwner, + abi.encodeCall( + OmniGasPump.initialize, + ( + OmniGasPump.InitParams({ + oracle: address(feeOracle), + gasStation: gasStation, + maxSwap: maxSwap, + toll: toll, + portal: address(portal), + owner: owner + }) + ) + ) + ) + ) + ) + ); + } + + function test_fillUp() public { + address recipient = makeAddr("recipient"); + uint256 initialBalance = 1000 ether; + uint256 fee = pump.xfee(); + uint64 omniChainId = portal.omniChainId(); + vm.deal(recipient, initialBalance); + + // requires fee + vm.expectRevert("OmniGasPump: insufficient fee"); + pump.fillUp(recipient); + + // requires < maxSwap + vm.expectRevert("OmniGasPump: over max"); + vm.prank(recipient); + pump.fillUp{ value: fee + maxSwap + 1 }(recipient); + + // takes toll, updates owed, emits xcall + uint256 swapAmt = 1 ether; + uint256 expectedOwedETH = swapAmt - (swapAmt * toll / pump.TOLL_DENOM()); + uint256 expectedOwedOMNI = expectedOwedETH * 10; // 1 ETH == 10 OMNI + + vm.expectCall( + address(portal), + fee, + abi.encodeCall( + IOmniPortal.xcall, + ( + omniChainId, + ConfLevel.Latest, + gasStation, + abi.encodeWithSelector(OmniGasStation.settleUp.selector, recipient, expectedOwedOMNI), + pump.SETTLE_GAS() + ) + ) + ); + vm.prank(recipient); + + // fillUp returns amount swapped for, not total + uint256 actualOwedOMNI = pump.fillUp{ value: fee + swapAmt }(recipient); + + assertEq(expectedOwedOMNI, actualOwedOMNI); + assertEq(expectedOwedOMNI, pump.owed(recipient)); + + // fillUp again, assert owed accumulates + swapAmt = 2 ether; + expectedOwedETH += swapAmt - (swapAmt * toll / pump.TOLL_DENOM()); + expectedOwedOMNI = expectedOwedETH * 10; // 1 ETH == 10 OMNI + + vm.expectCall( + address(portal), + fee, + abi.encodeCall( + IOmniPortal.xcall, + ( + omniChainId, + ConfLevel.Latest, + gasStation, + abi.encodeWithSelector(OmniGasStation.settleUp.selector, recipient, expectedOwedOMNI), + pump.SETTLE_GAS() + ) + ) + ); + vm.prank(recipient); + + // fillUp returns amount swapped for, not total + actualOwedOMNI += pump.fillUp{ value: fee + swapAmt }(recipient); + + assertEq(expectedOwedOMNI, actualOwedOMNI); + assertEq(expectedOwedOMNI, pump.owed(recipient)); + } + + function test_setMaxSwap() public { + uint256 newMaxSwap = 2e18 ether; + + // only owner + address notOwner = address(0x456); + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.setMaxSwap(newMaxSwap); + + // success + vm.prank(owner); + pump.setMaxSwap(newMaxSwap); + assertEq(pump.maxSwap(), newMaxSwap); + } + + function test_setOmniGasStation() public { + address newGasStation = makeAddr("newGasStation"); + + // only owner + address notOwner = address(0x456); + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.setGasStation(newGasStation); + + // success + vm.prank(owner); + pump.setGasStation(newGasStation); + assertEq(pump.gasStation(), newGasStation); + } + + function test_setToll() public { + uint256 newToll = 100; // 10% + + // only owner + address notOwner = address(0x456); + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.setToll(newToll); + + // success + vm.prank(owner); + pump.setToll(newToll); + assertEq(pump.toll(), newToll); + } + + function test_setOracle() public { + address newOracle = address(0x123); + + // only owner + address notOwner = address(0x456); + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.setOracle(newOracle); + + // success + vm.prank(owner); + pump.setOracle(newOracle); + assertEq(address(pump.oracle()), newOracle); + } + + function test_pause() public { + // only owner can pause + address notOwner = address(0x456); + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.pause(); + + // owner can pause + vm.prank(owner); + pump.pause(); + + assertTrue(pump.paused()); + + // fillUp is paused + address recipient = makeAddr("recipient"); + vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector)); + pump.fillUp(recipient); + + // only owner can unpause + vm.prank(notOwner); + vm.expectRevert(abi.encodeWithSelector(OwnableUpgradeable.OwnableUnauthorizedAccount.selector, notOwner)); + pump.unpause(); + + // owner can unpause + vm.prank(owner); + pump.unpause(); + + assertFalse(pump.paused()); + + // fillUp is unpaused + vm.expectRevert("OmniGasPump: insufficient fee"); // reverts, but not becasue its paused + pump.fillUp(recipient); + } +} diff --git a/contracts/core/test/token/OmniGasStation.t.sol b/contracts/core/test/token/OmniGasStation.t.sol index 2980c1d5a..85c6db604 100644 --- a/contracts/core/test/token/OmniGasStation.t.sol +++ b/contracts/core/test/token/OmniGasStation.t.sol @@ -184,7 +184,7 @@ contract OmniGasStation_Test is Test { // settledUp is unpaused vm.prank(owner); - vm.expectRevert("GasStation: unauthorized"); // still reverts, but not because of pause + vm.expectRevert("GasStation: unauthorized"); // reverts, but not because its paused station.settleUp(recipient, owed); } }