Union Finance 🛠Masters of Credit:Building Smart Contracts that can Borrow or Lend w/out Collateral
ETHGlobal·Sun, Oct 9, 2022, 12:00 AM
Join Gerald Host of Union Finance for a workshop titled "Masters of Credit: Building smart contracts that can borrow or lend w/out collateral." An introduction to programatic credit on the Union protocol. You'll get a quick intro to Union, the key interfaces and functions, and how to build an autonomous underwriter or borrower. This workshop is part of ETHAmsterdam, the first in-person hackathon for ETHGlobal since ETHLondon in 2019. Join over 800 likeminded engineers, designers, and creators to build and learn over one full weekend at the Beurs Van Berlage in Amsterdam. ETHAmsterdam is taking place as part of Devconnect, the week-long in-person gathering in Amsterdam. We're back to build, we hope you'll join us. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] [Applause] oh we got a few few stragglers hey welcome you know dude maybe i'll just wait like 30 seconds see if anybody else comes in okay cool we'll start um so yeah my name's gerald i work at union i'm a dev um and we'll um we'll start by just giving a brief overview of like what union is what problem we're actually solving um i'll go through a little bit about like uh how you actually interact with a protocol like you know which smart contracts you might be looking at what functions you might want to be calling and i'll also go over a few like potential ideas um just to give you an idea of like some things you could actually do with the protocol and then obviously at the end i can answer any questions you might have so yeah union in a nutshell it's basically like a credit network it's a coordination layer so if you're a person a dow a contract um you can essentially become a union member and either borrow from a credit line or provide a credit line to anybody else and the anybody else that you'd be providing a credit line to could be people groups investments um so yeah it's really like just that coordination layer um so like an example would be like and uh jacob's giving me these really difficult names to pronounce but let's say it's so we've got jean ophelia and claire um and uh they're three separate parties and they want to trust uh the louvre dao i'm going to say that is and so each of them trusts the louvre dao and they uh gene truster lutheral for a hundred ophelia for 50 and claire for 250. so now the louvre dao has a credit line of 400 um and the louvrdale can do what they wish with that credit line so um if they borrow 100 they obviously have to repay the 100 before they default plus they're basically their interest fee so that's essentially like oh hey guys so yeah that's essentially how union works um and just to briefly go over that again you basically have three parties uh each of them can trust a single contract in this case the louvdall um they can trust them for a map an amount in this case jean for 100 ophelia for 50 and clear for 250 um at which point the loose down now has a credit line of 400 and the louvre dal can borrow from that credit line do what it wishes with the money and as long as it repays it with interest it won't go into default and that's good for everybody else um so yeah this is just an example of like the trust graph you can have like one to one you can have one to many you can have many to one so you can have all these different types of like borrowing and lending sort of schemes and uh yeah it's kind of up to you to define like what those might be so yeah that's basically what i just said um you can do yeah one to one you can do one to many blah blah blah um so with union we have this like onboarding process for new union members so in order to actually do anything on the protocol or anything meaningful like borrowing um you have to be onboarded as a union member and to do so you need to have free vouchers from existing members and so this is kind of like a little bit annoying when you're just trying to build stuff because you have to get these free initial vouchers but we do this to try and make sure that the network grows in this kind of like uh well-connected way and you don't just have like a single like a single connection for the network but anyway um in order to onboard a contract to become a member there's one contract that you have to interact with that's called the user manager so once you have three people that are trusting your contract you can then call register member on the user manager and then your contract will become a union member and from which point you can then start to borrow repay and vouch for other people also when you call this register member function you have to have one union and at which point the union gets burned anybody can call it so it doesn't have to be the member that's trying to become a member somebody can call registered member on behalf of the contract they're trying to so we do have uh an sdk so it's on npm you can get it by installing union credit v1 sdk and what's essentially inside this is just like some helper functions to help you interact with the union protocol so for this example we have a contract that's called squeaf with friends it's a union borrower and basically what you can do is people can vouch for this contract this contract can then borrow from its credit line and it can go long on squeef so assuming that uh you know you're vouching for this contract and you think that long-term if is going to go up you might want to vouch for this contract this contract can then borrow from its credit line and then it calls this invest in squeeze function which you can imagine just goes off to an m and buy some oat squeeze likewise you can go the other way around this contract is actually misnamed but this would be a union voucher so instead of borrowing funds this contract is going to vouch for people and so this would inherit the union voucher contract which is also in the sdk and once it becomes a member it can vouch for owners of the frank frank uh nfp so if you're a holder of a frankfurt nft you can call this contract and this contract will give you a credit line so you can start building like little communities that maybe have some characteristic that you want to vouch for and you can build contracts to vouch for people based on that um so other things you might consider is like what what is on chain that i can use to determine if i want to vouch for somebody so maybe you look at their ens you look at how long they've been holding their ens and you try and determine some sort of sentimental value for it you could write that into a contract and vouch for people based on that so yeah so just a few ideas of things that you could build on union um so this would be like a credit union so imagine you have a dao and the dao was initialized with free people and we will call these people degens and those three degens can approve another new member for the dao and to do so they have to not only vouch for the member on union but they also have to vouch for the member to become a part of this dow once that member joins the dao it will now have not only a credit line from the three original degens that vote for them but it will also get a credit line from the dao and this way you can start to build up like a pot of money in the dow where you have a bunch of people that can that are members that can borrow from this credit line so that's uh one simple idea another idea could be like a pay with union button um you could simply do it as a ui piece so you have like a you know a button on a ui um you click the button it borrows from your credit line and it sends the that money to whatever you're trying to buy um a less simple approach to this would be like to write a basically like a credit account so like instead of you your eoa being the member you could build a contract to be the member and this contract could have some like extra abilities like you know borrow and pay in one transaction or borrow and transfer in one transaction um or you know anything you can imagine that you could put into this this credit account contract um so yeah i think gnosis safe but with like some built-in functions that interact with the union protocol and this is one actually that when we were talking to superfluid yesterday they gave us this idea and it's basically like provide a credit line for somebody that has a super fluid stream obviously there's like some some issues with this being that like how do you necessarily know like that you should be providing credit just because somebody has a superfluid stream but it's an interesting idea that like if somebody is being streamed income you can see that there they have an ability to pay repay a loan of a certain size so you could create a voucher contract that uh checks for somebody stream on superfluid and then vouchers for them an amount to give them a credit line based on that cool and that's pretty much yeah union in a nutshell so if you have any questions let me know and i'll be happy to yeah answer i was wondering like where does that interest go and also like how does that like how do you kind of figure out if someone's like kind of in debt yeah so to deal with the second question uh how do you figure out if somebody's in debt so in the protocol we call it overdue and and basically if you're overdue you're owing money and you haven't repaid your loan on time um and that function is in the u token contract and it's called check is overdue um and so what does it mean to be overdue so if you're a staker vouching for people you're earning union tokens by doing so and the rate that you earn union tokens is based on if your loans are healthy so if you're if i'm lending to you and you default on your loan and now you'll become overdue the amount of union that i'm earning is gonna like drop basically um so that's how like the overdue piece works as for your first question um where does the interest go so union is like a two-sided market you have the stakers that are underwriting the loans but uh the the people that are borrowing are not borrowing from the pool of money that is being used to underwrite the loan that just gets staked in the contracts there's a second pool of money which we call eudaimenters and uh they basically mint money into this reserve pool which is what people actually use for borrowing and the interest can get paid well the interest always gets paid back into this pool of money and it can be determined within the protocol should should that interest go back to the people that have originally deposited in the pool or should that money just remain in the reserves and in the treasury generating talking with this and they're kind of like increasing uh you die is just like a token to say like you have minted uh like you have added dye to the reserves um so yeah if you it's not like one for one with die because obviously if a bunch of people default there's like less money in the pool for you to withdraw but if a bunch of people are repaying their loans and it's going up with interest then yeah there would be more money in the pool any other questions no all good then but yeah if you do have any other questions if you think of them in a day um we're on discord um we've also got there's a like union.finance you can find a bunch of useful links we have docs et cetera et cetera just ping us the easiest thing to do is just yeah message us and we'll we'll help you answer lovely [Applause] [Music] [Applause] [Music] you
Automatic transcript — names and jargon may be misspelled.