18. Smart Contracts - ubiquity/ubiquity-dollar GitHub Wiki

Here you will find a brief descriptive overview for each of the primary smart contracts in Ubiquity's dollar protocol, along with hyperlinks to their source code on Github.

Ubiquity Dollar Core Contracts

Staking.sol

Staking Upgrade

github etherscan

Ubiquity Dollar's Staking contract, which handles staking deposits, withdrawals, and minting. Also allows the StakingManager to take emergency action in raising or lowering the price of Dollar by removing Dollar or 3CRV LP tokens from the pool, respectively (see functions addLiquidity and removeLiquidity).

The Staking Manager has unilateral access to the staking contract's minting and pool adjustment functions. This permissioned wallet is currently operated by the development team, as per the initial DAO governance operations period outlined here. This will be changed following the DAO's continued governance rollout, and manual utilization of these functions using the manager address will only take play via governance votes.

Also contains disabled functions used for the migration from the bonding v1 contract(previous staking contract) to the v2 contract(current staking contract) Staking Upgrade.

StakingFormulas.sol

github etherscan

Contains formulas which are used to determine allotted LP shares and proportional token ownership for a given staking contract. In particular, the functions sharesForLP calculates the proportional ownership of staked LP tokens for Governance rewards, and correctedAmountToWithdraw calculates the number of LP tokens to withdrawal based on a staking contract's proportional ownership of the pool.

StakingShare.sol

github etherscan

The upgraded contract for handling a user's persistent staking share NFT, which stores the user's history of interactions with the staking contract.

CreditNFTRedemptionCalculator.sol

github etherscan

Calculates the premium at which Credit NFTs are to be issued for a given amount of Dollars to burn.

CurveDollarIncentive.sol

github etherscan

Contains functions which implement price stability mechanisms through the Curve LP token pool. Specifically, the contract incentivizes arbitrage that brings the Dollar price closer to peg via Governance rewards.

CreditNFT.sol

github etherscan

The ERC-1155 compliant Credit NFT contract. Contains functions that calculate the total debt in the system and update the debt in the system on every debt-related state change.

CreditNFTManager.sol

github etherscan

The ERC-1155 Receiver compliant credit issuance and redemption contract. Implements the protocol's credit issuing and redemption mechanism for Credit NFT holders.

This is the contract end users interact with, directly. It allows users to burn their Dollars in exchange for Credit NFTs redeemable in the future. It allows users to redeem individual Credit NFTs or batch redeem Credit NFTs on a first-come, first-serve basis.

DollarMintCalculator.sol

github etherscan

Calculates the total amount of Dollars to be minted, given the TWAP at that moment, in the case of a supply expansion.

ERC1155Ubiquity.sol

github

The preset contract that implements the ERC-1155 standard for NFTs. The contract also defines the minting, burning and pausing permissions for Credit NFT tokens.

ERC20Ubiquity.sol

github

The preset contract for ERC20-standard tokens of the protocol (Dollar, Governance, and Credit). The contract also defines the transfer function and the minting, burning and pausing permissions for these tokens.

DollarMintExcess.sol

github etherscan

An excess dollar distributor that sends excess Dollars minted during a supply expansion to Treasury, LP rewards, and supply expansion rewards. Here, "excess Dollars minted" refers to any leftover Dollars in the Credit NFT redemption contract (i.e., CreditNFTManager.sol), not required to pay off the credit being redeemed in the concerned transaction.

UbiquityChef.sol

github etherscan

Calculates and distributes Governance rewards to LP token pool stakers based on a deposit time length-based multiplier. The upgraded contract contains logic which handles the persistent staking share NFT

SushiSwapPool.sol

github etherscan

Implements pairs for Dollar and Governance on SushiSwap.

TWAPOracleDollar3pool.sol

github etherscan

This contract is the oracle which retrieves and calculates the Time Weighted Average Price (TWAP) for both Dollar and 3CRV, taken directly from Curve's API.

CreditRedemptionCalculator.sol

github etherscan

Calculates the amount of Dollars to be burned in order to 'auto-redeem' and pay out to existing Dollar credit tokens.

UbiquityDollarManager.sol

github etherscan

A central config for the Ubiquity DAO system. Also acts as a central access control manager. For storing constants, storing variables, and allowing them to be changed by the admin (see the Governance Module) to learn more).

UbiquityDollarToken.sol

github etherscan

The ERC-20 compliant contract for the Dollar token.

UbiquityCreditToken.sol

github etherscan

Defines the RaiseCapital function to be used by the contracts manager to mint Dollars for the treasury. See the Treasury Module documentation page to learn more.

UbiquityFormulas.sol

github etherscan

This contract uses mathematical functions in order to calculate the staking-length based rewards multipliers, as well as the the calculations for Credit NFT issuance, price, and redemption.

UbiquityGovernanceToken.sol

github etherscan

The ERC-20 compliant contract for the protocol's native governance token.

Ubiquity Dollar Dependencies

Curve Metapool

etherscan

Curve 3pool Token

etherscan

Treasury

etherscan