Speeding up token connector #569
Replies: 3 comments 4 replies
-
I like this idea a lot and support the plan. Some small problems I see:
|
Beta Was this translation helpful? Give feedback.
-
How about fee handling happens separately on NEAR. Meaning you keep the interface of withdrawal on NEAR side the same as right now. Allows to separate the fee payment into any other asset potentially (or NEAR and ETH to start, which would just increase the user's visible tx fee). Also allows anyone to actually call finalize vs user needing to predetermine who will fast finalize at the sending time. And if no one finalized (no liquidity) - then it will just be automatic finalized in the normal way, as there is no change the default flow. |
Beta Was this translation helpful? Give feedback.
-
We can also skip all together the transfer from NEAR to Ethereum using the bridge, and let the liquidity provider get the fee and the tokens on NEAR side, while providing liquidity on Ethereum side. This can work similar to hashed timelock contracts in the following way. There is a contract X on NEAR with methods: def lock(amount: u64, fee: u64, eth_receipient: EthAddress, locked_time: u64) -> hash:
Lock amount + fee tokens from sender into contract X for locked_time NEAR blocks
Compute unique hash (*)
Store information in the contract
def unlock(hash):
If hash is in memory and more than locked_time NEAR blocks have passed since locked_event
send all locked tokens to the originator of this transaction.
Remove information associated with hash from storage
def claim(hash, proof):
If the proof is a valid (checked against bridge prover), then
amount + fee is sent to account calling this function.
Remove information associated with hash from storage And contract Y on Ethereum with method: def finish_transfer(amount, eth_receipient, hash, near_receipient):
Check hash hasn't been used before, and stores it in memory.
Send amount to eth_receipient
Emit event FinishTransaction(hash, near_receipient) Transferring tokens works in the following way:
Pros:
Cons:
Notes
Passive LPNOTE: This will not work as described automatically, but still this can work with a service running off-chain that verify and signs tx. There can be a passive LP system where a user that wants to provide liquidity puts their funds in a contract Z in Ethereum with the following methods: def provide_liquidity(amount): ...
def remove_liquidity(amount): ...
def finish_transfer(*args):
validate(args)
Y.finish_transfer(*args) In this case, B puts their assets on this contract. Anyone can call finish_transfer, and will get tokens on Ethereum immediately (as long as these tokens are available). It is responsibility for B to be monitoring all calls to this method, and claim tokens on NEAR side. Details of the contract needs to be decided, but if there is a single user operating this, it is straightforward. This approach has the benefit that user A sending tokens from NEAR to Ethereum can do it instantaneously and doesn't depend on an off-chain service (3rd party) to finalise the transaction. In this case fees can be lower, since gas on Ethereum is paid by A rather than by B. |
Beta Was this translation helpful? Give feedback.
-
There's an idea how one can speed up the NEAR->Ethereum transfer for tokens. Here's the principal scheme for this:
withdraw_fast(amount, recipient, fee)
method OR by enforcing a protocol forrecipient
-- if it consists of 20 bytes, then this is a normal withdrawal, otherwise, first 20 bytes is a recipient, next 32 bytes is a fee.finalise_fast_withdraw(receipt_hash, erc20, amount, recipient, fee)
. This method does three things:unlock
is modified in a way that it checks whether the submitted proof contains a receipt hash that was already submitted throughfinalise_fast_withdraw
. In case the data from the receipt corresponds to the data stored during the execution offinalise_fast_withdraw
, the payout is done not to therecipient
, but to the caller offinalise_fast_withdraw
.This enables the following flow:
finalise_fast_withdraw
transaction and transfers tokens to the user.Note: this allows not only for the 1 Ethereum block transfers to Ethereum, but also allows for 1 user interaction transfers.
This approach might remove the urgent need of the realistic bridge.
Beta Was this translation helpful? Give feedback.
All reactions