---
description: >-
  Events are a special recording mechanism used to broadcast specific events or
  messages during the execution of smart contracts.
---

# Events

In this section, we will introduce all Events related to Dyson Finance, which allows smart contracts to interact with external applications, such as decentralized applications (dApps)

## Pair Factory

### PairCreated Event

This event will be emitted after the Factory [creates a Pair](../pairfactory#createpair) for dual investment and DEX.

```solidity
event PairCreated(address indexed token0, address indexed token1, uint id, address pair);
```

<table><thead><tr><th width="162">Arguments</th><th width="222">Type</th><th>Description</th></tr></thead><tbody><tr><td>token0</td><td>address indexed</td><td>Sorted tokens index 0*</td></tr><tr><td>token1</td><td>address indexed</td><td>Sorted tokens index 1*</td></tr><tr><td>id</td><td>uint</td><td>The index for Pairs with the same token0-token1 pair</td></tr><tr><td>pair</td><td>address</td><td>The address of created Pair </td></tr></tbody></table>

\[token0, token1]\*:  `token0` and `token1` are terms used to represent the two tokens in a trading pair. These tokens are sorted according to their addresses to ensure consistency and avoid ambiguity.

## Pairs

### Swap Event

The Pair represents a DEX trading pair. This event will be emitted when a user attempts to [swap](../pair#swap0in-1) tokens within the trading pair.

```solidity
event Swap(address indexed sender, bool indexed isSwap0, uint amountIn, uint amountOut, address indexed to);
```

<table><thead><tr><th width="157">Arguments</th><th width="184">Type</th><th>Description</th></tr></thead><tbody><tr><td>sender</td><td>address indexed</td><td><code>msg.sender</code> who trigger the fuctioin. ex: <code>Router</code></td></tr><tr><td>isSwap0</td><td>bool indexed</td><td>Indicate the swap input token type. if<code>token0</code>, <code>isSwap0</code> will be <code>true</code></td></tr><tr><td>amountIn</td><td>uint</td><td>Swap input amount of input type. Including decimals*</td></tr><tr><td>amountOut</td><td>uint</td><td>The result after the swap is processed. Including decimals*</td></tr><tr><td>to</td><td>address indexed</td><td>The address that receives the swap result</td></tr></tbody></table>

including decimals\*: ex: 1000000 amount in USDC represents 1 USDC

### Deposit Event

The Pair represents a Dual Investment pair. This event will be emitted when a user attempts to [deposit](../../guides/integration-of-dual-investment/perfrom-a-dual-investment-deposit) tokens to the pair.

```solidity
event Deposit(address indexed user, bool indexed isToken0, uint index, uint amountIn, uint token0Amt, uint token1Amt, uint due);
```

<table><thead><tr><th width="164">Arguments</th><th width="171">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td><code>user</code> who could claim this position</td></tr><tr><td>isToken0</td><td>bool indexed</td><td>Indicate the deposit input token type. if<code>token0</code>, <code>isToken0</code> will be <code>true</code></td></tr><tr><td>index</td><td>uint</td><td>The <a href="../../../guides/integration-of-dual-investment#concept-of-deposit-and-withdraw">Note</a> index of this deposit action.</td></tr><tr><td>amountIn</td><td>uint</td><td>Deposit input amount of input type. Including decimals* </td></tr><tr><td>token0Amt</td><td>uint</td><td>The potential position ampount in token0 that the user may receive upon expiration.  Including decimals*</td></tr><tr><td>token1Amt</td><td>uint</td><td>The potential position amount in token1 that the user may receive upon expiration. Including decimals*</td></tr><tr><td>due</td><td>uint</td><td>The Unix timestamp represents the time when the user can claim the position.</td></tr></tbody></table>

including decimals\*: ex: 1000000 amount in USDC represents 1 USDC

### Withdraw Event

This event will be emitted when a user attempts to [withdraw](../pair#withdraw-1) a note of a pair.

```solidity
event Withdraw(address indexed user, bool indexed isToken0, uint index, uint amountOut);
```

<table><thead><tr><th width="163">Arguments</th><th width="165">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td><code>user</code> who own the claimed position</td></tr><tr><td>isToken0</td><td>bool indexed</td><td>The claimed token type for withdrawal. If the output token is of type token0, then isToken0 will be set to true.</td></tr><tr><td>index</td><td>uint</td><td>The <a href="../../../guides/integration-of-dual-investment#concept-of-deposit-and-withdraw">Note</a> index of this withdraw action.</td></tr><tr><td>amountOut</td><td>uint</td><td>The position claimed amount. Including decimals*</td></tr></tbody></table>

including decimals\*: ex: 1000000 amount in USDC represents 1 USDC

### ApprovalForAll Event

This event will be emitted after a user[ sets operatorApprovals](../pair#setapprovalforallwithsig) permission.

```solidity
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
```

<table><thead><tr><th width="156">Arguments</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>address indexed</td><td>Target user address who delegate control of their Note to the operator.</td></tr><tr><td>operator</td><td>bool indexed</td><td>Address that delegates authority to control the <code>owner</code>'s Note.</td></tr><tr><td>approved</td><td>bool</td><td>The permissin is set approved (<code>true</code>) or not.</td></tr></tbody></table>

## Agency

### Register Event

When new users want to create a new membership, this event will be emitted.

```solidity
event Register(uint indexed referrer, uint referee);
```

<table><thead><tr><th width="152">Arguments</th><th width="196">Type</th><th>Description</th></tr></thead><tbody><tr><td>referrer</td><td>uint indexed</td><td>Referrer id in map <code>agents</code>, could use to retrieve referrer's  <code>Agent</code></td></tr><tr><td>referee</td><td>uint</td><td>The new user id in map <code>agents</code>, could use to retrieve new user's <code>Agent</code></td></tr></tbody></table>

{% hint style="info" %}
Membership(AgentNFT) is transferable through Agency [transfer](../membership/agency#transfer) or AgenctNFT [transfer](../membership/agentnft#safetransferfrom).\
Do not rely solely on Register events to construct the membership tree.
{% endhint %}

## Farm

There are two types of pools to help Farm generate Points for users, please review our [other documen](https://docs.dyson.finance/mechanisms/token-incentive#point-calculation)t to understand how to grant Points.

### Rate Updated Event

When an action affects two types of "Points" pools on Farm this event will be emitted.

```solidity
event RateUpdated(address indexed poolId, uint rewardRate, uint weight);
```

<table><thead><tr><th width="169">Arguments</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>poolId</td><td>address indexed</td><td>The Pair Address or Farm Address. <br>Which can be used to retrieve the Pool structure from the pools map. <br>If the address is associated with a Farm, it indicates that the global pool is being updated.<br>If the address is associated with a Pair, it indicates that the local pool is being updated.</td></tr><tr><td>rewardRate</td><td>uint</td><td>Updated RewardRate<br>Decimals: 18</td></tr><tr><td>weight</td><td>uint</td><td>Updated Weight<br>Decimals: 18</td></tr></tbody></table>

### Grant Points Event

When the user [deposits](../pair#deposit0) on Dual Investment Pair and triggers Farm to [grant sp](../staking-and-yield-boosting/farm#grantsp) this event will be emitted.

```solidity
event GrantSP(address indexed user, address indexed poolId, uint amountIn, uint amountOut);
```

<table><thead><tr><th width="162">Arguments</th><th width="208">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>Address which will receive the Points</td></tr><tr><td>poolId</td><td>address indexed</td><td>The dual investment pair address</td></tr><tr><td>amountIn</td><td>uint</td><td>Amount of  a internal used parameters "localSP"<br>Decimals: 18</td></tr><tr><td>amountOut</td><td>uint</td><td>Amount of Points with 18 decimals</td></tr></tbody></table>

### Swap Points to $DYSN Event

When the user [swaps](../staking-and-yield-boosting/farm#swap) anyone's Points to DYSN this event will be emitted.

```solidity
event Swap(address indexed user, address indexed parent, uint amountIn, uint amountOut);
```

<table><thead><tr><th width="163">Arguments</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>The address that spends its own Points to exchange for DYSN.</td></tr><tr><td>parent</td><td>address indexed</td><td>The parent who could get 1/3 Points commission.</td></tr><tr><td>amountIn</td><td>uint</td><td>Spent Points amounts for DYSN<br>Decimals: 18</td></tr><tr><td>amountOut</td><td>uint</td><td>The DYSN amounts <code>user</code> received<br>Decimals: 18</td></tr></tbody></table>



## Staking (sDYSN)

### Stake Event

When the user [stakes](../../../guides/stake-your-usddysn-for-usdsdysn#executing-a-stake) $DYSN to get $sDYSN this event will be emitted.

```solidity
event Stake(address indexed vaultOwner, address indexed depositor, uint amount, uint sDysonAmount, uint time);
```

<table><thead><tr><th width="179">Arguments</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultOwner</td><td>address indexed</td><td>The address that received $sDYSN and voting power, and owns the position.</td></tr><tr><td>depositor</td><td>address indexed</td><td>The address which deposit $DYSN (msg.sender)</td></tr><tr><td>amount</td><td>uint</td><td>The amount of $DYSN staked this time.<br>Decimals: 18</td></tr><tr><td>sDysonAmount</td><td>uint</td><td>The amount of $sDYSN minted this time.<br>Which is equal to the additional voting power the vault owner gets.<br>Decimals: 18</td></tr><tr><td>time</td><td>uint</td><td>The lock duration from now for this $DYSN position.<br>unit: secounds</td></tr></tbody></table>

### Restake Event

When the user [restake](../staking-and-yield-boosting/sdyson#restake) $DYSN to get $sDYSN this event will be emitted.

```solidity
event Restake(address indexed vaultOwner, uint index, uint dysonAmountAdded, uint sDysonAmountAdded, uint time);
```

<table><thead><tr><th width="223">Arguments</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultOwner</td><td>address indexed</td><td>The address that received $sDYSN and voting power, and owns the position.</td></tr><tr><td>index</td><td>uint</td><td>The vaults index to indicate which position was updated<br><code>vaults[vaultOwner][indx]</code></td></tr><tr><td>dysonAmountAdded</td><td>uint</td><td>The amount of $DYSN staked this time.<br>Decimals: 18</td></tr><tr><td>sDysonAmountAdded</td><td>uint</td><td>The amount of $sDYSN minted this time.<br>Which is equal to the additional voting power the vault owner gets.<br>Decimals: 18</td></tr><tr><td>time</td><td>uint</td><td>The lock duration from now for this $DYSN position.<br>unit: secounds</td></tr></tbody></table>

### Unstake Position Event

When the user [redeems](../staking-and-yield-boosting/sdyson#unstake) $DYSN from staking vaults this event will be emitted.

```solidity
event Unstake(address indexed vaultOwner, address indexed receiver, uint amount, uint sDysonAmount);
```

<table><thead><tr><th width="163">Arguments</th><th width="157">Type</th><th>Description</th></tr></thead><tbody><tr><td>vaultOwner</td><td>address indexed</td><td>The address that owns the position.</td></tr><tr><td>receiver</td><td>address indexed</td><td>Address that will receive $DYSN</td></tr><tr><td>amount</td><td>uint</td><td>The amount of $DYSN unstaked this time.<br>Decimals: 18</td></tr><tr><td>sDysonAmount</td><td>uint</td><td>The amount of $sDYSN burned this time.<br>Which is equal to the  reduction in the voting power of the vault owner.<br>Decimals: 18</td></tr></tbody></table>



## Gauge Factory

### Gauge Created Event

This event is emitted when a new Gauge is created, indicating the link from the new Gauge to the existing Pair.

```solidity
event GaugeCreated(address indexed poolId, address gauge);
```

<table><thead><tr><th width="150">Arguments</th><th width="157">Type</th><th>Description</th></tr></thead><tbody><tr><td>poolId</td><td>address indexed</td><td>Pair contract address link to new deployed Gauge contract.</td></tr><tr><td>gauge</td><td>address</td><td>New deployed Gauge contract address</td></tr></tbody></table>



## Gauge

### $sDYSN Deposit Event

This event is emitted when an address[ deposits](../staking-and-yield-boosting/gauge#deposit) $sDYSN to a Gauge

```solidity
event Deposit(address indexed user, address depositor, uint indexed week, uint amount);
```

<table><thead><tr><th width="153">Arguments</th><th width="159">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>Owner of this deposit position</td></tr><tr><td>depositor</td><td>address</td><td>Address that deposit $sDYSN (msg.sender)</td></tr><tr><td>week</td><td>uint indexed</td><td>The week* in which this deposit position was added</td></tr><tr><td>amount</td><td>uint</td><td>Added $sDYSN Amount<br>Decimals: 18</td></tr></tbody></table>

week\*: It's the i-th week since 1970/01/01

### $sDYSN Apply Withdrawal Event

This event is emitted when an address[ applies to withdraw ](../staking-and-yield-boosting/gauge#applywithdrawal)$sDYSN from a Gauge.

```solidity
event ApplyWithdrawal(address indexed user, uint indexed week, uint amount);
```

<table><thead><tr><th width="156">Arguments</th><th width="184">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>Owner of this deposit position (msg.sender)</td></tr><tr><td>week</td><td>uint indexed</td><td>The week* in which this position amount was removed</td></tr><tr><td>amount</td><td>uint</td><td>This applies to withdrawing the $sDYSN amount<br>Decimals: 18</td></tr></tbody></table>

week\*: It's the i-th week since 1970/01/01

### $sDYSN Withdraw Event

This event is emitted when an address [withdraws](../staking-and-yield-boosting/gauge#withdraw) its pending $sDYSN from a Gauge.

```solidity
event Withdraw(address indexed user, uint amount);
```

<table><thead><tr><th width="157">Arguments</th><th width="187">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>Owner of this pending withdrawal position (msg.sender)</td></tr><tr><td>amount</td><td>uint</td><td><p>The amount of $sDYSN received by the user</p><p>Decimals: 18</p></td></tr></tbody></table>

## Bribe Factory

### Bribe Created Event

This event is emitted when a new Bribe is created and indicates the link to the gauge.

```solidity
event BribeCreated(address indexed gauge, address bribe);
```

<table><thead><tr><th width="139">Arguments</th><th width="183">Type</th><th>Description</th></tr></thead><tbody><tr><td>gauge</td><td>address indexed</td><td>Gauge contract address link to new deployed Bribe contract.</td></tr><tr><td>bribe</td><td>address</td><td>New deployed Bribe contract address</td></tr></tbody></table>

## Bribe

### Add Rewards Event

When someone [adds rewards](../fee-and-reward-distribution/bribe#addreward) to Bribe for users who deposit in Gauge this event will be emitted.

```solidity
event AddReward(address indexed from, address indexed token, uint indexed week, uint amount);
```

<table><thead><tr><th width="138">Arguments</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td>from</td><td>address indexed</td><td>The address that deposit token rewards (msg.sender)</td></tr><tr><td>token</td><td>address indexed</td><td>The added reward token address</td></tr><tr><td>week</td><td>uint indexed</td><td>The week* to add the reward to. </td></tr><tr><td>amount</td><td>uint</td><td>The amount of added reward tokens.<br>Decimals: by token</td></tr></tbody></table>

week\*: It's the i-th week since 1970/01/01

### Claim Rewards Event

When users [claim](../fee-and-reward-distribution/bribe#claimreward-1) rewards from Bribe this event will be emitted.

```solidity
event ClaimReward(address indexed user, address indexed token, uint indexed week, uint amount);
```

<table><thead><tr><th width="149">Arguments</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td>user</td><td>address indexed</td><td>The address that claimed and received the token rewards (msg.sender).</td></tr><tr><td>token</td><td>address indexed</td><td>The claimed reward token address</td></tr><tr><td>week</td><td>uint indexed</td><td>The week* to claim the reward from. </td></tr><tr><td>amount</td><td>uint</td><td>The amount of claimed reward tokens.<br>Decimals: by token</td></tr></tbody></table>

week\*: It's the i-th week since 1970/01/01
