bitbankinc / exchangeDepositContract

27 stars 8 forks source link

[Suggestion] EIP-1167: Minimal Proxy Contract #15

Closed luoqeng closed 3 years ago

luoqeng commented 3 years ago

We can further reduce the cost of our solution by using another novel technique called minimal proxy contracts. The minimal proxy contracts allow the deployment of a contract that is an exact copy of another existing contract, but is extremely light-weight to deploy.

https://blog.coinbase.com/usdc-payment-processing-in-coinbase-commerce-b1af1c82fb0#e539

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/cdb929aada14e391576f9fddbe613e026d1abc6b/contracts/proxy/Clones.sol#L43

junderw commented 3 years ago

We need to use CALL for value transactions for event logging purposes.

During the initial spec phase I tried to make it work with that EIP...

But if we only use DELEGATECALL we need to check events for thousands of accounts.

With the current model we only need to check events for one account. (the ExchangeDeposit contract)

If you have a solution to that problem we can consider it.

junderw commented 3 years ago

For the record we've also tried factories that create contracts that automatically selfdestruct themselves after sweeping the tokens, but...

It removes the gain in simplicity from having all ETH deposits for the system emitting events in one place.

(Basically, with those events being in one place it's making deposit detection for ETH just as easy as ERC20. (That Transfer event is so useful, well, we have the same thing for our ETH deposits now))

luoqeng commented 3 years ago

I see, thank you

junderw commented 3 years ago

I would love to hear @bjoveski thoughts on our contract, though.

If we were ERC20 only we probably would have used a system closer to what Coinbase is doing.