> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mystockline.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# CreatorFeeRouter

> CreatorFeeRouter receives STK creator fees from Pons in ETH and turns them into supplier yield.

CreatorFeeRouter receives STK creator fees from Pons in ETH and turns them into supplier yield. Anyone can call `sweep`, which wraps ETH, sells it for USDG along the WETH zap route, and routes the USDG. Below \$100k of pool assets every dollar is donated to USDGPool. At or above that, 30% is donated, 40% goes to the FeeCollector reserve, and 30% to the treasury. The contract must be the pool's `yieldDistributor` and has no withdraw function.

`CreatorFeeRouter` lets you:

* Convert accumulated ETH and WETH creator fees to USDG
* Donate USDG to sUSDG holders during bootstrap
* Split USDG between pool, reserve, and treasury after the TVL trigger

Addresses per network. Every address is also on [Addresses](/resources/addresses).

| Network                 | Address                                                                                                                                       |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Robinhood Chain testnet | [0x83Ca3613B4567171Cd766714366d1793B67B1e10](https://explorer.testnet.chain.robinhood.com/address/0x83Ca3613B4567171Cd766714366d1793B67B1e10) |

The source code is [`src/token/CreatorFeeRouter.sol`](https://github.com/stockline-xyz/contracts/blob/main/src/token/CreatorFeeRouter.sol) on GitHub. The ABI is [`/abis/CreatorFeeRouter.json`](/abis/CreatorFeeRouter.json).

## Write methods

### sweep

```solidity theme={"system"}
function sweep() external nonReentrant
```

Wraps any ETH balance, swaps the full WETH balance to USDG along the registry's WETH route with the registry slippage cap, then routes all USDG held. Below `tvlTrigger` everything is donated to the pool. Otherwise 30% is donated, 30% is credited to treasury, and the remainder (40%) to reserve. Permissionless. Reverts with InvalidRoute if WETH has no allowed route to USDG and ZeroAmount if no USDG results.

<Note>
  The TVL check happens before this sweep's donation, so a pool just under the trigger still receives the full amount.
</Note>

## Events

### Swept

```solidity theme={"system"}
event Swept(
    uint256 ethIn,
    uint256 usdgOut,
    uint256 donated,
    uint256 toReserve,
    uint256 toTreasury
)
```

Fires on every sweep with the ETH in, USDG out, and the split into donated, reserve, and treasury.

## Errors

### ZeroAddress

```solidity theme={"system"}
error ZeroAddress()
```

A constructor address was zero, or the registry has no DEX router.

### NotDistributor

```solidity theme={"system"}
error NotDistributor()
```

The pool's yieldDistributor is not this contract at deployment.

### ZeroAmount

```solidity theme={"system"}
error ZeroAmount()
```

The swap returned 0 or no USDG was available to route.

### InvalidRoute

```solidity theme={"system"}
error InvalidRoute()
```

WETH has no allowed route ending in USDG.

### AssetMismatch

```solidity theme={"system"}
error AssetMismatch()
```

The FeeCollector's USDG or pool does not match the pool at deployment.
