Skip to content

Conversation

@chrismaree
Copy link
Member

Adds initial initiateRelayerRefund PR.

mrice32 and others added 6 commits January 25, 2022 16:15
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
Copy link
Member Author

Choose a reason for hiding this comment

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

changes in this file were due to running the linter config.

@chrismaree chrismaree changed the title chrismaree/first pass repayment claim feat(hubpool): Add Initial initiateRelayerRefund implementation Jan 27, 2022
import "./interfaces/BridgeAdminInterface.sol";


contract BridgeAdmin is BridgeAdminInterface {
Copy link
Member

Choose a reason for hiding this comment

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

why not just import this from uma/core?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see that this would be a brand new contract

mapping(address => LPToken) public lpTokens; // Mapping of L1TokenAddress to the associated LPToken.

// Address of L1Weth. Enable LPs to deposit/receive ETH, if they choose, when adding/removing liquidity.
WETH9Like public l1Weth;
Copy link
Member

Choose a reason for hiding this comment

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

in general do we prefer storing contracts as addresses or as interfaces? I stored weth as an address in the SpokePool for example but we should just standardize

Copy link
Member Author

Choose a reason for hiding this comment

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

ye, good point. my main question which should inform this decision is is this more expensive to store? is this more expensive to use?

my main reason for doing it this way is it means you dont need to do any type casting when using the interface which makes things a bit easier.

IERC20 public bondToken;

// The bondToken's final fee from the UMA Store is scaled by this number to increase the bonding amount.
uint256 public bondTokenFinalFeeMultiplier;
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this a uint64?

Copy link
Member

Choose a reason for hiding this comment

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

for context, I use uint64 for all percentage values in spokepool

Copy link
Member Author

Choose a reason for hiding this comment

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

what? you dont want a 2^256-1 * final fee?

Copy link
Member Author

Choose a reason for hiding this comment

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

but ye we can. I'll change the type to uint64

address _bridgeAdmin,
address _bondToken,
uint256 _bondTokenFinalFeeMultiplier,
address _timerAddress
Copy link
Member

Choose a reason for hiding this comment

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

nit: group similar types together

*************************************************/

function setBondToken(address _bondToken) public onlyOwner {
bondToken = IERC20(_bondToken);
Copy link
Member

Choose a reason for hiding this comment

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

These should emit events since they change state

status: RefundRequestStatus.Pending
})
);
uint256 relayerRefundId = relayerRefundRequests.length - 1;
Copy link
Member

Choose a reason for hiding this comment

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

int: should the ID be a smaller type like uint64?

Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

LGTM i agree with the structure but have nits on types

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

LGTM! A few minor comments

emit BondTokenSet(newBondToken);
}

function setBondTokenFinalFeeMultiplier(uint64 newBondTokenFinalFeeMultiplier) public onlyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting. I totally get the rationale: it's easier to just set the final fees and have this move around as a result since they're kinda a valuation anchor, but do you think this is weird in that it relies on internal UMA system variables for setting its own security bounds? Like if the UMA voting system changed and spam were less of a concern, so final fees were dropped by 95%, we probably wouldn't want this value to change as a result, right?

It's also not super hard to manage this since it's only one bond and one token for the entire Across v2 system.

As a side note: this also means that we need to be sure that the bond token is an approved UMA collateral currency.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is all true! would you prefer it to simply have one number that is set within the contract and we don't pull anything from the store? my logic was that the store is a reasnoble bond size that can be scaled. we can easily just define one number in this contract that sets the bond for everything

Copy link
Member Author

Choose a reason for hiding this comment

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

OK I've changed this. we now have a bondAmount that the owner can set. much cleaner

Copy link
Member

Choose a reason for hiding this comment

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

agreed with this, its cleaner and in the same spirit of the UMA final fee

);

// Pull bonds from from the caller.
bondToken.safeTransferFrom(msg.sender, address(this), bondAmount);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is annoying, but how do we deal with a changing bond amount mid-refund? I know this code is to pull the bond, but do you think we need to store the bond amount for each refund request?

Copy link
Member Author

@chrismaree chrismaree Jan 27, 2022

Choose a reason for hiding this comment

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

just dont change it if there is a pending refund I guess. if we set the bond as a variable directly (not using the store) this becomes easier.

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
@chrismaree chrismaree merged commit 448680b into master Jan 27, 2022
@chrismaree chrismaree deleted the chrismaree/first-pass-repayment-claim branch January 27, 2022 23:41
pxrl added a commit that referenced this pull request Feb 7, 2024
This was renamed in all other events and function prototypes, but it
appears to have been missed here. Having it named relayer rather than
exclusiveRelayer creates friction when unpacking the event in the sdk.

This PR has already been merged into the public contracts-v2; I'm 
cherry-picking it here for consistency.
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.

4 participants