Testing, Testing Union v2

larger credit networks and explicit liquidity risks

Jacob Shiach
Union Finance
4 min readMar 24, 2023

--

Tl;dr: Union has deployed version 2 live for testing on Optimism Goerli @ https://app.v2.union.finance/

The Union Protocol has been live on Ethereum and Arbitrum for over a year now.

It has enabled the creation of $173,404 in Available Credit, has originated $117,392 in Borrows, across 190 member addresses.

All without a centralized mediator deciding who is credit-worthy.

But as you can probably tell from the member count being less than the global population, we hit a limit with v1. One of v1’s design flaws limited the number addresses any one address could Vouch* for (re: Underwrite) or be vouched by to 25.

This was quite the hurdle cause one of the most unique aspects of a credit network on a global computer is the ability to create programs with credit lines and autonomous programs that can trust! A 25 address limit restricted the use cases to primarily person to person activity, which isn’t the ideal use case for an on-chain protocol.

Thankfully last summer we had a key breakthrough for how to scale, and overnight, just nine months later we are very excited to share:

Union version Two: https://github.com/unioncredit/union-v2-contracts

What’s new in Union version 2?

  1. Greater scalability: The new version increases the maximum number of addresses one can underwrite from 25 to 1000 and be underwritten by from 25 to 400 (within a 15m gas limit). — In v1, updating locked stake wasn’t scaleable it required looping through all your backers and their backee’s. To fix this in V2, among other things, we no longer sort backers by trust size and instead use a First in First out algorithm.
  2. Enhanced liquidity: writing off debt is made public after a “max overdue” period to ensure liquidity isn’t locked for an indefinite period and bad debt doesn’t accrue in the system.— In V1 stakers could write off the defaulted debt of their borrowers using their locked stake. In V2 that function becomes publicly callable for stake cosigning loans that have been in default for ‘overdueBlocks’ + ‘maxOverdueBlocks’. [e.g. if this is set to 60 days and someone borrows and makes no payments, anyone will be able to call the function after 90 days.]
  3. Union Lens Contract — Union is an incredibly call-intensive protocol. This View layer contract consolidates view helpers making it easier to build frontends, and also helped reduce contract size in core contracts
  4. More efficient and constant gas costs — V2 uses struct packing to pack structs into single slots reducing storage read and writes dramatically compared to v1 . Vouching now has a constant gas cost, in V1 the gas cost was dependent on number of vouchers(O(n)) but in V2 it is constant (O(1)).
A sample of v2 Gas Costs.

What will Union V2 enable?

  • Credit Associations: Instead of joining the network via a single point of contact, you can join a group, or create one — all variants of more traditional forms of credit can be implemented on Union.
  • DAOs underwriting their Members: dao’s can now vouch for most of their members from a single timelock or vouching contract.
  • More Available Credit: You can now vouch for large swaths of addresses with specific traits. — e.g. Trust every CryptoCorgi holder with an ENS age over two years old with 42 DAI
  • Borrow from Hundreds of People: With the ability to be backed by hundreds of people and DAOs, users can access even more significant credit lines — What can you do with a dao-owned credit line backed by 400 people and dao’s?
  • Exciting credit experiments: probably the most underrated aspect of being able to vouch for 1000 addresses is you now have a statistically significant sample size, we expect to learn a great deal in the months ahead. If you’re interested in running a credit experiment, feel free to reach out.

Testing Together:

Union V2 Contracts have just completed a Sherlock Audit Contest, and before deploying Union v2 to MainNet, we’d love for you to help us stress test the system. To participate in the testing process follow the steps below.

If you’d like to help test the Interface:

  1. Get some Goerli Eth and bridge to Optimism Goerli.
  2. Get some AAVE v3 Optimism Goerli DAI
  3. Go to app.v2.union.finance and connect to optimism goerli (v2)
  4. Follow the instructions for Becoming a Member
  5. Use the new testnet Vouch Faucet or stop by Discord to get a vouch.
  6. Burn 1 UNION to become a member
  7. Try all the main functions: trust, borrow, repay, writeoff
  8. Use the dashboard to see live stats and statuses.

If you’d like to help test the contracts directly:

If you find any oddities, bugs, or things that don’t make sense, report them via Discord #support, Github Issues or DM @unionprotocol on twitter.

Thank you for reading to the end, can’t wait for you to experience the improvements Union v2 has to offer. ​ ​Happy Testing!

--

--