Skip to content

Commit

Permalink
added solmate eth transfer (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
aadams authored Jun 9, 2023
1 parent b4dec0b commit 633a639
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 9 additions & 5 deletions contracts/libraries/CurrencyLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ library CurrencyLibrary {
Currency public constant NATIVE = Currency.wrap(address(0));

function transfer(Currency currency, address to, uint256 amount) internal {
// implementation from
// https://github.com/Rari-Capital/solmate/blob/3c738133a0c1697096d63d28ef7a8ef298f9af6b/src/utils/SafeTransferLib.sol

bool success;
if (currency.isNative()) {
(bool success,) = to.call{value: amount}("");
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}

if (!success) revert NativeTransferFailed();
} else {
// implementation from
// https://github.com/Rari-Capital/solmate/blob/3c738133a0c1697096d63d28ef7a8ef298f9af6b/src/utils/SafeTransferLib.sol
bool success;

assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
Expand Down
18 changes: 9 additions & 9 deletions test/__snapshots__/PoolManager.gas.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -136,63 +136,63 @@ Object {
exports[`PoolManager gas tests Native Tokens #mint above current price add to position existing 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 150738,
"gasUsed": 150676,
}
`;

exports[`PoolManager gas tests Native Tokens #mint above current price new position mint first in range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 210480,
"gasUsed": 210419,
}
`;

exports[`PoolManager gas tests Native Tokens #mint above current price second position in same range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 150738,
"gasUsed": 150676,
}
`;

exports[`PoolManager gas tests Native Tokens #mint around current price add to position existing 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 202461,
"gasUsed": 202400,
}
`;

exports[`PoolManager gas tests Native Tokens #mint around current price new position mint first in range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 312077,
"gasUsed": 312016,
}
`;

exports[`PoolManager gas tests Native Tokens #mint around current price second position in same range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 202461,
"gasUsed": 202400,
}
`;

exports[`PoolManager gas tests Native Tokens #mint below current price add to position existing 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 163874,
"gasUsed": 163812,
}
`;

exports[`PoolManager gas tests Native Tokens #mint below current price new position mint first in range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 291524,
"gasUsed": 291462,
}
`;

exports[`PoolManager gas tests Native Tokens #mint below current price second position in same range 1`] = `
Object {
"calldataByteLength": 260,
"gasUsed": 163874,
"gasUsed": 163812,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/PoolManager.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`PoolManager bytecode size 1`] = `26364`;
exports[`PoolManager bytecode size 1`] = `26295`;

0 comments on commit 633a639

Please sign in to comment.