Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas porter #53

Merged
merged 14 commits into from
Nov 26, 2024
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maticnetwork/lxlyjs",
"version": "2.2.1",
"version": "2.3.0-beta.2",
"description": "Javascript developer library for interacting with Polygon LxLy Bridge",
"main": "dist/lxly.node.js",
"types": "dist/ts/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/abis/mainnet/GasPorter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default [{ "inputs": [{ "internalType": "address", "name": "lxlyBridge_", "type": "address" }, { "internalType": "address", "name": "dex_", "type": "address" }, { "internalType": "address", "name": "settlementToken_", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "CannotDetermineConversionBecauseWrappedTokenDoesNotExist", "type": "error" }, { "inputs": [], "name": "CannotDetermineGassetBecauseWrappedTokenDoesNotExist", "type": "error" }, { "inputs": [], "name": "CannotDetermineGassetMakeSureDestinationNetworkParametersAreCorrect", "type": "error" }, { "inputs": [], "name": "CannotRefuelGas", "type": "error" }, { "inputs": [], "name": "CannotReturnExcessiveMessageValueToYou", "type": "error" }, { "inputs": [], "name": "DestinationAddressCannotBeAddressZero", "type": "error" }, { "inputs": [], "name": "DestinationNetworkCannotBeCurrentNetwork", "type": "error" }, { "inputs": [], "name": "ECDSAInvalidSignature", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "length", "type": "uint256" }], "name": "ECDSAInvalidSignatureLength", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "ECDSAInvalidSignatureS", "type": "error" }, { "inputs": [], "name": "GasPorterOnCurrentNetworkDoesNotSupportDexSwapAsGassetSourceYet", "type": "error" }, { "inputs": [], "name": "GasPorterOnCurrentNetworkDoesNotSupportGassetConversionYet", "type": "error" }, { "inputs": [], "name": "GasPorterOnDestinationNetworkDoesNotSupportGassetConversionYet", "type": "error" }, { "inputs": [], "name": "GassetAmountCannotBeZero", "type": "error" }, { "inputs": [], "name": "GassetCannotBeDolphinAddressDidYouMeanAddressZero", "type": "error" }, { "inputs": [], "name": "GassetPermitDataMustBeEmptyWhenGassetIsNativeToken", "type": "error" }, { "inputs": [], "name": "GassetTypeCannotBeERC20TokenWhenNativeTokensAreTheSame", "type": "error" }, { "inputs": [], "name": "GassetTypeCannotBeNativeTokenWhenNativeTokensAreDifferent", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }, { "internalType": "uint256", "name": "minimumAmount", "type": "uint256" }], "name": "InsufficientAmountInERC20Permit", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }, { "internalType": "uint256", "name": "minimumAmount", "type": "uint256" }], "name": "InsufficientMessageValue", "type": "error" }, { "inputs": [], "name": "InvalidConversionNonce", "type": "error" }, { "inputs": [], "name": "InvalidGassetTypeAndGassetSourceCombination", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "InvalidToken", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [], "name": "OriginNetworkCannotBeCurrentNetwork", "type": "error" }, { "inputs": [], "name": "SwapCalldataCannotBeEmptyWhenGassetSourceIsDexSwap", "type": "error" }, { "inputs": [], "name": "SwapCalldataMustBeEmptyWhenGassetSourceIsNotDexSwap", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "SwapFailedBecauseDexGaveInsufficientAmount", "type": "error" }, { "inputs": [{ "internalType": "bytes", "name": "reason", "type": "bytes" }], "name": "SwapFailedBecauseDexReverted", "type": "error" }, { "inputs": [], "name": "SwapFailedBecauseDexRevertedWithoutExplanation", "type": "error" }, { "inputs": [], "name": "ThisFunctionIsOnlyCallableByGasPorter", "type": "error" }, { "inputs": [], "name": "TokenAmountCannotBeZero", "type": "error" }, { "inputs": [], "name": "TokenPermitDataMustBeEmptyWhenAssetAndGassetAreTheSameAndGassetPermitDataIsProvided", "type": "error" }, { "inputs": [], "name": "TokenPermitDataMustBeEmptyWhenAssetIsNativeToken", "type": "error" }, { "inputs": [], "name": "UnknownFunctionSelectorInERC20Permit", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint32", "name": "originNetworkID", "type": "uint32" }, { "indexed": true, "internalType": "bytes32", "name": "originNetworkTxHash", "type": "bytes32" }, { "indexed": false, "internalType": "address", "name": "signer", "type": "address" }, { "indexed": true, "internalType": "address", "name": "msgSender", "type": "address" }, { "indexed": false, "internalType": "bytes", "name": "reason", "type": "bytes" }], "name": "ConversionFailed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint32", "name": "destinationNetwork", "type": "uint32" }, { "indexed": false, "internalType": "address", "name": "destinationAddress", "type": "address" }, { "indexed": false, "internalType": "address", "name": "gasset", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "bridgedGassetAmount", "type": "uint256" }], "name": "ConversionRequested", "type": "event" }, { "anonymous": false, "inputs": [], "name": "EIP712DomainChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint32", "name": "originNetworkID", "type": "uint32" }, { "indexed": true, "internalType": "bytes32", "name": "originNetworkTxHash", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "signer", "type": "address" }], "name": "GassetConverted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "inputs": [], "name": "WETHToken", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bool", "name": "requestConversion", "type": "bool" }, { "internalType": "bool", "name": "forceUpdateGlobalExitRoot", "type": "bool" }, { "internalType": "uint32", "name": "destinationNetwork", "type": "uint32" }, { "internalType": "address", "name": "destinationAddress", "type": "address" }, { "internalType": "address", "name": "gasset", "type": "address" }, { "internalType": "enum GasPorter.GassetSource", "name": "gassetSource", "type": "uint8" }, { "internalType": "bytes", "name": "gassetPermitData", "type": "bytes" }, { "internalType": "uint256", "name": "gassetAmount", "type": "uint256" }, { "internalType": "bytes", "name": "swapCalldata", "type": "bytes" }, { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" }, { "internalType": "bytes", "name": "tokenPermitData", "type": "bytes" }], "name": "bridgeAssetAndGas", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "uint32", "name": "originNetworkID", "type": "uint32" }], "name": "conversionNonce", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint32", "name": "originNetworkID", "type": "uint32" }, { "internalType": "bytes32", "name": "originNetworkTxHash", "type": "bytes32" }, { "internalType": "uint256", "name": "conversionNonce", "type": "uint256" }, { "internalType": "address", "name": "settlementTokenDestinationAddress", "type": "address" }, { "internalType": "bytes", "name": "settlementTokenDestinationPermitData", "type": "bytes" }, { "internalType": "uint256", "name": "settlementTokenDestinationAmount", "type": "uint256" }, { "internalType": "bytes", "name": "destinationSwapCalldata", "type": "bytes" }, { "internalType": "uint256", "name": "destinationNativeTokenMinimumAmount", "type": "uint256" }], "internalType": "struct GasPorter.ConversionAuthorizationData", "name": "authorizationData", "type": "tuple" }, { "internalType": "address", "name": "signer", "type": "address" }], "name": "convertGasset", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "components": [{ "components": [{ "internalType": "uint32", "name": "originNetworkID", "type": "uint32" }, { "internalType": "bytes32", "name": "originNetworkTxHash", "type": "bytes32" }, { "internalType": "uint256", "name": "conversionNonce", "type": "uint256" }, { "internalType": "address", "name": "settlementTokenDestinationAddress", "type": "address" }, { "internalType": "bytes", "name": "settlementTokenDestinationPermitData", "type": "bytes" }, { "internalType": "uint256", "name": "settlementTokenDestinationAmount", "type": "uint256" }, { "internalType": "bytes", "name": "destinationSwapCalldata", "type": "bytes" }, { "internalType": "uint256", "name": "destinationNativeTokenMinimumAmount", "type": "uint256" }], "internalType": "struct GasPorter.ConversionAuthorizationData", "name": "data", "type": "tuple" }, { "internalType": "bytes", "name": "signature", "type": "bytes" }], "internalType": "struct GasPorter.ConversionAuthorization", "name": "authorization", "type": "tuple" }], "name": "convertGasset", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint32", "name": "destinationNetworkGasTokenNetwork", "type": "uint32" }, { "internalType": "address", "name": "destinationNetworkGasTokenAddress", "type": "address" }, { "internalType": "address", "name": "gasset", "type": "address" }], "name": "determineConversion", "outputs": [{ "internalType": "bool", "name": "conversionRequired", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint32", "name": "destinationNetworkGasTokenNetwork", "type": "uint32" }, { "internalType": "address", "name": "destinationNetworkGasTokenAddress", "type": "address" }, { "internalType": "enum GasPorter.GassetType", "name": "gassetType", "type": "uint8" }], "name": "determineGasset", "outputs": [{ "internalType": "address", "name": "gasset", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "dex", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "eip712Domain", "outputs": [{ "internalType": "bytes1", "name": "fields", "type": "bytes1" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "version", "type": "string" }, { "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "verifyingContract", "type": "address" }, { "internalType": "bytes32", "name": "salt", "type": "bytes32" }, { "internalType": "uint256[]", "name": "extensions", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "gasTokenAddress", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "gasTokenNetwork", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "lxlyBridge", "outputs": [{ "internalType": "contract ILxlyBridge", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "networkID", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "msgValue", "type": "uint256" }, { "internalType": "uint32", "name": "destinationNetwork", "type": "uint32" }, { "internalType": "uint32", "name": "destinationNetworkGasTokenNetwork", "type": "uint32" }, { "internalType": "address", "name": "destinationNetworkGasTokenAddress", "type": "address" }, { "internalType": "address", "name": "destinationAddress", "type": "address" }, { "internalType": "address", "name": "destinationGasPorterDex", "type": "address" }, { "internalType": "enum GasPorter.GassetType", "name": "gassetType", "type": "uint8" }, { "internalType": "enum GasPorter.GassetSource", "name": "gassetSource", "type": "uint8" }, { "internalType": "uint256", "name": "gassetAmount", "type": "uint256" }, { "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" }, { "internalType": "bytes", "name": "gassetPermitData", "type": "bytes" }, { "internalType": "bytes", "name": "swapCalldata", "type": "bytes" }, { "internalType": "bytes", "name": "tokenPermitData", "type": "bytes" }, { "internalType": "bool", "name": "forceUpdateGlobalExitRoot", "type": "bool" }], "internalType": "struct GasPorter.Cargo", "name": "cargo", "type": "tuple" }], "name": "plotRoute", "outputs": [{ "internalType": "uint256", "name": "msgValue", "type": "uint256" }, { "internalType": "bytes", "name": "callData", "type": "bytes" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "settlementToken", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "settlementTokenIsNativeToken", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "pure", "type": "function" }, { "stateMutability": "payable", "type": "receive" }]
2 changes: 2 additions & 0 deletions src/abis/mainnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import PolygonZkEVMGlobalExitRoot from "./PolygonZkEVMGlobalExitRoot";
import PolygonZkEVMGlobalExitRootL2 from "./PolygonZkEVMGlobalExitRootL2";
import ZkEVMBridgeAdapter from "./ZkEVMBridgeAdapter";
import ZkEVMWrapper from "./ZkEVMWrapper";
import GasPorter from "./GasPorter";

export default {
GasPorter,
ERC20,
PolygonZkEVM,
PolygonZkEVMBridge,
Expand Down
Loading
Loading