> For the complete documentation index, see [llms.txt](https://docs.evently.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.evently.market/smart-contracts/profiles.md).

# EventlyProfiles.sol v1.3

**Address:** `0x9F0708145BCCD1F5B16F610cB8a75A63fA4A9a24` **Version:** v1.3

***

## Constants

| Constant                        | Value      | Description                                               |
| ------------------------------- | ---------- | --------------------------------------------------------- |
| `MIN_USERNAME_LENGTH`           | 3          | Min username chars                                        |
| `MAX_USERNAME_LENGTH`           | 20         | Max username chars                                        |
| `LEADERBOARD_SIZE`              | 10         | Top N tracked onchain                                     |
| `REFERRAL_ACTIVATION_THRESHOLD` | 1 USDm     | Min prediction market trading volume to activate referral |
| `SWAP_POINTS_PER_USD_CENT`      | 5          | Points per $0.01 swapped                                  |
| `SWAP_COOLDOWN`                 | 30 seconds | Min delay between swap records                            |

***

## Profile Struct

```solidity
struct Profile {
    string username;
    uint256 swapVolumeUsd;    // Lifetime swap volume in USD cents
    uint256 swapPoints;       // Points earned from swaps
    uint256 tradePoints;      // Points earned from prediction market trades
    address referrer;         // Referrer address
    uint256 referralEarnings; // Total USDm earned via referrals
}
```

***

## Profile Creation

| Function                                                | Cost | Description                              |
| ------------------------------------------------------- | ---- | ---------------------------------------- |
| `createProfile(username, referrerUsername)`             | Free | Standard profile creation                |
| `createProfileWithPromo(username, referrer, promoCode)` | Free | Valid community code grants bonus points |

Profiles are **free for everyone**. Community codes grant a points bonus on creation.

Referrers are passed by **username** (not address). If the username doesn't resolve, it is silently ignored — no revert.

***

## Key Functions

### Called by Protocol Contracts

| Function                                           | Description              |
| -------------------------------------------------- | ------------------------ |
| `creditReferral(address referred, uint256 amount)` | Credits referrer balance |
| `referrerOf(address)`                              | Returns referrer address |

### User-Facing

| Function                     | Description                                             |
| ---------------------------- | ------------------------------------------------------- |
| `claimReferralEarnings()`    | Withdraw referral earnings                              |
| `recordSwap(volumeUsdCents)` | Log swap volume, award points (authorized callers only) |
| `getProfile(address)`        | View profile data                                       |
| `getLeaderboard()`           | Returns top 10 addresses + scores                       |

### Admin

| Function                             | Description                      |
| ------------------------------------ | -------------------------------- |
| `setAuthorizedContract(address)`     | Authorize protocol contract      |
| `addPromoCode(code, maxUses)`        | Create community code            |
| `removePromoCode(code)`              | Invalidate a code                |
| `setAuthorizedCaller(address, bool)` | Authorize address for recordSwap |
| `withdrawFees()`                     | Withdraw accumulated fees        |

***

## Events

| Event                | Trigger                          |
| -------------------- | -------------------------------- |
| `ProfileCreated`     | Profile created                  |
| `ReferralRewarded`   | Referral balance credited        |
| `ReferralClaimed`    | User withdraws referral earnings |
| `SwapRecorded`       | Swap volume logged               |
| `WhaleStatusUpdated` | Player marked as whale           |
| `PromoCodeUsed`      | Community code redeemed          |
