Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/abis/EtherFiARM.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
1 change: 1 addition & 0 deletions src/js/actions/allocateSonic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const handler = async (event) => {
arm,
threshold: 10000,
maxGasPrice: 500,
armContractVersion: "v1",
});
};

Expand Down
15 changes: 12 additions & 3 deletions src/js/tasks/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/js/utils/txLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading