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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ LI.FI Intent is a cross-chain swap protocol built with the Open Intents Framewor

Deployed addresses:
- Compact Address: `0x00000000000000171ede64904551eeDF3C6C9788`
- Input Settler Compact Address: `0x000000c9eC71B1a39055Ec631200ED0022140074`
- Input Settler Escrow Address: `0x000001bf3F3175BD007f3889b50000c7006E72c0`
- Output Settler Address: `0x00000000D7278408CE7a490015577c41e57143a5`
- Input Settler Compact Address: `0x0000000000cd5f7fDEc90a03a31F79E5Fbc6A9Cf`
- Input Settler Escrow Address: `0x000025c3226C00B2Cdc200005a1600509f4e00C0`
- Output Settler Address: `0x0000000000eC36B683C2E6AC89e9A75989C22a2e`
- Polymer Oracle Testnet: `0x00d5b500ECa100F7cdeDC800eC631Aca00BaAC00`
- Polymer Oracle Mainnet: `0x0000006ea400569c0040d6e5ba651c00848409be`

Expand Down
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ evm_version = "cancun"
via_ir = true
optimizer = true
optimizer_runs = 100_000_000
bytecode_hash = 'none'
fuzz.runs = 10_000
fs_permissions = [{ access = "read-write", path = "./script/wormhole.json" }, { access = "read-write", path = "./script/polymer.json" }]

Expand Down
2 changes: 1 addition & 1 deletion lib/OIF
Submodule OIF updated from d81ecf to 225afb
118 changes: 48 additions & 70 deletions script/deploy.s.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/orderId.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract GetOrderId is Script {
token: 0x000000000000000000000000036cbd53842c5426634e7929541ec2318f3dcf7e,
amount: 20000,
recipient: 0x000000000000000000000000529cebf485dee1d68073afb75244022f048b0157,
call: hex"",
callbackData: hex"",
context: hex""
});
StandardOrder memory order = StandardOrder({
Expand Down
4 changes: 2 additions & 2 deletions script/polymer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ contract deployPolymer is multichain {

constructor() {
polymerSalts[0x03Fb5bFA4EB2Cba072A477A372bB87880A60fC96] =
0x00000000000000000000000000000000000000003f5a1d9c8d66f846fc58000c;
0x00000000000000000000000000000000000000003f5a1d9c8d66f846fc58000c;
polymerSalts[0x95ccEAE71605c5d97A0AC0EA13013b058729d075] =
0x00000000000000000000000000000000000000004f09241f65a03e2a3e020030;
0x00000000000000000000000000000000000000004f09241f65a03e2a3e020030;
}

function run(
Expand Down
20 changes: 10 additions & 10 deletions snapshots/inputSettler.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"CompactFinaliseFor": "101978",
"CompactFinaliseSelf": "94549",
"CompactFinaliseTo": "94549",
"EscrowFinalise": "44343",
"IntegrationCoinFill": "64943",
"EscrowFinalise": "44316",
"IntegrationCoinFill": "64965",
"IntegrationCompactFinaliseSelf": "85359",
"IntegrationWormholeReceiveMessage": "45665",
"IntegrationWormholeSubmit": "13837",
"broadcast": "14904",
"compactFinaliseSelfWithFee": "164087",
"depositAndRegisterFor": "129887",
"escrowFinaliseSelfWithFee": "106546",
"escrowFinaliseWithSignature": "51532",
"escrowOpen": "56800",
"escrowOpenFor3009Single": "85401",
"escrowOpenFor3009SingleArray": "90505",
"escrowOpenFor3009Two": "140507",
"escrowOpenForMsgSender": "57023",
"escrowOpenForPermit2": "94692"
"escrowFinaliseSelfWithFee": "106519",
"escrowFinaliseWithSignature": "51505",
"escrowOpen": "56999",
"escrowOpenFor3009Single": "85640",
"escrowOpenFor3009SingleArray": "90796",
"escrowOpenFor3009Two": "140807",
"escrowOpenForMsgSender": "57219",
"escrowOpenForPermit2": "94897"
}
5 changes: 4 additions & 1 deletion src/input/compact/InputSettlerCompactLIFI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ contract InputSettlerCompactLIFI is InputSettlerCompact, GovernanceFee {

event IntentRegistered(bytes32 indexed orderId, StandardOrder order);

constructor(address compact, address initialOwner) InputSettlerCompact(compact) {
constructor(
address compact,
address initialOwner
) InputSettlerCompact(compact) {
_initializeOwner(initialOwner);
}

Expand Down
6 changes: 5 additions & 1 deletion src/input/escrow/InputSettlerEscrowLIFI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ contract InputSettlerEscrowLIFI is InputSettlerEscrow, GovernanceFee {
* msg.sender.
* Does not validate fillDeadline.
*/
function _validateFillsNow(address inputOracle, MandateOutput[] calldata outputs, bytes32 orderId) internal view {
function _validateFillsNow(
address inputOracle,
MandateOutput[] calldata outputs,
bytes32 orderId
) internal view {
uint256 numOutputs = outputs.length;
bytes memory proofSeries = new bytes(32 * 4 * numOutputs);
for (uint256 i; i < numOutputs; ++i) {
Expand Down
5 changes: 4 additions & 1 deletion src/libs/GovernanceFee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ abstract contract GovernanceFee is Ownable {
* @param fee Fee to subtract from amount. Is percentage and GOVERNANCE_FEE_DENOM based.
* @return amountFee Fee
*/
function _calcFee(uint256 amount, uint256 fee) internal pure returns (uint256 amountFee) {
function _calcFee(
uint256 amount,
uint256 fee
) internal pure returns (uint256 amountFee) {
unchecked {
// Check if amount * fee overflows. If it does, don't take the fee.
if (fee == 0 || amount >= type(uint256).max / fee) return amountFee = 0;
Expand Down
33 changes: 20 additions & 13 deletions src/libs/RegisterIntentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ library RegisterIntentLib {

bytes32 constant STANDARD_ORDER_BATCH_COMPACT_TYPE_HASH = keccak256(
bytes(
"BatchCompact(address arbiter,address sponsor,uint256 nonce,uint256 expires,Lock[] commitments,Mandate mandate)Lock(bytes12 lockTag,address token,uint256 amount)Mandate(uint32 fillDeadline,address inputOracle,MandateOutput[] outputs)MandateOutput(bytes32 oracle,bytes32 settler,uint256 chainId,bytes32 token,uint256 amount,bytes32 recipient,bytes call,bytes context)"
"BatchCompact(address arbiter,address sponsor,uint256 nonce,uint256 expires,Lock[] commitments,Mandate mandate)Lock(bytes12 lockTag,address token,uint256 amount)Mandate(uint32 fillDeadline,address inputOracle,MandateOutput[] outputs)MandateOutput(bytes32 oracle,bytes32 settler,uint256 chainId,bytes32 token,uint256 amount,bytes32 recipient,bytes callbackData,bytes context)"
)
);

Expand All @@ -42,7 +42,7 @@ library RegisterIntentLib {
output.token,
output.amount,
output.recipient,
keccak256(output.call),
keccak256(output.callbackData),
keccak256(output.context)
)
);
Expand Down Expand Up @@ -112,7 +112,10 @@ library RegisterIntentLib {
}
}

function compactClaimHash(address settler, StandardOrder calldata order) internal pure returns (bytes32) {
function compactClaimHash(
address settler,
StandardOrder calldata order
) internal pure returns (bytes32) {
return keccak256(
abi.encode(
STANDARD_ORDER_BATCH_COMPACT_TYPE_HASH,
Expand All @@ -133,7 +136,10 @@ library RegisterIntentLib {
if (block.chainid != originChainId) revert WrongChain(block.chainid, originChainId);
}

function _validateExpiry(uint32 fillDeadline, uint32 expires) internal view {
function _validateExpiry(
uint32 fillDeadline,
uint32 expires
) internal view {
// Check if the fill deadline has been passed
if (block.timestamp > fillDeadline) revert DeadlinePassed();
// Check if expiry has been passed
Expand Down Expand Up @@ -163,14 +169,15 @@ library RegisterIntentLib {
}
}

(claimHash,) = TheCompact(COMPACT).batchDepositAndRegisterFor(
order.user,
idsAndAmounts,
arbiter,
order.nonce,
order.expires,
STANDARD_ORDER_BATCH_COMPACT_TYPE_HASH,
witnessHash(order)
);
(claimHash,) = TheCompact(COMPACT)
.batchDepositAndRegisterFor(
order.user,
idsAndAmounts,
arbiter,
order.nonce,
order.expires,
STANDARD_ORDER_BATCH_COMPACT_TYPE_HASH,
witnessHash(order)
);
}
}
15 changes: 8 additions & 7 deletions test/input/compact/InputSettlerCompactLIFI.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ contract InputSettlerCompactLIFITest is InputSettlerCompactTest {
InputSettlerCompactLIFI(inputSettlerCompact).setGovernanceFee(type(uint64).max);
}

function test_governance_fee_change_not_ready(uint64 fee, uint256 timeDelay) public {
function test_governance_fee_change_not_ready(
uint64 fee,
uint256 timeDelay
) public {
vm.assume(fee <= MAX_GOVERNANCE_FEE);
vm.assume(timeDelay < uint32(block.timestamp) + GOVERNANCE_FEE_CHANGE_DELAY);

Expand Down Expand Up @@ -96,7 +99,7 @@ contract InputSettlerCompactLIFITest is InputSettlerCompactTest {
token: bytes32(uint256(uint160(address(anotherToken)))),
amount: amount,
recipient: bytes32(uint256(uint160(swapper))),
call: hex"",
callbackData: hex"",
context: hex""
});
StandardOrder memory order = StandardOrder({
Expand Down Expand Up @@ -125,14 +128,12 @@ contract InputSettlerCompactLIFITest is InputSettlerCompactTest {

InputSettlerBase.SolveParams[] memory solveParams = new InputSettlerBase.SolveParams[](1);
solveParams[0] = InputSettlerBase.SolveParams({
solver: bytes32(uint256(uint160((solver)))),
timestamp: uint32(block.timestamp)
solver: bytes32(uint256(uint160((solver)))), timestamp: uint32(block.timestamp)
});

vm.prank(solver);
InputSettlerCompactLIFI(inputSettlerCompact).finalise(
order, signature, solveParams, bytes32(uint256(uint160((solver)))), hex""
);
InputSettlerCompactLIFI(inputSettlerCompact)
.finalise(order, signature, solveParams, bytes32(uint256(uint160((solver)))), hex"");
vm.snapshotGasLastCall("inputSettler", "compactFinaliseSelfWithFee");

assertEq(token.balanceOf(solver), amountPostFee);
Expand Down
23 changes: 14 additions & 9 deletions test/input/escrow/InputSettlerEscrowLIFI.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ contract InputSettlerEscrowLIFIHarness is InputSettlerEscrowLIFI {
address initialOwner
) InputSettlerEscrowLIFI(initialOwner) { }

function validateFillsNow(address inputOracle, MandateOutput[] calldata outputs, bytes32 orderId) external view {
function validateFillsNow(
address inputOracle,
MandateOutput[] calldata outputs,
bytes32 orderId
) external view {
_validateFillsNow(inputOracle, outputs, orderId);
}
}
Expand Down Expand Up @@ -60,7 +64,7 @@ contract inputSettlerEscrowTestBaseLIFI is InputSettlerEscrowTest {
output.token,
output.amount,
output.recipient,
output.call,
output.callbackData,
output.context
)
)
Expand Down Expand Up @@ -91,7 +95,10 @@ contract inputSettlerEscrowTestBaseLIFI is InputSettlerEscrowTest {
InputSettlerEscrowLIFI(inputSettlerEscrow).setGovernanceFee(type(uint64).max);
}

function test_governance_fee_change_not_ready(uint64 fee, uint256 timeDelay) public {
function test_governance_fee_change_not_ready(
uint64 fee,
uint256 timeDelay
) public {
vm.assume(fee <= MAX_GOVERNANCE_FEE);
vm.assume(timeDelay < uint32(block.timestamp) + GOVERNANCE_FEE_CHANGE_DELAY);

Expand Down Expand Up @@ -140,7 +147,7 @@ contract inputSettlerEscrowTestBaseLIFI is InputSettlerEscrowTest {
token: bytes32(uint256(uint160(address(anotherToken)))),
amount: amount,
recipient: bytes32(uint256(uint160(swapper))),
call: hex"",
callbackData: hex"",
context: hex""
});
uint256[2][] memory inputs = new uint256[2][](1);
Expand Down Expand Up @@ -181,14 +188,12 @@ contract inputSettlerEscrowTestBaseLIFI is InputSettlerEscrowTest {

InputSettlerBase.SolveParams[] memory solveParams = new InputSettlerBase.SolveParams[](1);
solveParams[0] = InputSettlerBase.SolveParams({
timestamp: uint32(block.timestamp),
solver: bytes32(uint256(uint160((solver))))
timestamp: uint32(block.timestamp), solver: bytes32(uint256(uint160((solver))))
});

vm.prank(solver);
InputSettlerEscrowLIFI(inputSettlerEscrow).finalise(
order, solveParams, bytes32(uint256(uint160((solver)))), hex""
);
InputSettlerEscrowLIFI(inputSettlerEscrow)
.finalise(order, solveParams, bytes32(uint256(uint160((solver)))), hex"");
vm.snapshotGasLastCall("inputSettler", "escrowFinaliseSelfWithFee");

uint256 govFeeAmount = (amount * fee) / 10 ** 18;
Expand Down
14 changes: 6 additions & 8 deletions test/integration/InputSettler7683LIFI.samechain.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract InputSettlerEscrowSameChainSwapTest is InputSettlerEscrowTestBase {
token: bytes32(uint256(uint160(address(anotherToken)))),
amount: amount2,
recipient: bytes32(uint256(uint160(swapper))),
call: hex"",
callbackData: hex"",
context: hex""
});
uint256[2][] memory inputs1 = new uint256[2][](1);
Expand All @@ -87,7 +87,7 @@ contract InputSettlerEscrowSameChainSwapTest is InputSettlerEscrowTestBase {
token: bytes32(uint256(uint160(address(token)))),
amount: amount1,
recipient: bytes32(uint256(uint160(swapper2))),
call: hex"",
callbackData: hex"",
context: hex""
});
uint256[2][] memory inputs2 = new uint256[2][](1);
Expand Down Expand Up @@ -119,9 +119,8 @@ contract InputSettlerEscrowSameChainSwapTest is InputSettlerEscrowTestBase {
bytes memory dataToForward = abi.encode(signature2, orderid1, order1, orderid2, order2);

// Notice! This test will continue in inputs filled.
InputSettlerEscrowLIFI(inputSettlerEscrow).openForAndFinalise(
order1, order1.user, signature1, address(this), dataToForward
);
InputSettlerEscrowLIFI(inputSettlerEscrow)
.openForAndFinalise(order1, order1.user, signature1, address(this), dataToForward);

assertEq(token.balanceOf(address(swapper)), 0);
assertEq(anotherToken.balanceOf(address(swapper2)), 0);
Expand All @@ -148,9 +147,8 @@ contract InputSettlerEscrowSameChainSwapTest is InputSettlerEscrowTestBase {
assertEq(anotherToken.balanceOf(address(swapper2)), amount2);

// Notice! The test will continue after "} else {"
InputSettlerEscrowLIFI(inputSettlerEscrow).openForAndFinalise(
order2, order2.user, signature2, address(this), dataToForward
);
InputSettlerEscrowLIFI(inputSettlerEscrow)
.openForAndFinalise(order2, order2.user, signature2, address(this), dataToForward);
} else {
(, bytes32 orderid1, StandardOrder memory order1, bytes32 orderid2, StandardOrder memory order2) =
abi.decode(dataToForward, (bytes, bytes32, StandardOrder, bytes32, StandardOrder));
Expand Down
5 changes: 4 additions & 1 deletion test/lib/RegisterIntentLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ contract RegisterIntentLibTest is InputSettlerCompactTestBase {

event IntentRegistered(bytes32 indexed orderId, StandardOrder order);

function test_depositFor(address depositor, address user) public {
function test_depositFor(
address depositor,
address user
) public {
vm.assume(depositor != address(0));
vm.assume(user != address(0));
vm.assume(depositor != address(inputSettlerCompact));
Expand Down