Ecosystem

Git Source

Inherits:IECOSYSTEM, Initializable, PausableUpgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable

Ecosystem contract handles airdrops, rewards, burning, and partnerships

Implements a secure and upgradeable DAO ecosystem

Notes:

  • security-contact: security@nebula-labs.xyz

  • copyright: Copyright (c) 2025 Nebula Holding Inc. All rights reserved.

State Variables

BURNER_ROLE

AccessControl Burner Role

bytes32 internal constant BURNER_ROLE = keccak256("BURNER_ROLE");

PAUSER_ROLE

AccessControl Pauser Role

bytes32 internal constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

UPGRADER_ROLE

AccessControl Upgrader Role

REWARDER_ROLE

AccessControl Rewarder Role

MANAGER_ROLE

AccessControl Manager Role

MIN_VESTING_DURATION

Minimum required vesting duration (30 days)

MAX_VESTING_DURATION

Maximum allowed vesting duration (10 years)

UPGRADE_TIMELOCK_DURATION

Upgrade timelock duration (3 days)

tokenInstance

governance token instance

rewardSupply

starting reward supply

maxReward

maximal one time reward amount

issuedReward

issued reward

burnedAmount

burned reward amount (tracked separately for transparency)

maxBurn

maximum one time burn amount

airdropSupply

starting airdrop supply

issuedAirDrop

total amount airdropped so far

partnershipSupply

starting partnership supply

issuedPartnership

partnership tokens issued so far

version

number of UUPS upgrades - packed with other variables to save gas

timelock

timelock address for partner vesting cancellations

vestingContracts

Addresses of vesting contracts issued to partners

pendingUpgrade

Pending upgrade information

__gap

Functions

nonZeroAmount

Modifier to check for non-zero amounts

Parameters

Name
Type
Description

amount

uint256

The amount to validate

nonZeroAddress

Modifier to check for non-zero addresses

Parameters

Name
Type
Description

addr

address

The address to validate

constructor

Note: oz-upgrades-unsafe-allow: constructor

receive

Prevents receiving Ether. This contract doesn't handle ETH.

initialize

Initializes the Ecosystem contract with core dependencies and configurations

Sets up the contract with initial token allocations, roles, and limits

Notes:

  • security: Uses initializer modifier to prevent multiple initializations

  • security-roles: Grants the following roles:

  • DEFAULT_ADMIN_ROLE to timelock

  • MANAGER_ROLE to timelock

  • PAUSER_ROLE to timelock

  • UPGRADER_ROLE to both timelock and multisig

  • allocation: Configures token allocations as follows:

  • 26% for rewards

  • 10% for airdrops

  • 8% for partnerships

  • limits: Sets initial limits:

  • maxReward: 0.1% of reward supply

  • maxBurn: 2% of reward supply

  • events-emits: {Initialized} when initialization is complete

  • throws: ZeroAddressDetected if any input address is zero

Parameters

Name
Type
Description

token

address

Address of the LENDEFI token contract

timelockAddr

address

Address of the timelock contract that will have admin control

multisig

address

Address of the multisig wallet that will have upgrade rights

pause

Pauses all contract operations.

Pause contract.

Notes:

  • requires-role: PAUSER_ROLE

  • events-emits: {Paused} event from PausableUpgradeable

unpause

Resumes all contract operations.

Unpause contract.

Notes:

  • requires-role: PAUSER_ROLE

  • events-emits: {Unpaused} event from PausableUpgradeable

scheduleUpgrade

Only callable by an address with UPGRADER_ROLE

Schedules an upgrade to a new implementation

Parameters

Name
Type
Description

newImplementation

address

Address of the new implementation

emergencyWithdrawToken

Only callable by addresses with MANAGER_ROLE

Always sends all available tokens to the timelock controller

Emergency function to withdraw all tokens to the timelock

Notes:

  • throws: ZeroAddress if token address is zero

  • throws: ZeroBalance if contract has no token balance

Parameters

Name
Type
Description

token

address

The ERC20 token to withdraw

airdrop

Distributes a specified amount of tokens to each address in the recipients array.

Performs an airdrop to a list of recipients.

Notes:

  • requires-role: MANAGER_ROLE

  • requires: Contract must not be paused

  • requires: Amount must be at least 1 ether

  • requires: Total airdropped amount must not exceed the airdrop supply

  • requires: Number of recipients must not exceed 4000 to avoid gas limit issues

  • events-emits: {AirDrop} event

  • throws: InvalidAmount if the amount is less than 1 ether

  • throws: AirdropSupplyLimit if the total airdropped amount exceeds the airdrop supply

  • throws: GasLimit if the number of recipients exceeds 4000

Parameters

Name
Type
Description

recipients

address[]

An array of addresses to receive the airdrop.

amount

uint256

The amount of tokens to be airdropped to each address.

reward

Distributes a specified amount of tokens to a beneficiary address.

Reward functionality for the Nebula Protocol.

Notes:

  • requires-role: REWARDER_ROLE

  • requires: Contract must not be paused

  • requires: Amount must be greater than 0

  • requires: Amount must not exceed the maximum reward limit

  • requires: Total rewarded amount must not exceed the reward supply

  • events-emits: {Reward} event

  • throws: InvalidAmount if the amount is 0

  • throws: InvalidAddress if the recipient address is 0

  • throws: RewardLimit if the amount exceeds the maximum reward limit

  • throws: RewardSupplyLimit if the total rewarded amount exceeds the reward supply

Parameters

Name
Type
Description

to

address

The address that will receive the reward.

amount

uint256

The amount of tokens to be rewarded.

burn

Burns a specified amount of tokens from the reward supply.

Enables burn functionality for the DAO.

Notes:

  • requires-role: BURNER_ROLE

  • requires: Contract must not be paused

  • requires: Amount must be greater than 0

  • requires: Amount must not exceed the maximum burn limit

  • requires: Total burned amount must not exceed the reward supply

  • events-emits: {Burn} event

  • throws: InvalidAmount if the amount is 0

  • throws: MaxBurnLimit if the amount exceeds the maximum burn limit

  • throws: BurnSupplyLimit if the amount exceeds available supply

Parameters

Name
Type
Description

amount

uint256

The amount of tokens to be burned.

addPartner

Adds a new partner by creating a cancellable vesting contract and transferring the specified amount of tokens.

Creates and funds a new vesting contract for a new partner.

Notes:

  • requires-role: MANAGER_ROLE

  • requires: Contract must not be paused

  • requires: Partner address must not be zero and must be a valid contract or EOA

  • requires: Amount must be between 100 ether and half of the partnership supply

  • requires: Duration must be within reasonable bounds

  • requires: Total issued partnership tokens must not exceed the partnership supply

  • events-emits: {AddPartner} event

  • throws: InvalidAddress if the partner address is zero

  • throws: PartnerExists if the partner already has a vesting contract

  • throws: InvalidAmount if the amount is not within the valid range

  • throws: InvalidVestingSchedule if duration is not within reasonable bounds

  • throws: AmountExceedsSupply if the total issued partnership tokens exceed the partnership supply

Parameters

Name
Type
Description

partner

address

The address of the partner to receive the vesting contract.

amount

uint256

The amount of tokens to be vested.

cliff

uint256

The duration in seconds of the cliff period.

duration

uint256

The duration in seconds of the vesting period.

cancelPartnership

This can only be called by the timelock (governance)

Cancels a partner vesting contract

Notes:

  • requires: The caller must be the timelock

  • requires: The partner must have a valid vesting contract

  • emits: CancelPartnership event on successful cancellation

  • throws: CallerNotAllowed if the caller is not the timelock

  • throws: InvalidAddress if the partner has no vesting contract

Parameters

Name
Type
Description

partner

address

The address of the partner whose vesting should be cancelled

cancelUpgrade

Cancels a previously scheduled upgrade

Only callable by addresses with UPGRADER_ROLE

updateMaxReward

Allows updating the maximum reward that can be issued in a single transaction.

Updates the maximum one-time reward amount.

Notes:

  • requires-role: MANAGER_ROLE

  • requires: Contract must not be paused

  • requires: New max reward must be greater than 0

  • requires: New max reward must not exceed 5% of remaining reward supply

  • events-emits: {MaxRewardUpdated} event

  • throws: InvalidAmount if the amount is 0

  • throws: ExcessiveMaxValue if the amount exceeds 5% of remaining reward supply

Parameters

Name
Type
Description

newMaxReward

uint256

The new maximum reward amount.

updateMaxBurn

Allows updating the maximum amount that can be burned in a single transaction.

Updates the maximum one-time burn amount.

Notes:

  • requires-role: MANAGER_ROLE

  • requires: Contract must not be paused

  • requires: New max burn must be greater than 0

  • requires: New max burn must not exceed 10% of remaining reward supply

  • events-emits: {MaxBurnUpdated} event

  • throws: InvalidAmount if the amount is 0

  • throws: ExcessiveMaxValue if the amount exceeds 10% of remaining reward supply

Parameters

Name
Type
Description

newMaxBurn

uint256

The new maximum burn amount.

upgradeTimelockRemaining

Returns the remaining time before a scheduled upgrade can be executed

Returns

Name
Type
Description

<none>

uint256

The time remaining in seconds, or 0 if no upgrade is scheduled or timelock has passed

availableRewardSupply

Returns the effective available reward supply considering burns.

Returns

Name
Type
Description

<none>

uint256

The current available reward supply.

availableAirdropSupply

Returns the effective available airdrop supply.

Returns

Name
Type
Description

<none>

uint256

The current available airdrop supply.

availablePartnershipSupply

Returns the effective available partnership supply.

Returns

Name
Type
Description

<none>

uint256

The current available partnership supply.

_authorizeUpgrade

Authorizes an upgrade to a new implementation with timelock enforcement

Parameters

Name
Type
Description

newImplementation

address

The address of the new implementation contract

Last updated