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

added solmate eth transfer #202

Merged
merged 1 commit into from
Jun 9, 2023
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
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`;