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

update reserve amount of LINK after offchain settlement #12916

Merged
merged 1 commit into from
Apr 25, 2024
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
5 changes: 5 additions & 0 deletions .changeset/witty-icons-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

offchain settlement fix #bugfix
5 changes: 5 additions & 0 deletions contracts/.changeset/poor-panthers-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

Offchain settlement fix #bugfix
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@ contract NOPsSettlement is SetUp {
assertEq(i, index);
assertEq(0, balance);
}

// after the offchain settlement, the total reserve amount of LINK should be 0
assertEq(registry.getReserveAmount(address(linkToken)), 0);
}

function testSettleNOPsOffchainForDeactivatedTransmittersSuccess() public {
Expand Down Expand Up @@ -1035,6 +1038,9 @@ contract NOPsSettlement is SetUp {
assertEq(i, index);
assertEq(0, balance);
}

// after the offchain settlement, the total reserve amount of LINK should be 0
assertEq(registry.getReserveAmount(address(linkToken)), 0);
}

function testDisableOffchainPaymentsRevertDueToUnauthorizedCaller() public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,32 @@ contract AutomationRegistryLogicC2_3 is AutomationRegistryBase2_3 {
uint256 length = activeTransmittersLength + deactivatedTransmittersLength;
uint256[] memory payments = new uint256[](length);
address[] memory payees = new address[](length);

for (uint256 i = 0; i < activeTransmittersLength; i++) {
address transmitterAddr = s_transmittersList[i];
uint96 balance = _updateTransmitterBalanceFromPool(
transmitterAddr,
s_hotVars.totalPremium,
uint96(activeTransmittersLength)
);

payments[i] = balance;
payees[i] = s_transmitterPayees[transmitterAddr];
s_transmitters[transmitterAddr].balance = 0;
}

for (uint256 i = 0; i < deactivatedTransmittersLength; i++) {
address deactivatedAddr = s_deactivatedTransmitters.at(i);
Transmitter memory transmitter = s_transmitters[deactivatedAddr];

payees[i + activeTransmittersLength] = s_transmitterPayees[deactivatedAddr];
payments[i + activeTransmittersLength] = transmitter.balance;
s_transmitters[deactivatedAddr].balance = 0;
}

// reserve amount of LINK is reset to 0 since no user deposits of LINK are expected in offchain mode
s_reserveAmounts[IERC20(address(i_link))] = 0;

for (uint256 idx = s_deactivatedTransmitters.length(); idx > 0; idx--) {
s_deactivatedTransmitters.remove(s_deactivatedTransmitters.at(idx - 1));
}
Expand Down
Loading