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

Base version #1

Merged
merged 17 commits into from
May 15, 2024
Merged

Base version #1

merged 17 commits into from
May 15, 2024

Conversation

RuslanProgrammer
Copy link
Collaborator

No description provided.

@RuslanProgrammer RuslanProgrammer self-assigned this Apr 4, 2024
@FedokDL FedokDL self-requested a review April 10, 2024 16:01
Comment on lines 8 to 12
address public arbitrumGateway;
address public treasuryAddress;

address public lZEnpointAddress; // L1
uint256 public destinationChainId; // arbitrum
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to move it to the Factory

}

function setFee(address token_, uint256 fee_) external onlyOwner {
_fees[token_] = fee_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that fee less then 100%

_fees[token_] = fee_;
}

function setTreasuryAddress(address treasuryAddress_) external onlyOwner {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTreasury, remove Address at the end

Comment on lines 39 to 47
function setDeployParams(
address arbitrumGateway_,
address lZEnpointAddress_,
uint256 destinationChainId_
) external onlyOwner {
arbitrumGateway = arbitrumGateway_;
lZEnpointAddress = lZEnpointAddress_;
destinationChainId = destinationChainId_;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to factory

contracts/L1/Distribution.sol Show resolved Hide resolved
Pool storage pool = pools[poolId_];
require(pool.isPublic == pool_.isPublic, "DS: invalid pool type");
if (pool_.payoutStart > block.timestamp) {
require(pool.payoutStart != pool_.payoutStart, "DS: invalid payout start value");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pool.payoutStart == pool_.payoutStart

@@ -327,6 +335,12 @@ contract Distribution is IDistribution, OwnableUpgradeable, UUPSUpgradeable {
uint256 overplus_ = overplus();
require(overplus_ > 0, "DS: overplus is zero");

(uint256 feePercent_, address treasuryAddress_) = coreProperties.getFeeAndTreasury(address(this));
uint256 fee_ = _feeAmount(overplus_, feePercent_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint256 fee_ = (amount_ * feePercent_) / PRECISION

uint256 public totalDepositedInPublicPools;

CorePropertiesL1 public coreProperties;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address public feeProperties;

Add it to initialize

address public lZEnpointAddress; // L1
uint256 public destinationChainId; // arbitrum

mapping(address => uint256) private _fees;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseFee
customFee

destinationChainId = destinationChainId_;
}

function getFeeAndTreasury(address distributionAddress_) external view returns (uint256, address) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Check custom fee.
  2. If not exist, return base fee

Comment on lines 29 to 31
address zroPaymentAddress;
uint16 l2EndpointId;
bytes adapterParams;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To DeployConfig


abstract contract BaseFactoryL1 is BaseFactory {
using EnumerableSet for EnumerableSet.AddressSet;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapping(deployer=>bytes name=>DeployedAddresses)
DeployedAddresses {
  distribution: 0x
  l1Sender: 0x
}

@tster
Copy link
Contributor

tster commented Apr 20, 2024

Noticed a typo throughout the codebase - lzEnpointAddress instead of lzEndpointAddress

Occurs in at least 8 places so won't list them all, Ctrl + F should do it!

coreProperties = CorePropertiesL2(coreProperties_);
}

function deployMor20OnL1(Mor20DeployParams calldata parameters_) external onlyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this method be called deployMor20OnL2?

* @param poolType_ the type of the pool.
* @param implementation_ the implementation the pool will point to.
*/
function setImplementation(uint8 poolType_, address implementation_) public onlyOwner {
Copy link
Collaborator

@dovgopoly dovgopoly May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should implementation_ be a beacon?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to do it with ERC1967Proxy to have the chance to remove the upgradability


IL2MessageReceiver(l2MessageReceiver).L2MessageReceiver__init(
mor20,
IL2MessageReceiver.Config(lzExternalDeps.endpoint, address(0), lzExternalDeps.senderChainId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we calculate L1Sender in advance?

lzExternalDeps.adapterParams
);

IL1Sender.DepositTokenConfig memory arbConfig = IL1Sender.DepositTokenConfig(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IL1Sender.DepositTokenConfig memory arbConfig = IL1Sender.DepositTokenConfig(
IL1Sender.DepositTokenConfig memory arbConfig_ = IL1Sender.DepositTokenConfig(


import {IFactory} from "./interfaces/IFactory.sol";

abstract contract Factory is IFactory, OwnableUpgradeable, PausableUpgradeable, UUPSUpgradeable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add method to precalculate address. It should take deployer as a parameter.

Copy link
Collaborator

@dovgopoly dovgopoly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@dovgopoly dovgopoly merged commit f645ea0 into dev May 15, 2024
1 check passed
@dovgopoly dovgopoly deleted the beacon-proxy branch May 15, 2024 10:45
dovgopoly added a commit that referenced this pull request May 20, 2024
* initial version

* Base version (#1)

* Base version

* Added BaseFactory

* Refactored code

* Set CoreProperties upgradeable

* fixes

* refactor logic

* updated

* removed scripts

* Updated package.json

* fixes

* added more tests

* added config

* changed swap params

* changed package-lock.json

* changed package-lock.json

* changed ci

* changed package-lock.json

---------

Co-authored-by: Oleksandr Fedorenko <[email protected]>

* added beacon & refactored (#4)

* added beacon & refactored

* fix event

* typo

* context

* upd enum

* tiny adjustments & cov 100%

* factories dir & isUpgradeable for all pools

* fixed lint

* factory ifaces folder

---------

Co-authored-by: Ruslan Kasheparov <[email protected]>
Co-authored-by: Ruslan Kasheparov <[email protected]>
Co-authored-by: Oleksandr Fedorenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants