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
  • buy
  • sell

Was this helpful?

  1. About the Protocol
  2. Protocol V3 Documentation
  3. Core Contracts & API

ExchangeHelper

Helper contract to buy/sell G$ at GoodReserve with any token supported by Uniswap V2. Since reserve only supports cDAI.

Events

TokenPurchased

Emitted when G$ tokens are purchased.

Parameter name
Annotation

caller

The address who initiated the action.

inputToken

The convertible token address which the G$ tokens were purchased with.

inputAmount

Reserve tokens amount.

actualReturn

Actual return after the conversion.

receiverAddress

Address of the receiver of the tokens.

event TokenPurchased(
    address indexed caller,
    address indexed inputToken,
    uint256 inputAmount,
    uint256 actualReturn,
    address indexed receiverAddress
);

TokenSold

Emitted when G$ tokens are sold.

Parameter name
Annotation

caller

The address who initiated the action.

outputToken

The convertible token address which the G$ tokens were sold to.

gdAmount

The G$ tokens amount.

contributionAmount

The amount of G$ tokens that was contributed during the conversion.

actualReturn

Actual return after the conversion.

receiverAddress

Address of the receiver of tokens.

event TokenSold(
    address indexed caller,
    address indexed outputToken,
    uint256 gdAmount,
    uint256 contributionAmount,
    uint256 actualReturn,
    address indexed receiverAddress
);

buy

The function converts any "buyWith" tokens to DAI. Then call to reserve's buy function is occured. It is to convert the tokens to G$ tokens.

Parameter name
Annotation

_buyPath

The tokens swap path in order to buy G$ if initial token is not DAI or cDAI. The end of the path must be set to DAI.

_tokenAmount

The amount of "buyWith" tokens that should be converted to G$ tokens.

_minReturn

The minimum allowed return in G$ tokens.

_minDAIAmount

The minimum DAI out amount from Exchange swap function.

_targetAddress

The address of G$ and GDX recipient if different than msg.sender.

Returns: how much G$ tokens were transferred.

function buy(
    address[] memory _buyPath,
    uint256 _tokenAmount,
    uint256 _minReturn,
    uint256 _minDAIAmount,
    address _targetAddress
) public payable returns (uint256);

sell

The function converts G$ tokens to cDAI through reserve then it makes further transactions according to desired _sellTo token. The user could either send cDAI or DAI directly or desired token through Uniswap V2.

Parameter name
Annotation

_sellPath

The tokens swap path in order to sell G$ to target token. If target token is not DAI or cDAI then first element of the path must be DAI.

_gdAmount

The amount of G$ tokens that should be converted to "_sellTo" tokens.

_minReturn

The minimum allowed "sellTo" tokens return.

_minTokenReturn

The mininmum DAI out amount from Exchange swap function.

_targetAddress

The address of "_sellTo" token recipient if different than msg.sender.

Returns: how much "sellTo" tokens were transferred.

function sell(
    address[] memory _sellPath,
    uint256 _gdAmount,
    uint256 _minReturn,
    uint256 _minTokenReturn,
    address _targetAddress
) public returns (uint256);
PreviousAaveStakingFactoryNextFuseFaucet

Last updated 2 years ago

Was this helpful?