Skip to main content

Call

Icon

Call_image1+1.png

Function

The Call component allows a subject to reuse its independent passive processes.

Tip

Here, the subject can be the Global Observer, Individuals in an Entity, or the Entity Observer.

Key Points

Tip

Just like functions in programming, you can model common behaviors as independent passive processes. This makes it easy to reuse these processes in different scenarios.

Example

For example, a DeFi algorithm arbitrageur has three independent passive behaviors: A Buy/Sell Tokens, B Mint Stablecoin, and C Redeem Stablecoin. We can easily construct various trading strategies for the arbitrageur through calling behaviors, avoiding redundant modeling.

  • Positive Deviation Arbitrage (A-B-A): If the current price is above $1, first call A to buy protocol tokens, then call B to mint stablecoins, and finally call A to sell the stablecoins.
  • Negative Deviation Arbitrage (A-C-A): If the price is below $1, first call A to buy stablecoins, then call C to redeem them for protocol tokens at face value, and finally call A again to sell the protocol tokens.

Usage Conditions

For a process to be called, it must meet the following conditions:

  • It should be a passive behavior.
  • It should be independent (not a sub-process).
  • It should either belong to the same entity or share the same higher entity.
Tips
  • Global passive processes can be called within the global processes.
  • Global passive processes can also be called within the processes of entities.
  • Passive processes of the observer can be called within the individual processes, while the observer and the individuals belong to the same population, but not vice versa.
  • Passive processes of the individuals, the observer, and the global can be called within a subprocess of individual processes within an entity.
  • The difference between Call and Ask to Call is that Ask to Call is used for processes of different subjects, while Call is specific to the same subject.

Data passing

If the called process has interfaces, the calling component will show the corresponding ports. Data passing methods are explained in the Process Interfaces and Data Passing chapter.

Setup Methods

Call_image2.png

Select the Calling Object

  • Click the dropdown menu to select the process you want to call. Only the processes that can be called will be displayed in the dropdown menu.

  • Jump to the original object

    After selecting, click the button on the right side of the dropdown to focus the canvas view on the target process.

    Call_image3.png

Pass Port Parameter Value

  • If the called process has variable interfaces, the calling component will present variable ports.

    Call_image4.png

  • Data can be passed to the port in two ways:

    • Pass values via expressions.

      Call_image5.png

    • Pass data objects via State Links.

      Call_image6.png

    • The system will prioritize the second method. In this case, the parameter field in the calling object's properties panel will be disabled.

      Call_image7.png

  • If no specific data is passed:

    • For container interfaces, an error will occur during runtime if the called process uses the interface.

    • For variable interfaces, the system will use the default value of the interface, which is the initial value set for the corresponding data object in the called process, as shown in the figure below.

      Call_image8.png

Tip

For more information on passing data to process ports, please refer to the Process Interfaces and Data Passing chapter.

Data Output

  • Port Data
    • In the formula after this component action, it can be accessed in the form of This.port_name.
    • In the calculation of the subsequent objects of this process, it can be accessed in the form of call_component_name.port_name.

Example

Model Example: Token Exchange in Web3

The Go process calls the to Trade passive process to exchange USDC and ETH tokens between WalletA and Pool at the Exchange Rate.