ava-labs / teleporter-token-bridge

Token bridging cross-chain built on top of Teleporter
Other
10 stars 4 forks source link

Register Destination (M-01) #108

Closed michaelkaplan13 closed 3 weeks ago

michaelkaplan13 commented 4 weeks ago

Why this should be merged

Introduces a new required step for destination contracts to "register" with their token source contracts. Token source contracts will now only allow sending to registered destinations. This provides a guardrail that prevents accidental locking of tokens in the bridge contracts if an arbitrary invalid destination contract is provided. In the multi-hop case, if an invalid destination is provided to the source contract, the tokens are sent to a fallback recipient address provided in the message.

How this works

Adds a new RegisterDestinationMessage that all destination contracts send to their configured source contract in their constructor. This message includes the token multiplier information, as well as the initial reserve imbalance of the destination (only non-zero for NativeTokenDestination instances).

As a result of the source contract now knowing the scaling information and initial reserve imbalance, the TeleporterTokenSource now handles the scaling the tokens amount prior to sending messages to a registered destination, and requires sufficient collateral to be added via a new addCollateral function prior to being able to send any bridge events to that respective destination

How this was tested

How is this documented

openzeppelin-code[bot] commented 4 weeks ago

Register Destination (M-01)

Generated at commit: 966718f71e7e9af3b95c2ff05dc322edefc3bf2d

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
3
13
17
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector