DEX 合约间依赖 (DEX Inter—Contract Dependencies)

To ensure deterministic outcome, we ask contract developers to explicitly specify what other contract dependencies their contract has, during registration with the DEX module. Contract A is considered to depend on contract B if the response of any of contract A's sudo calls may contain order placement/cancellation messages to contract B. For example, a perp contract might need to place orders on a spot contract during its own order placement process to support features like multi-collateral. In that case, the perp contract will need to specify its dependency on the spot contract. The CLI syntax to register a contract with dependencies is as follow:

为了保证确定性的结果,我们要求合约开发人员在向 DEX 模块注册期间明确指定他们的合约具有哪些其他合约依赖项。 如果合约A的任何响应 sudo 调用可能包含对合约B的下单/取消消息,则合约A被视为依赖于合约B。例如,永续合约可能需要在其自己的下单过程中对现货合约下订单,以支持多抵押等功能。在这种情况下,永久合约将需要指定其对现货合约的依赖。使用依赖项注册合约的 CLI 语法如下:

seid tx dex register-contract [contract address] [code id] \
    [need hook] [need order matching] [dependency1,dependency2,...]

In the above perp-spot example, assuming perp's address is sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m and spot's address is sei1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq8un0p6, the CLI to register perp would be:

在上面的 perp-spot 示例中,假设永续合约的地址是 sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m 并且现货的地址是 sei1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8fapq8un06,CLI 将注册:

seid tx dex register-contract sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m \
    1 true true sei1fzm6gzyccl8jvdv3qq6hp9vs6ylaruervs4m06c7k0ntzn2f8faq8un0p6

Note that the registration is an upsert operation, so registering the same contract multiple times will update its registration information.

注意注册是一个合并(upsert)操作,所以多次注册同一个合约会更新它的注册信息。

循环依赖 (Circular Dependency)

Circular dependency is not allowed and will be rejected if detected upon contract registration. For example, if contract A is already registered to depend on contract B, then a registration of contract B that specifies contract A as a dependency will fail.

不允许循环依赖,如果在合约注册时检测到,将被拒绝。例如,如果合约A已经注册为依赖于合约B,那么将合约A指定为依赖项的合约B的注册将失败。

最后更新于