diff --git a/src/abis/EtherFiARM.json b/src/abis/EtherFiARM.json index 28068e6d..170d4a58 100644 --- a/src/abis/EtherFiARM.json +++ b/src/abis/EtherFiARM.json @@ -487,6 +487,38 @@ "name": "Transfer", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "requestId", + "type": "uint256" + } + ], + "name": "RequestEtherFiWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "requestIds", + "type": "uint256[]" + } + ], + "name": "ClaimEtherFiWithdrawals", + "type": "event" + }, { "inputs": [], "name": "DELAY_REQUEST", @@ -1200,5 +1232,19 @@ "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], "stateMutability": "view", "type": "function" + }, + { + "inputs": [{"internalType": "uint256[]", "name": "requestIds", "type": "uint256[]"}], + "name": "claimEtherFiWithdrawals", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256"}], + "name": "requestEtherFiWithdrawal", + "outputs": [{"internalType": "uint256", "name": "requestId", "type": "uint256"}], + "stateMutability": "nonpayable", + "type": "function" } ] diff --git a/src/js/actions/allocateSonic.js b/src/js/actions/allocateSonic.js index a6ac68cb..24c16ca1 100644 --- a/src/js/actions/allocateSonic.js +++ b/src/js/actions/allocateSonic.js @@ -27,6 +27,7 @@ const handler = async (event) => { arm, threshold: 10000, maxGasPrice: 500, + armContractVersion: "v1", }); }; diff --git a/src/js/tasks/admin.js b/src/js/tasks/admin.js index f70c4b7f..31e0eba2 100644 --- a/src/js/tasks/admin.js +++ b/src/js/tasks/admin.js @@ -30,16 +30,25 @@ async function allocate({ threshold, execute = true, maxGasPrice: maxGasPriceGwei = 10, + // V1 on sonic everywhere else V2 + armContractVersion = "v2", }) { if (await limitGasPrice(signer, maxGasPriceGwei)) { log("Skipping allocation due to high gas price"); return; } - // 1. Call the allocate static call to get the return values - // Returned value is a tuple of two int256 values let liquidityDelta; - [, liquidityDelta] = await arm.allocate.staticCall(); + if (armContractVersion === "v1") { + // The old implementation returns only liquidityDelta + liquidityDelta = await arm.allocate.staticCall(); + } else if (armContractVersion === "v2") { + // 1. Call the allocate static call to get the return values + // Returned value is a tuple of two int256 values + [, liquidityDelta] = await arm.allocate.staticCall(); + } else { + throw new Error("Invalid ARM contract version"); + } const thresholdBN = parseUnits((threshold || "10").toString(), 18); if (liquidityDelta < thresholdBN && liquidityDelta > -thresholdBN) { diff --git a/src/js/utils/txLogger.js b/src/js/utils/txLogger.js index 6a95c6e6..9751dd8c 100644 --- a/src/js/utils/txLogger.js +++ b/src/js/utils/txLogger.js @@ -26,6 +26,10 @@ async function logTxDetails(tx, method, confirm = true) { } GWei, costing ${formatUnits(txCost)} ETH`, ); + if (receipt.status !== 1) { + throw new Error(`Transaction ${tx.hash} calling ${method} failed.`); + } + return receipt; }