Skip to content

Commit d39e157

Browse files
chore: remove Native library (#31)
* chore: remove deprecated strategies and related files * chore: remove Native library --------- Co-authored-by: OneTony <onetony@defi.sucks>
1 parent 8ba1ccb commit d39e157

5 files changed

Lines changed: 13 additions & 41 deletions

File tree

contracts/core/Allo.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {ReentrancyGuardUpgradeable} from
1414
import {IAllo} from "contracts/core/interfaces/IAllo.sol";
1515
import {IRegistry} from "contracts/core/interfaces/IRegistry.sol";
1616
import {Errors} from "contracts/core/libraries/Errors.sol";
17-
import {Native} from "contracts/core/libraries/Native.sol";
1817
import {Transfer} from "contracts/core/libraries/Transfer.sol";
1918
import {Metadata} from "contracts/core/libraries/Metadata.sol";
2019
import {IBaseStrategy} from "strategies/IBaseStrategy.sol";
@@ -38,7 +37,7 @@ import {IBaseStrategy} from "strategies/IBaseStrategy.sol";
3837
/// @author @thelostone-mc <aditya@gitcoin.co>, @0xKurt <kurt@gitcoin.co>, @codenamejason <jason@gitcoin.co>, @0xZakk <zakk@gitcoin.co>, @nfrgosselin <nate@gitcoin.co>
3938
/// @notice This contract is used to create & manage _pools as well as manage the protocol.
4039
/// @dev The contract must be initialized with the 'initialize()' function.
41-
contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, Errors {
40+
contract Allo is IAllo, Initializable, Ownable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, Errors {
4241
using Transfer for address;
4342

4443
// ==========================
@@ -318,7 +317,8 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
318317
/// @param _recipient The recipient
319318
function recoverFunds(address _token, address _recipient) external onlyOwner {
320319
// Get the amount of the token to transfer, which is always the entire balance of the contract address
321-
uint256 _amount = _token == NATIVE ? address(this).balance : IERC20Upgradeable(_token).balanceOf(address(this));
320+
uint256 _amount =
321+
_token == Transfer.NATIVE ? address(this).balance : IERC20Upgradeable(_token).balanceOf(address(this));
322322

323323
// Transfer the amount to the recipient (pool owner)
324324
_token.transferAmount(_recipient, _amount);
@@ -379,7 +379,7 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
379379
if (_amount == 0) revert INVALID();
380380

381381
Pool memory _pool = _pools[_poolId];
382-
if (_pool.token == NATIVE && _amount != msg.value) revert ETH_MISMATCH();
382+
if (_pool.token == Transfer.NATIVE && _amount != msg.value) revert ETH_MISMATCH();
383383

384384
// Call the internal fundPool() function
385385
_fundPool(_amount, _msgSender(), _poolId, _pool.strategy);
@@ -544,8 +544,8 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
544544
// To prevent paying the _baseFee from the Allo contract's balance
545545
// If _token is NATIVE, then _baseFee + _amount should be equal to _msgValue.
546546
// If _token is not NATIVE, then _baseFee should be equal to _msgValue.
547-
if (_token == NATIVE && (_baseFee + _amount != _msgValue)) revert ETH_MISMATCH();
548-
if (_token != NATIVE && _baseFee != _msgValue) revert ETH_MISMATCH();
547+
if (_token == Transfer.NATIVE && (_baseFee + _amount != _msgValue)) revert ETH_MISMATCH();
548+
if (_token != Transfer.NATIVE && _baseFee != _msgValue) revert ETH_MISMATCH();
549549

550550
address(_treasury).transferAmountNative(_baseFee);
551551

@@ -592,7 +592,7 @@ contract Allo is IAllo, Native, Initializable, Ownable, AccessControlUpgradeable
592592

593593
address _token = _pools[_poolId].token;
594594

595-
if (_token == NATIVE && msg.value < _amount) revert ETH_MISMATCH();
595+
if (_token == Transfer.NATIVE && msg.value < _amount) revert ETH_MISMATCH();
596596

597597
if (_feeAmount > 0) {
598598
uint256 _balanceBeforeFee = _token.getBalance(_treasury);

contracts/core/libraries/Native.sol

Lines changed: 0 additions & 25 deletions
This file was deleted.

contracts/strategies/examples/direct-allocation/DirectAllocation.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ pragma solidity ^0.8.19;
55
// Core Contracts
66
import {BaseStrategy} from "strategies/BaseStrategy.sol";
77
// Internal Libraries
8-
import {Native} from "contracts/core/libraries/Native.sol";
98
import {Errors} from "contracts/core/libraries/Errors.sol";
109
import {Transfer} from "contracts/core/libraries/Transfer.sol";
1110

1211
/// @title DirectAllocationStrategy
1312
/// @dev The strategy only implements the allocate logic
1413
/// @notice A strategy that directly allocates funds to a recipient
15-
contract DirectAllocationStrategy is BaseStrategy, Native, Errors {
14+
contract DirectAllocationStrategy is BaseStrategy, Errors {
1615
using Transfer for address;
1716

1817
/// ===============================
@@ -70,7 +69,7 @@ contract DirectAllocationStrategy is BaseStrategy, Native, Errors {
7069
uint256 _totalNativeAmount;
7170
for (uint256 i; i < _recipientsLength; ++i) {
7271
/// Direct allocate the funds
73-
if (_tokens[i] == NATIVE) _totalNativeAmount += _amounts[i];
72+
if (_tokens[i] == Transfer.NATIVE) _totalNativeAmount += _amounts[i];
7473
_tokens[i].transferAmountFrom(_sender, _recipients[i], _amounts[i]);
7574

7675
emit DirectAllocated(_recipients[i], _amounts[i], _tokens[i], _sender);

contracts/strategies/examples/donation-voting/DonationVotingOffchain.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {RecipientsExtension} from "strategies/extensions/register/RecipientsExte
1010
import {AllocationExtension} from "strategies/extensions/allocate/AllocationExtension.sol";
1111
// Internal Libraries
1212
import {Transfer} from "contracts/core/libraries/Transfer.sol";
13-
import {Native} from "contracts/core/libraries/Native.sol";
1413

1514
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
1615
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
@@ -30,7 +29,7 @@ import {Native} from "contracts/core/libraries/Native.sol";
3029
/// @title Donation Voting Strategy with off-chain setup
3130
/// @notice Strategy that allows allocations in multiple tokens to accepted recipient. The actual payouts are set
3231
/// by the pool manager.
33-
contract DonationVotingOffchain is BaseStrategy, RecipientsExtension, AllocationExtension, Native {
32+
contract DonationVotingOffchain is BaseStrategy, RecipientsExtension, AllocationExtension {
3433
using Transfer for address;
3534

3635
/// ===============================
@@ -241,7 +240,7 @@ contract DonationVotingOffchain is BaseStrategy, RecipientsExtension, Allocation
241240

242241
address _recipientAddress = DIRECT_TRANSFER ? _recipients[__recipients[i]].recipientAddress : address(this);
243242

244-
if (_tokens[i] == NATIVE) {
243+
if (_tokens[i] == Transfer.NATIVE) {
245244
_totalNativeAmount += _amounts[i];
246245
} else {
247246
_tokens[i].usePermit(_sender, _recipientAddress, _amounts[i], _permits[i]);

contracts/strategies/examples/donation-voting/DonationVotingOnchain.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {RecipientsExtension} from "strategies/extensions/register/RecipientsExte
1010
import {AllocationExtension} from "strategies/extensions/allocate/AllocationExtension.sol";
1111
// Internal Libraries
1212
import {QFHelper} from "strategies/libraries/QFHelper.sol";
13-
import {Native} from "contracts/core/libraries/Native.sol";
1413
import {Transfer} from "contracts/core/libraries/Transfer.sol";
1514

1615
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
@@ -31,7 +30,7 @@ import {Transfer} from "contracts/core/libraries/Transfer.sol";
3130
/// @title Donation Voting Strategy with qudratic funding tracked on-chain
3231
/// @notice Strategy that allows allocations in a specified token to accepted recipient. Payouts are calculated from
3332
/// allocations based on the quadratic funding formula.
34-
contract DonationVotingOnchain is BaseStrategy, RecipientsExtension, AllocationExtension, Native {
33+
contract DonationVotingOnchain is BaseStrategy, RecipientsExtension, AllocationExtension {
3534
using QFHelper for QFHelper.State;
3635
using Transfer for address;
3736

@@ -135,7 +134,7 @@ contract DonationVotingOnchain is BaseStrategy, RecipientsExtension, AllocationE
135134
emit Allocated(_recipients[i], _sender, _amounts[i], abi.encode(_allocationToken));
136135
}
137136

138-
if (_allocationToken == NATIVE) {
137+
if (_allocationToken == Transfer.NATIVE) {
139138
if (msg.value != _totalAmount) revert ETH_MISMATCH();
140139
} else {
141140
_allocationToken.usePermit(_sender, address(this), _totalAmount, _permitData);

0 commit comments

Comments
 (0)