GoodDocs
  • Welcome to GoodDocs!
  • GoodDollar Ecosystem Vision
  • About the Protocol
    • Usage
    • Tokenomics
    • Sybil-Resistance
    • Protocol V3 Documentation
      • Architecture & Value Flow
      • System's Elements
      • Core Contracts & API
        • GoodDollar
        • GoodCompoundStaking V2 (DAI)
        • GoodAaveStaking V2 (USDC)
        • GoodReserveCDai
        • GoodFundManager
        • GoodMarketMaker
        • ContributionCalculation
        • UBIScheme
        • Identity
        • FirstClaimPool
        • AdminWallet
        • OneTimePayments
        • DonationsStaking
        • NameService
        • GReputation
        • CompoundVotingMachine
        • StakersDistribution
        • UniswapV2SwapHelper
        • Invites
        • GovernanceStaking
        • ClaimersDistribution
        • CompoundStakingFactory
        • AaveStakingFactory
        • ExchangeHelper
        • FuseFaucet
        • GoodDollarMintBurnWrapper
      • Previous Protocol Versions
        • Protocol V1
          • Architecture & Value Flow
          • Core Contracts & API
        • Protocol V2
          • Architecture & Value Flow
          • System's Elements
            • 1. The token (G$)
            • 2. The Reserve
            • 3. The Trust
            • 4. Staking rewards (APR)
            • 5. The Fund Manager
            • 6. The Distribution Contract (DisCo)
            • 7. Governance (DAO)
          • Core Contracts & API
            • GoodDollar
            • GoodCompoundStaking V2 (DAI)
            • GoodAaveStaking V2 (USDC)
            • GoodReserveCDai
            • GoodFundManager
            • GoodMarketMaker
            • ContributionCalculation
            • UBIScheme
            • Identity
            • FirstClaimPool
            • AdminWallet
            • OneTimePayments
            • DonationsStaking
            • NameService
            • GReputation
            • CompoundVotingMachine
            • StakersDistribution
            • UniswapV2SwapHelper
            • Invites
            • GovernanceStaking
            • ClaimersDistribution
            • CompoundStakingFactory
            • AaveStakingFactory
            • ExchangeHelper
            • FuseFaucet
  • User Guides
    • Buy & Sell G$
    • Stake to create UBI
    • Claim GOOD and G$X
    • Bridge GoodDollars
    • Connect another wallet address to identity
  • Liquidity
  • Wallet and Products
    • GoodWallet
    • GoodDapp
    • New GoodWallet
    • GoodCollective
    • GoodID & GoodOffers
    • 3rd Party Partners and Integrations
  • Frequently Asked Questions
    • Web3 basic knowledge and security tips - by Consensys
    • About GoodDollar
    • GoodDollar Protocol & G$ Token
    • Using GoodDollar
    • GoodDollar Community
    • Troubleshooting
  • For Developers
    • Contributing to GoodDollar
    • GoodDapp Developer Guides
      • Deploy your own GoodDapp UI
    • APIs & SDKs
      • Claim UBI
      • React Hooks Setup
      • Login With GoodDollar
      • Sybil Resistance
        • Identity (Ethers v5 / React)
        • Identity (Viem/Wagmi)
  • Useful Links
    • GoodDollar.org
    • GoodDapp
    • GoodWallet
    • GoodDollar User Guides
    • Statistics Dashboard
    • GoodDollar Whitepaper
    • GoodDollar Litepaper
    • GoodDollar Litepaper - Español
Powered by GitBook
On this page
  • Events
  • calculateNewReserveRatio
  • buyReturn
  • sellReturn
  • buy
  • sellWithContribution

Was this helpful?

  1. About the Protocol
  2. Protocol V3 Documentation
  3. Previous Protocol Versions
  4. Protocol V2
  5. Core Contracts & API

GoodMarketMaker

Helper contract for the GoodReserveCDai. It serves as a dynamic reserve ratio market maker.

Events

BalancesUpdated

Emits when a change has occurred in a reserve balance, i.e. buy / sell will change the balance.

Parameter name
Annotation

caller

The account who initiated the action.

reserveToken

The address of the reserve token.

amount

The incoming amount.

returnAmount

The return value.

totalSupply

The updated total supply.

reserveBalance

The updated reserve balance.

event BalancesUpdated(
    address indexed caller,
    address indexed reserveToken,
    uint256 amount,
    uint256 returnAmount,
    uint256 totalSupply,
    uint256 reserveBalance
);

ReserveRatioUpdated

Emits when the ratio changed. The caller should be the Avatar by definition.

Parameter name
Annotation

caller

The address of the staker.

nom

Nominator of the ratio.

denom

Denominator of the ratio.

event ReserveRatioUpdated(address indexed caller, uint256 nom, uint256 denom);

calculateNewReserveRatio

Calculates how much to decrease the reserve ratio for _token by the reserveRatioDailyExpansion.

Parameter name
Annotation

_token

The reserve token to calculate the reserve ratio for.

Returns: the new reserve ratio.

function calculateNewReserveRatio(ERC20 _token) public view returns (uint32);

buyReturn

Calculates the buy return in G$ according to the given _tokenAmount.

Parameter name
Annotation

_token

The reserve token buying with.

_tokenAmount

The amount of reserve token buying with.

Returns: A number of G$ that should be given in exchange as calculated by the bonding curve.

function buyReturn(ERC20 _token, uint256 _tokenAmount);

sellReturn

Calculates the sell return in _token according to the given _gdAmount.

Parameter name
Annotation

_token

The reserve token buying with.

_gdAmount

The amount of reserve token buying with.

Returns: A number of tokens that should be given in exchange as calculated by the bonding curve.

function sellReturn(ERC20 _token, uint256 _gdAmount);

buy

Updates the _token bonding curve params. Emits BalancesUpdated with the new reserve token information.

Parameter name
Annotation

_token

The reserve token buying with.

_tokenAmount

The amount of reserve token buying with.

Returns: A number of G$ that will be given in exchange as calculated by the bonding curve.

function buy(ERC20 _token, uint256 _tokenAmount);

sellWithContribution

Calculates the sell return with contribution in _token and update the bonding curve params. Emits BalancesUpdated with the new reserve token information.

Parameter name
Annotation

_token

The desired reserve token to have.

_gdAmount

The amount of G$ that are sold.

_contributionGdAmount

The number of G$ tokens that will not be traded for the reserve token.

Returns: A number of tokens that will be given in exchange as calculated by the bonding curve.

function sellWithContribution(
	ERC20 _token,
	uint256 _gdAmount,
	uint256 _contributionGdAmount
) public returns (uint256);
PreviousGoodFundManagerNextContributionCalculation

Last updated 3 years ago

Was this helpful?