# Fund Trustless USDC Payments Contract

## Summary

In order to pay builders directly with USDC, we have deployed a contract (`TokenBuyer`) which swaps ETH for USDC on behalf of the DAO.

We propose to fund `TokenBuyer` with 625 ETH in order to acquire a USDC buffer of $500K (there's a baked in volatility buffer; any extra ETH will be used for later proposals or can come back to the treasury).

Future proposals created from nouns.wtf will automatically "top off" TokenBuyer with additional ETH, minimizing the need for additional funding proposals.

## Motivation

Many proposals have costs in USD (or other fiat currencies) and would prefer to request USDC for the DAO instead of ETH.

It is not trivial to swap ETH to USDC at proposal execution time without being subjected to sandwich attacks and getting bad swap rates.

## Solution

The tech pod developed [TokenBuyer](https://github.com/nounsDAO/token-buyer) - a suite of smart contracts that allow permissionless swapping of tokens.

TokenBuyer will allow proposals to request payment amount in USDC.

The swapping of ETH to USDC happens asynchronously, meaning:
If the DAO doesn't have enough USDC on hand, it will register a debt for the remaining amount. As soon as the rest of the USDC is available, it is sent to the recipient's wallet, no user intervention needed. We expect this to take a few days at most, depending on the total amount.

TokenBuyer allows anyone to swap USDC for the ETH it holds. It uses Chainlink's ETH/USD price feed to set the price.

Whenever a proposal requests USDC from the DAO, it will also include a transaction to top up TokenBuyer with additional ETH, proportional to the USDC amount requested.

(*This "automatic top-off" is part of nouns.wtf; other governance clients can choose whether they implement this behavior*)

### Example:
* Builder A creates a proposal that requests 100,000 USDC
* 2 actions will be added to the proposal:
    1. Send 100K USDC from the TokenBuyer to Builder A
    2. Send $150K worth of ETH to TokenBuyer to swap for USDC
       * The extra $50K (50% buffer) is added in case ETH price goes down
       * If TokenBuyer already holds ETH, then it will be sent less ETH accordingly
* When the proposal executes:
    1. 100K USDC it sent to Builder A
        * If TokenBuyer has less than 100K USDC on hand, a debt will be registered towards Builder A
    3. TokenBuyer will swap ETH for 100K USDC
    4. Any remaining USDC debt to Builder A is paid as soon as it is swapped

### UI preview

This is a preview of a new proposal creation flow for nouns.wtf developed by Brian.
It will go live once it's possible to request USDC.

![proposal_ui_1](https://i.imgur.com/cOqFO3V.png)
![proposal_ui_2](https://i.imgur.com/vZNqCJ7.png)

### Parameters

* `baselinePaymentTokenAmount`: amount of USDC to hold "on hand". Currently set to $500,000.
* `botDiscountBPs`: a price discount to incentivize anyone (probably bots) to swap USDC for ETH. Currently set to 10 bps (0.1%).

### Admin access
* The tech pod & the DAO have an "operator" privilege with permissions to:
    * Modify `baselinePaymentTokenAmount`, allowed range is: 0 - $1M
    * Modify `botDiscountBPs`, allowed range is: 0-150 (0-1.5%)
    * Pause TokenBuyer swaps
    * Withdraw ETH from TokenBuyer and send it to the DAO
    * Change the operator
* Only the DAO has the ability to:
    * Send USDC
    * Change the allowed ranges for `baselinePaymentTokenAmount` and `botDiscountBPs`

### Arbitrage bot
* A reference bot has been developed and [open-sourced](https://github.com/solimander/eth-buyer-arbitrage-bot) by solimander. We encourage anyone to run their own bot or improve on the code
* The tech pod will be running the reference bot at the beginning to bootstrap the system
* Anyone can perform swaps against TokenBuyer. If we see low activity, we will increase the `botDiscountBPs` parameters to increase the incentive (e.g. if gas prices become high).

## Auditing and Testing

* The smart contracts were audited by yAcademy. [Audit report](https://github.com/nounsDAO/token-buyer/blob/166ec30ecd5dada8e17b55317ce3823d4c36b35f/audit/yAcademy_NounsDAO_TokenBuyer_review.pdf)
    * No "critical" issues were found
    * 1 "high" and 1 "medium" issues were found. The "high" issue was fixed, and the "medium" issue was acknowledged as not being an issue for us.
* Prior to this proposal a few rounds of funding and spending using Token Buyer were done on mainnet


## Funding
* Assuming `baselinePaymentTokenAmount` is set to $500K, we would want to fund TokenBuyer with enough ETH to swap for $500K. We suggested adding an extra 50% to account for price changes. At current ETH prices this 750,000 / 1200 = 625 ETH
* The initial ETH amount will be sent to the tech pod multisig
* The tech pod will deploy it into TokenBuyer in chunks while monitoring that it performs correctly

---

Included Transactions:

* Send 625 ETH to: `0x79095391743e0f017A16c388De6a6a3f175a5cD5` (Tech Pod Multisig)

Outcome: EXECUTED