Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AstariaXYZ/starport into feat/git-w…
Browse files Browse the repository at this point in the history
…orkflows
  • Loading branch information
0xgregthedev committed Sep 16, 2023
2 parents 5f10aa1 + 9280b32 commit 15aa42a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 40 deletions.
17 changes: 0 additions & 17 deletions .gas-snapshot

This file was deleted.

32 changes: 9 additions & 23 deletions src/ConduitHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {Custodian} from "src/Custodian.sol";
import {ECDSA} from "solady/src/utils/ECDSA.sol";
import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol";
import {CaveatEnforcer} from "src/enforcers/CaveatEnforcer.sol";
import {LoanManager} from "src/LoanManager.sol";

abstract contract ConduitHelper {
error RepayCarryLengthMismatch();

// TODO: Greg pls help us unfuck this mess
function _mergeConsiderations(
ReceivedItem[] memory repayConsideration,
ReceivedItem[] memory carryConsideration,
Expand All @@ -37,11 +37,9 @@ abstract contract ConduitHelper {
if (carryConsideration.length == 0 && additionalConsiderations.length == 0) {
return repayConsideration;
}
consideration = new ReceivedItem[](
repayConsideration.length +
consideration = new ReceivedItem[](repayConsideration.length +
carryConsideration.length +
additionalConsiderations.length
);
additionalConsiderations.length);

uint256 j = 0;
// if there is a carry to handle, subtract it from the amount owed
Expand Down Expand Up @@ -69,11 +67,9 @@ abstract contract ConduitHelper {
}
// else just use the consideration payment only
else {
uint256 i = 0;
for (; i < repayConsideration.length;) {
consideration[j] = repayConsideration[i];
for (; j < repayConsideration.length;) {
consideration[j] = repayConsideration[j];
unchecked {
++i;
++j;
}
}
Expand All @@ -82,20 +78,10 @@ abstract contract ConduitHelper {
if (additionalConsiderations.length > 0) {
uint256 i = 0;
for (; i < additionalConsiderations.length;) {
if (
consideration[i].recipient == additionalConsiderations[i].recipient
&& consideration[i].token == additionalConsiderations[i].token
) {
consideration[i].amount += additionalConsiderations[i].amount;
unchecked {
++i;
}
} else {
consideration[j] = additionalConsiderations[i];
unchecked {
++i;
++j;
}
consideration[j] = additionalConsiderations[i];
unchecked {
++i;
++j;
}
}
}
Expand Down

0 comments on commit 15aa42a

Please sign in to comment.