Building on Bentobox

ETHCC 5 · July 2022 · 57:23

Sarang Parikh demonstrates building applications on Sushi's BentoBox token vault. The hands-on workshop develops GM BentoBox and BentoFund while examining shared vault infrastructure and strategies for deployed capital.

Speakers

Topics

From ETHCC 5, hosted by Ethereum France.

Transcript

uh gm bonjour i am sarang from sushi i kind of deal with anything smart contracts and today we'll be looking at building on bento box which would probably change the way you kind of develop on solidity or smart contracts but it's kind of like an infrastructure layer i would try to squeeze in some a bit of some coding so that you guys can see something live uh as a demo or something but there will be like a challenge for you guys and if you guys do it find me and i can give you some swags so uh let's see what's the agenda for it so first of all like like what's what's broken in the system right like why bento box and then like what is bento box uh then we'll look at some of the

features of bento box uh and then like how can you get started building on top of it and i'll give you some boilerplate code and you know some templates so that you can just fork and you can just you know kind of building like i'm from sushi so you know i love working so let's see like one of uh this slide shows like oh save your finance which has been an excellent tool for the community to pay out salaries had more than one billion plus tvl probably not now in the beer market but when i took the screenshot it was like one billion plus and then we have everybody's favorite nurses safe right so uh it's like go to tool for treasury management and it has a lot of funds can you see one problem with these tools

all the funds are idly sitting doing nothing right so they they're just kept there on the smart contract stored doing nothing bento box solves this we'll get to the point like how it's going to solve this but let's first identify the problem so the first problem is that the apps we have like clear and glossy safe are not capital efficient enough who hates this screen i just hate this right every other dap new tab i open right it's gonna ask me for all these stupid approvals and uh it's gonna cost me a lot of money right but these stupid approvals saves us a lot of money from getting rigged right because if somehow uh we don't have this dapps can just

take away your money right so it's an important step but it's a very big ux hurdle that we have there are some intermediate solutions for this such as permit functions right uh that allows you to sign and then you can like batch it together and dabs can use it but the problem with that is that it's only available for handful of tokens such as usdc dye and a couple of others right the other problem that you have while developing d-apps is having this uh weird token crazy gas calculation so for instance uh usdc has some checks usdt has more checks right so there is no way for you to identify what would be the exact gas cost for your function

operation for all the tokens and not to mention the the esoteric erc777 where you have like you know multiple hooks on deposits withdrawals and stuff like that so you technically it's very difficult for you to actually measure your gas cost right and it's variables in fact bento box solves all of these problems it solves the problem of capital inefficiency in the dapps it solves the problem of variable and high gas cost it solves the problem of approval health so what if i tell you after this presentation you will be able to write much more capital efficient much more gas efficient and you know like much more ux friendly daps without actually changing your coding

style at all right so you just have to follow just few steps and that's it so what is bento box after all bento box is basically like a token vault so it's basically into an infrastructure smart contract layer where it's a set of contracts that acts as a vault you as a user or a developer develops app on top of these bento box which then deposits the capital on bento box which are used in something called as strategies which gives you an extra yield hence the capital efficiency all the value logged inside bento box is stayed within the bento box contract and goes to some other protocols for the strategies everything inside bento box is an accounting unit just like your bank

right so for instance when you go into your bank and you deposit your precious money right bank use it in some strategies but you can still see your balance on your you know phone app or something like that right but actually that balance might not exist with the bank right now right so bender box works with the same same kind of features where you know you make apps and you deposit money on bento box bento box uses that money and puts in different strategies and bento box apps deals with something called as shares and we're gonna look at it one by one but this is how do you develop apps without bento box so this is uh your dap this is boring bob he doesn't know how to

develop dabs and stuff like that so he just created a dab without bento box you put in his he put in his money you know he this money is stored inside the smart contract itself it's a normal way after some time he gets some token back with some yield so far so good now let's go to djinn bob which uses bento box to develop his apps so as i told bento box is like a smart contract infrastructure layer and you can build more daps on top of it now dejan bob deposits some funk some tokens on bento box these tokens can be used by these dapps right so now in the same time these tokens are

also supplied to a strategy such as away after this strategy you get some yield and it comes back and stores back into the bento box making bento box and you much richer all this while you still have a virtual balance inside bento box that your dapps can query and see that this user owes this much to us and now dj and boss get more yield for the same application that he built from the bento box some of the features of bento box are strategies so you can deposit tokens and went to box automatically puts it into strategies such as away compound yearn and xsushi

gas optimization now because all these operations are having are getting done inside the bento box contract so it's just a balance change inside bento box right it does not actually touch any token contracts right so you deposit token on bento box all the tokens are on bento box now let's say if you want to transfer a to b some tokens inside bento box it's just a balance change inside bento box it's not going to touch the token contracts and do a transfer flash loans so bento box supports flash loan bento box has user amount of assets that you can use to flash loan and the yield from the flash loan gets divided to the people who are inside bento box it has batching support so you can batch multiple operations of bento box

together to have like you know much more ux friendly experience so for me i look at bento box as an app store a savings account and a smart contract infrastructure layer all combined into one so it's like your aws your bank and your google play store because we have a lot of different apps built upon bento box some of the apps are from sushi some of the apps are not from sushi but they all share all the same advantages that you that you can see here some key points to remember before we like move on further is user only approves bento box via an approval transaction they do not need to approve your dap so everything happens through bento box it like acts like a funnel to your app right so everything goes with inside the bento

box every approval happens to the bento box and your dap leverages bento box to basically deal with everything that is why you could see that there is a common point and hence people don't have to you know approve like all the tokens again when they have to use your dap all funds are stored in the bento box contract and bento apps what we call it works with basically virtual balances and share whenever there are transfers between like say user to user inside bento box or dap studio apps or adapt to user they all happen within the bento box contract there is no external call that happens the only place when to box touch external calls are like deposits and withdrawals so if somebody wants to deposit from outside bento box from their wallet they do an external call

some when you have to withdraw from the bento box to your wallet you do an external call and that's it but obviously these two again will are expensive operations but if you do everything inside bento box it's so much cheaper so from our research we found out this infographic that says users like the apps which are built upon bento box because they're an extra eel rather than the apps which are not so it's a choice which statistics you want to go forward with some of the apps built upon bento box are isolated lending and borrowing market kashi abracadabra finance you might have also heard about meme and sifu it's that sushi limit orders trident and furo

vesting and streaming so we just saw an example of save layer right where safety has a lot of capital underutilized we built furo which basically allows you to use that capital while you're paying your salaries so let's say if your employee starts a salary for you now you are earning yield on that long amount so when you withdraw your salary you're getting more out of it right so make sure you tell your employees to pay you f euro our trident is basically our next generation amm so we come uh it's built upon bento box so whenever so for the example in uni swap right when you lp your capital is just stored in the contracts doing nothing right uh we could see that a lot of capital from these unisop pairs are not even utilized right with trident you're actually

putting it inside bento box so all this capital is also being utilized in another place so with the trading apr you also get the strategy apr making yourself earning more than normal units for v2 pairs then you have limit orders so when you create these limit orders with bento box you're basically earning yield while limit order is executed everybody knows about abracadabra and mm finance right they're like the cdp kind of a clone where you could deposit the assets and mint out mem which you can use it for any other purpose you want then you have isolated boring and lending market kashi which allows you to lend and borrow assets in an isolated fashion it probably in my knowledge was the first isolated borrowing lending concept that was introduced way before uh rv3 and

everything was launched and next could be your tap as well so if you if you build a dap you're kind of having like this uh bento apps page like an app store where your app could be featured and people could access them let's go to a bit of tricky concept of amounts and shares which kind of tend to confuse a lot of our integrators as well so amounts are the actual amount that the user owns and shares at the virtual balance inside bento box so same like in your bank right you you deposit like say 100 usd you might show the the bank might show you the balance that you have 100 usd but underlying it actually invested somewhere else right and then it occurs yield on top of it which you don't see until unless they pay you out

right so it's the same way so share is something that is stored for internal and virtual computation whereas amounts are the actual money that you hold so whenever a user deposits any amount it gets converted to shares and then it's stored in a bento box in a mapping whenever these are withdraws these shares are converted back to the amounts so that you get the yield that is occurred and you get like more amount than you have actually deposited so ideally when you're building daps you should just use shares because that way your users can get the advantage of having an extra yield so there's a there's a simple formula to convert the amounts to share so you take the supplied amount multiply it by total share and then divide it by total amount

then you take for the amount for the share to amount conversion you take this supplied shares multiplied by total amount and deposit in total shares sounds mathematically let's go with an example so let's say we have alice depositing 1000 usdc into bento box so let's say this is the first deposit so there has been no strategy no apr nothing and right now the share of alice would be hundred because everything is zero right so it's it's just thousand the balance of bender box would be also a thousand because there's nothing else and the amount of alice would be also a thousand because you know it's it has not occurred anything or any stuff now from a strategy if a bento box gains like say 200 usdc the share always

remains constant because that's a virtual balance that would always remain constant whenever you deposit the balance of bento box has increased to 1200 right because it has got 200 dollars from one of our strategies like ave yearn sushi whatever right and the amount of a is now different because according to the formula you take the supply share which was thousand multiplied with the total amount which are 1200 divided by total shares that would give you 1200 usdc so alice just earned 1200 usd just by depositing into pen to box now let's say bob also joins the party right so he deposits another thousand usdc so the share of alice is always gonna be

constant so it's thousand share of b however is not gonna be thousand because now there's been an e liqueur right so you need to use the formula to calculate how much shares would bob receive in this case it it is receiving something called as like 833 or something the total balance of bento box is like 2200 usdc so amount of b is 833 into the total amount of balance that bento hacks a bento box has divided by the total number of shares that yields you thousand sounds correct let's say now from another strategy bento box gains more 200 usdc share of a still remains thousand share of b would be 850 because shares never change she has a constant

the bento box balance however is 2400 usdc now right so now when you put it into the amount formula you get like 1309 for uh alice and 90 1091 for b so you could see there's been a split between the yield right because now there was one more participant into the bento box ecosystem and when we add up all this it it comes to the exact value of 24 usdc it means that the maps check out obviously if the mask did not check out bento box would have been kind of seafood for like three billion dollars so yeah you can trust me on the map uh so now let's look into how do you integrate bender box but before like going on further do you guys have any

question about how what bento box is or you know uh something it's i for now i would say it's you would understand it's not a dish right so yeah so if not let's let's go ahead so the first step to use bento box is call something called as register protocol inside the bender box contracts once you call that what it means like we are just emitting an event which is registering that hey i want to use bento box and register me right it's just like that the other thing is now you need to find a way in which the other people can approve your dap to access the bento box funds

that they have remember like everybody's approving bento box right nobody's approving your app so how would your app get the funds from the bento box they have to use something called a set master contract approval function they pass in the user they pass in the in the master contract they pass in the address of the contract that needs the access of the user's funds they pass in the approve so if it's true it means that the user is giving the approval if it's false it means that user is revoking the approval then vrs are the signature parameters so what you can do is you can use a signature from the user batch it with some other smart contract operation that you have and do approval and that operation just in one transaction so unlike approval hell they're like

they're like not two or three different transactions that a user has to do once a user approves this you get access to all the tokens that the user has approved to the bento box so it's not like you just get access to like say usdc or usdt but if the user has approved like 100 tokens to the bento box you get access to all of them using one single approval right so it becomes much more easy for dapps and the ux experience because users don't have to see that approval screen anymore the other function that you need is the deposit function right because you need to deposit functions from your you know like the user's wallet into the bento box so this is where you use deposit function where the funds are transferred from the user's wallet to the bento box if the user doesn't have it or if the

user chooses to deposit it from your dap so token would be the token which he wants to deposit uh from would be uh with like the user's address to with the would be the address of where he wants to deposit it to amount would be the amount he wants and then there is an optional parameter share so you can use either amounts or share the reason for that is because bento box will do the conversion for you so you don't have to do the complicated math that we did few slides back bento box would automatically do the conversion for you so you can either pass shares amounts and bender works gonna take care of that then you have the transfer function the transfer function is used to basically transfer funds inside the

bento box this is not an erc20 standard you know like transfer function so when you pass token from to and share it's gonna do that internally so it's an internal balance change inside bento box like how you transfer internally to your bank account right let's say if we both have bank account in like citibank right it's easier for citibank to do that it's cheaper for the citibank to do that so bender box is the same concept if you do it inside vendor box it's way cheaper so this transfer deals with the internal balance change inside the bento box then you have the withdrawal so obviously the user needs to withdraw from the bento box right and get a sweet eel this is what he calls so when you put like token from to amount and share uh the same the same concept as of

deposit then you are able to basically like withdraw tokens from the pentobox so far so good do you guys want to see some code on how do you do this so i have created like a bento box template and it's called a bj banter box so it's like bonjour bento box it was gm bento box before but because we are in france so why not so not sure if you guys can see my screen or should i kind of zoom in more yes okay awesome so uh this like a standard hardhat template probably if you guys can create like a foundry or a brownie template as well it

will be awesome uh but let's look at the contract so this is like a bj bento box so it's like hello world for bento box right it's a very simple contract where we basically import the bento box interface so let's go look at the interface as well oh yeah for sure let me know if this is the right zoom in awesome yeah so the interface just hap has the function interfaces for like say to share to convert it to share to amount to convert it to amounts if you want to you know convert inside your app you can easily do it deposit as we saw uh allows users funds from the wallet to be deposited

onto a bento box withdraw allows you to withdraw the funds from the bento box to the user's wallet transfer is used for internal uh bento box balance manipulation and then you have the set master contact approval for your dap to get access to the user's bento box funds and stuff like that and then let's go to bjbentobox so bjpentobox is like a very straightforward concept where we have like deposits is based upon the concept of banknotes and bank receipts that i mean like we had that in india where you know you basically do a deposit and the the banker gives you like a note and that was your non-fungible nft back then so anybody having that note or you know

uh that basically that nft could basically go back to the bank and claim back his deposit i don't know why people used to do that but it was just a concept so uh in this one right they can user can it has a struct user token and deposited shares because now when we create a bento app we have to be careful that we are dealing everything back in shares obviously you can do it with amounts as well but then you kind of lose one of the most important aspect of bend to box which is an extra yield that you get right so we basically define the contra address of the bento box on that particular chain uh we define who's the owner of this contract total deposits is the number of deposits that happened into this contract uh this basically

takes care of the mapping between the depositor and how much amounts he own then we basically kind of you know set the owner set the address of bento box in the constructor and we do the first step of bento box which is register protocol so obviously because now you're building this you want it to happen in the first step and that is why it's in the constructor this is the set bento box approval function so you can pass in the user the status of you know like if he wants to be true false if he wants to revoke or invoke the approval vrs other signature parameters and then you do a call to the bento box or set master contract approval which was stage two right where you now take the access ask

the users that hey you want to use my app give me access to your bento box and obviously the user have to do their own due diligence that the app is not a rug otherwise the app could take up all the funds right the same way with the approval that you should not approve any the app or any smart contract which is you know vulnerable or if it's like a rug pull right so assuming the user did the due diligence and signed it we would relay that signature to the bento box contract and that would give us the access of users funds now there's a function called as deposit to bjbento box which needs a token amount and from mentor box now what is strom bender box means in this context it means like

from where the funds are coming into this into this contract is it from a wallet or is it internally from bento box so let's say if a user has funds internally in its spent or box site then they can just use from bento box as true because it's gonna transfer it internally which is much more cheaper whereas if they don't have any funds inside bento box they can use it false and bento box will pull their funds from the token contract deposit into bento box and then give us the access in our in our dap so it kind of handles both the cases so it's not like you first have to always do a deposit transaction for the user it kind of does everything in just one so we first check so if from bento box is true we pass in the amounts so now we

have to convert this amounts to shares so we use bend to box dot to share to convert this amount to share because transfer only works with share because it's internal function right it's an internal balance transfer so it needs share so you take this amount and convert it to shares you you pass in the token a message.sender is the you know the person from where you want to take this token or you know uh from from fro who's the you user of this you know like this function then address this should be your tap address because where do you want it you want it inside your dac right but it's actually stored inside the bento box itself but it corresponds to your the app address right now in the else you have uh so if the

user wants to deposit it from the wallet they're gonna call deposit because now it's gonna fetch from the token contract all the tokens that is required store it inside bento box and then transfer it to your particular dab so it's it's the same thing and in this case because we already know what the amount is we're just passing amount and we're passing zero so whenever if you only have to pass either amount or shares so if you pass in just amounts it's going to convert inside the contract for bento box and you're good if you pass your share it's just going to use that then in the mapping we basically you know kind of use total deposits to kind of store these deposits so user would be message sender token would be the token that was supplied and the deposited

shares so all this function basically returns us deposited shares as we could see and we're going to increment the total deposit in the withdrawal function we basically have uh we check like you know you get a deposit id so call it like an ft id or note id or whatever right you get this id you can see like you know who's the owner so obviously you can't withdraw from my deposit id right i have to be owner of it right so whosoever is the owner of that deposit id should be the only one allowed so that's that's the check here then we basically want to check that how many shares do they want to withdraw so they pass in the amounts and we convert that to two share so previously while depositing we were converting it to from the uh amounts to share now we're

converting from amounts to share to get to know that how much shares that the user wants to withdraw so we check that if the shares were drawn do they actually own that much shares or not right so that's the check here and they can then uh we're then subtracting the amount of shares that the user wants to withdraw and then there's one more parameter called as two vendor box now this is a parameter to basically define where does the user wants to receive it does the user wants to receive it back in his center box itself or does it want to receive its wallet receiving an inventor box is a much more cheaper transaction because it's again like an internal balance chain inside bento box whereas receiving inside a wallet is a cost a transaction because now it's gonna do an

external call via bento box to withdraw the funds and you know call the token contract deliver it to your wallet address but obviously it's always a good choice for you know uh for the users to have like both the options that they want it on if they want it on wallet or better box you know so it's much more composable that way there's one more thing called as bentofn which is like a crowdfunding app that i made using bento box uh let's finish the presentation if let's see if we have time and if we have time we can crunch in some coding sessions as well okay so let's say goodbye to the cat but so far do you guys have any issues understanding how the structure or the flow of how the dapps is written inside winter box because it doesn't

change the functionality of your dap it just change how the users enter and exit your dap with the tokens right so it just changes your deposit withdraw and transfer function rest all the logic that your dap has is always going to remain constant so if you have a dap you can just start converting that to like say bento box and see how easy it is right you can also abstract this into more generalized functions create like a small library and reuse it that we that we have and we're going to see in the bend to fund example if you get time so obviously we have been talking about all the good things about bento box right that sounds too good to be true and if i'm just talking about all good things in crypto it's definitely a ponzi so let's talk about some risk that we

have first of all the risk is like if the underlying funds are used in a strategy obviously there there can be a hack on the strategy itself right let's say if we put it inside uh let's say uni swap and you saw gets hacked right i wish so but no i'm just kidding but if they get hacked right uh the fun the funds of the users inside bender box will be at loss right so now the shares will be worth less than what they were actually were right so this is one risk the other risk is your general d5 and smart contract risk right that you always have that uh any contract you develop can be vulnerable maybe in future they are like you know upgrades that could make it vulnerable so these are the two main risks that you have

with bento box and rest it's been like you know completely audited well battle tested and used now let's look at one interesting of strategies so we talked about you know like hey you can lose your funds your strategies so who who manages that who manages these strategies is it like sifu manages it who's the who's the one who basically you know governs these strategies so only sushi has the control to basically activate a strategy on any token inside bento box so all these tokens have different strategies they can have same strategies they can have different strategies it can be all the type of mix and match combinations that you want but it's only sushi who has the power the sushi dao who has the power to basically

activate the strategy for any new token inside bento box there's additionally a 14-day time block before the strategy gets basically gets activated the reason for that is because bento box holds humongous amounts of funds and we have to be very very careful to you know kind of activate any strategy so it gives sorry okay yeah so it gives basically a method to evaluate if the strategy activated uh is you know kind of buggy or it's safe and that way you have like 14 days if you feel that you're not comfortable with the strategy you can take your money out of bento box and you know be happy with the eel that you have got so this is also an option which is very important to us and that is why we took kind of like a very high 14 day time log

so that users have enough time to exit the system then you can sushi only add like you know strategy capital to like safe protocols like like i mean like safe is in d5 is like i don't know it's like a bit shady right like safe safe but nothing is safe after all right so what do you mean by safe here is uh we have added strategies to compound ave and xsushi which already has much more significantly higher uh tvl than mentobox right now they have been there in the industry for much more longer time than bento box have had multiple of audits and have been battle tested for so long right so we all love ave merch right when we just go and take

their merch so in the same way we basically trust away to be a bit of on the safer side obviously we're not gonna invest our money in in some scams or some stuff like that even though they tell us that this three three thousand percent apr what not we're not gonna do that we're gonna only do strategies which are basically kind of uh industry approved safe protocols or protocols which have humongous amount of tvl audits and you know basically like industry trust then sushi also so now you might be thinking what if uh sushi just takes away 100 of my capital as well in the strategies becomes difficult for you to deal with that right like the

daps it becomes much harder because when the dapps have to withdraw they have to always withdraw from the strategies right which is again a costly operation so just like in banks right they have like a a loan to value kind of ratio where they they keep some amount always in the reserve so sushi can at max put 95 of a capital like let's say if you have like 100 usdc inventor box you can at max put 95 in a strategy and 5 would be always reserved by reserve i do not mean that after this somebody withdraws this file you cannot withdraw you can also you can 100 withdraw that capital but you need to call a function called as harvest which basically rebalances the strategy and you know bring back more money out of the strategy and gives

it back to you that also comes to the point that we only put in strategies which do not have a lock up because if you put funds in a strategy inside you know like bento box which have like a lock let's say for instance maybe like some fixed vault strategy right that's giving us 20 apr right but it's locking our capital for like 10 days we can't do it because the user might need their capital back right because a lot of apps built upon that are relying that bento box own this capital right so in that case uh users won't be able to withdraw because the capital is logged so we don't put it into any strategies which we can't withdraw from so we the the way bento box strategies are created that you can get in any time get out any time no questions asked no time lock nothing

so that is what you know it allows us to scale much faster as well and currently there have been strategies for compound harvey and x sushi if you guys have some protocols or if you guys want to create strategies for sushi inside bento box there's an integrator fee so bento box has like three billion i think like maybe a bit down right now but it has like around two plus billion dollars in tvl right and we have strategies only for a handful of assets like there are more assets which can be used inside a strategy which is also safe enough and you guys can find that out and on every penny that bento box and its users make you get a cut out of it so let's say we have like say uh around like i think it was 100 million in ftx token or something so if you have

a strategy for that you can go there and like say if the strategy yields like 20 and you get like 10 percent you get like easily one to two million dollars per year for yourself by creating strategy for bento box so obviously it's not like you know quick get rich scheme so once you create a strategy we audit it we make sure everything is right we go through then you have to kind of you know help us manage it as well like you know let's say if you want to invest more you know kind of uh reduce the exposure so we're gonna involved in all such activities but obviously the the reward is also quite high right so some of the free ideas for you guys to kind of you know build on top of bento box that we would love to see is like indices protocol right prediction

market derivative platforms uh crowdfunding platform which is basically like a bender fund so it's like you know kind of a hack a hackathon based contract so you know it's not some app that sushi is gonna build it but you can easily do that build on top of bento box get yield and you know this can be your next project then one of again an interesting project would be a multi-stick treasury and down management system like gnosis safe but that is much more capital efficient so the funds which are idle of these dows will be easily used on different strategies right so we already had made a savilier cone we're calling it furor it's like um it's like a version two of safely you could say and now we had one more avgnos is safe and you can use this so furo currently has like

around like three four million dollars in tvl we just launched like probably last month or something uh but we have commitments of more than like like 50 million dollars in that and this is just why using bento box in sushi so yep i'm not sure how much time we have i think we have like some 10 20 minutes or something okay so uh if you guys have some questions we can go with that or we can go to uh the the bento fund app and we can see how it's spelled or and you can also you know in the okay let's go to sushi okay awesome yeah that sounds oh yeah

we're gonna talk about the crosston swaps as well sorry i had one question regarding the daughter here yes hello um regarding the deposit function that you were saying about can you go back to the code there yeah in this bjp again this one in the slides no this one this one suffices um so if i understand correctly when you create a vault with bento box um all the funds if you use deposit 2 bento box are basically the central contract here yep where also the funds let's say a deposit usdc they can also be allocated into strategies right yeah so the the risk is that uh sushi or the bento box uh and overall can can be hacked and then my funds will also be compromised is there also the option that i use my own vault and keep the funds local i i maybe

i miss that you can you can withdraw the funds so in this basically withdrawal right uh where is it where is it yeah in the withdrawal right you can choose to withdraw it to your own own smart contract and keep the funds in your own smart contract but in that case you won't get the yield and you know some advantages but that's fine that's your choice so you know we kind of mix match both the combo so sometimes we keep some funds in our app but most of the time the true bento apps you know like say uh furor or trident they don't you do this uh but like say limit order does this because it has to kind of execute it off the of the bento box architecture into an amm right so it kind of takes it out into a different contract and then

swaps it so that's that's like all your choice on how you want to mix and match it's definitely possible yeah thank you and there's a second question that you mentioned in the very beginning regarding let's say swap v2 i deposit i i entered a position there i have lp tokens and i can also get an extra yield on top of these lp tokens can you elaborate on that i i maybe missed them so that's actually trident uh so basically if you know trident is our next generation amm uh it's basically allows you to create multiple types of amm together and it uses a time scouting engine which would basically route among each other so so far we have stable pool uh which is like a solidly clone we have uh the sushi legacy which is like the unis of v2 clone we soon will be having

a concentrated uh uni swap v3 i would not say clone or whatever but you get the point right like it will be a the implementation of that but uh now in let's say let's take the example of normal uni swap v2 right you you you have eat or let's say like eat or die you put into uni swap you get an lp position those funds are stored in the contract like your entire liquidity is like most of the time never used like and those funds are just lying there right doing nothing right in in the case of trident imagine the same pair but inside that instead of putting the funds in the same contract it goes inside bento box right so now eth and usdc both have strategies which are used elsewhere right so you can swap it inside ventrobox and keep

your funds inside bento box or if you need to withdraw you can obviously swap it and withdraw it right if they're not enough capital inside bento box it's gonna rebalance it and then gonna do a withdrawal so it's not like your funds will be kind of like stuck or you can't withdraw you can always do that does that answer your question yes awesome uh okay so let me just so in the in the template i showed you right i've also written like few tests i don't think so this can be visible right okay awesome expected uh so yeah you you it you can see this test case when you go home and you know i can just share it right now as well so it basically tells you how to kind of you know like build with a bento box let's go to test

okay okay awesome so i've written like few tests that you can look up you know if you want to hook it to a ui on how you can do it because we guess it's easier for you to see how the actual things are working right so i've kind of uh written few tests to do it now let's look at the bento fund app so you guys know about kickstarter right let me go to test oh yeah that's that's much better yeah i anyway love to quote in dark so feels like natural yeah so in kickstarter generally you have like a goal set a start and an end date and you present your idea right and people

decide to fund it if the goal is reached right you get the money you build the idea and everybody's happy if the goal is not reached the people can take the money back and invest in some other project right sounds good so this is this gives me the vibe of you know that dao thing that we had which got hacked with reentrancy right but kind of it never got again successful enough so possibly this is a chance where you can you know take this code make it better make a front end and relaunch that kind of experience where people can you know just propose idea other people can fund them and you know and by by the time while it's on the you know like this app it's actually earning yield so now you're earning more money by just doing it so if in case you want

to get a refund you now get more back because your money was actually being utilized into strategy and if it's the goal is met and you want to you know pay that person that person receives more money because it was a strategy so it's like win-win for everyone so let's see how so the way i created this tap was it was basically like a challenge program so what you guys have to do is you guys have to look at these tests and figure out what what functions what what is the uh what are the commands that would go inside these specific functions right so you need to look at the test right if you would run the test it would fail so let's go to the tests and yep

yep okay [Music] oops i already have the solution so let me kind of like uh undo this uh yeah no cheating please yeah okay uh let's go to the vendor fund app okay so it's it's it's it's the unsolved function so when you run the test it should fail i mean if it passes i'm scared oh yeah it fails right so you could see all

these tests fails and then so your job is to basically you know write do so i'm kind of given like small hints like say register with bento box so the first function is you know kind of do the register with bento box so you need to come here uh fill in that's it and if you do it one test passes you know stuff like that so yeah this we've got to do one more to actually get some further uh but i have the solution as well so this time where's the solution let's see yeah i'm gonna tell you because you don't have much time but anyway so in this right we're gonna just have the solution brand but don't see it try to

do it yourself i'll get to know if you if you have obviously seen the solution but let's see if if i want to kind of you know like uh show you how how this works so i'm just gonna copy this come here quickly come back do some cheating paste it here and i'm gonna recompile retest let's see at least some test should have been passed if not all yeah so we could see that you know like creating a project pass now let's let's analyze this function so what i did was uh let's go step by step to do okay so this is a create project i basically initialize certain stuff but from here is the actual function which

starts so it says should not allow to create project earlier than current time right which means that you need to have a required check which basically checks that the start time should not be you know kind of like less than the end time or something like that right so if you do this so let me just comment out the rest so that you can see how it works so i save it and i run it so now only one of the tests would pass uh of the three which which we did so you can see only one passed here right so you look at the other test and you see that should not allow to create project if end is smaller than start so you need to make sure that end has to be uh greater than start so you you kind of create that condition

and uh then you pass a test should allow to create to create a project right so you basically kind of write this logic and you test it again obviously the tests are created in a way if you write anything differently it's gonna fail but i've tried to be like more like very explicit if i can and people had already done this challenge before so uh this challenge was simultaneously created by the person like who was doing bento box like who created bento box he was boring crypto he's an amazing guy and he was competing at the same time and two other people bet him on this contest he they bet the people who created bento box so it's definitely a doable challenge and i would like you guys to

you know kind of uh kind of give it a try and if you guys win you guys get a very very special merch from sushi so you guys can try it now and if you can't finish it now you guys can you know like uh and i'll i'll ask you a bunch of questions for sure to make sure that you you have done it yourself and if if you don't do it now find me anywhere into any of these parties and if you can find me and you know you can tell me the solution you win or just mail it to like you know any any or find just any sushi person for that matter sounds good yeah do you have any question oh yeah sure um i want to circle back to when we talked about strategies so sushi's

working on multiple chains just wanted to know bento box does it pull all the assets uh from all the first of all does it work on all the chains that you have and also does it pull the assets or are they separate oh yeah that's a great question so basically bento box is deployed on all the chain sushi as probably like it's not on just one two like you know like very weird l2s but it's it's all almost on all the chains that sushi is on uh it the way it does it like it uses these strategies on the same chain so let's say there are some arbitrary strategies so bento box will only put funds there so it's it doesn't pull funds between you know different chains and you know put it into one so it doesn't do cross-chain each aggregation right so just invest it there because there are

few issues with the cross-chain needle aggregation like there can be situations where you do not get your fund out right because they're not enough liquidity or something like that then the other part is it happens in another transaction right because you need to wait for the chain to receive those funds so that way you can't withdraw quickly so we we don't want users to lose on that withdrawals right if they want to do it so it has to be an atomic operation where they can easily withdraw anytime they want oh oh this is like a oh this was an alpha slide i by mystically shared it but anyway we are here for the alphas right so there's one more like you know kind of different version of bento box which is getting built by the same creator so now people are kind of trying their own

bento box flavors so this is like one of uh a new flavor which is there which is much more in a permissionless aspect it has some downsides and some good things good things is that like anybody can write a strategy and you know you can just go deposit right now you could say that sushi is controlling it i don't trust sushi maybe their sifu at the back end who knows right so they want to avoid that right and you don't want to kind of invest there so and you want like uh your own strategy maybe like 100 of the strategy you want to put in there right so this is what a good advantage elbow save you the issue with this is it kind of fragments the funds right so uh basically every every new strategy is like a new token itself so it's like

strategy a usdc strategy b usgc strategy usdc it kind of fragments so uh sushis is morally sticking towards the bento box architecture because give us much more capital efficiency and the integrator is much more easier for them to develop but obviously because it's like one of the again an upcoming thing so yeah here's the alpha for that and yep that is it and uh we're also having like a launch today for cross chain swaps uh so basically i think it's today or tomorrow but yeah it's today probably so basically you can swap between all these chains atomically uh

yeah so you can you can see this you can see that uh and you can select like say let's say i'm at avalanche and i want to go to um let's say what are the cheap chains again oh phantom yeah yeah it's any anything so i can like say put one fan oh my god what happened to phantom price anyway uh avax to phantom or whatever right and should we do a live i'm not sure if it's launched yeah and live things are always kind of scary but anyway let's see so this is a plane okay let's go to

[Music] oops launch let's go to phantom okay let me connect my wallet i hope it's the the right wallet i'm sharing anyway so we're swapping to avax to phantom like it can be anything but i think i'll just have avax in this so yeah uh that's the phantom in it yeah so we're going from the avalanche to phantom

uh how much should i swap let's see ah no let's go to oh got it let's change my account to this one yep let's see ah 0.5 sounds enough yeah i think so so it's gonna basically you know kind of you tell you the route so you can see the route it goes through avalanche it gets swapped into uh usdc which is then bridged through stargate and then uh the usgc is again swapped to phantom all happens in like like one transaction uh and then obviously legacy and trident is basically uh like avalanche and

phantom do not have trident right now but places where you have trident it's gonna choose the best part between legacy and trident um so so you need to approve pentobox can you see this the approval screen this is how it looks like but it's just a signature so i can just sign it and so there's not a transaction it's a signature so it's not like an approval handling thing it's still annoying but not not as much and then you can confirm if it breaks it breaks because it's still not launched probably but yeah we'll see you'll see uh oh it didn't break so far okay so we can see that it's swapping 0.5 ux so it did that now it's sending the usdc to the destination chain and

then it will swap usdc for 37 phantom let's save this transaction fail because there's a chance right where you know it plays through slippage or something you then would get usdc that you can swap on the other chain that you can again you know swap to any asset you want okay so generally takes like one to two minutes depending upon like you know how's the condition is and obviously this changes uh differently to different chains because let's say if you're going to ethereum they're like 15 seconds if you're going to polygon it says 500 i'd probably wait for a thousand blocks or whatever so you know we kind of added like more buffers for our swaps to be you know much safer oh yeah we got it here it is oh yeah explorers are a bit slow these

days so yeah so we basically like swapped um usdc uh avax to phantom from a vaccine to phantom chain and you know and yeah and this this word could yeah probably it's actually quicker than one minutes because i'm doing the presentation time runs faster let's see uh okay this was one minute ago okay let's see that this was 36 so the total transaction took around uh 30 or 20 seconds uh let's see the gas so we paid around uh we paid 11. oh no sorry here's the transaction we paid around like 36 cents which is like cheap enough right so yeah

and yeah so it depends upon the condition right so let's say if you're swap if you're sending usdc then we're not swapping right so there's no additional fee there it just uh kind of you know uh i teleport i'm lacking the word bridge oh yeah uh bridge on to the other chain and then on the other chain if you just want to use you see there's no swap so this is just a bridge fee then let's say if it's a swap so you are additionally incur like you know point three percent of the sushi fee or you know depending like trident has multiple few tears so probably it can be like point one point two depending upon like you know which kind of pool you are in yeah so our total fee would be this plus the zero point three percent no this includes everything

uh so transaction fee is always considered different right it's not a touching fee yeah there's a blockchain yeah plus the zero point yeah yeah yeah correct yeah and the target fee so basically the free calculation here is a bit different because it depends upon you know which decks it is going on which pool it is going on which bridge it is going on you know so if you want to exact for this i can tell you because there were like two transfers so both of them do not have trident it was legacy so it's going to be 0.3.3 plus target i think it's uh 6bps if i'm not wrong uh but yeah so that much feel and also a transaction yeah the transaction fee exactly plus this is just for avalanche and also

no you don't have to pay anything on phantom so you only pay the transaction fee on the source and on the destination you just directly receive your asset so if this address had zero phantom it did not care it would have got phantom the other thing is uh we have not i think switch it on but you can also get you know like gas refill so if you don't have gas money on that token or that native token you can basically add that and how much you want it and you'll even get that and this is gonna be the start of like you know sushi is like multichain expansion where you have not just this as a swap but when you go to uh legacy sushi and you go to you go to let's say

um let's say pool right where you could see like uh different positions of uh how much you have lent and how much you borrowed or you know uh basically we call it as onsen menu right where you can see a bunch of uh liquidity mining or el mining opportunity but most of the apps you have to basically kind of you know go and change the chain to see most of the opportunities on other chains right sushi's deployed on like 16 chains we're going to show all of these 16s together and you can directly ape into the best one what is available like say if you're into usdc right you can directly ape into that and it's gonna do everything and you can ap into it from any chain using the cross

chain functionality that i just showed you so so you can mix like like say five chains together you can get all the capital and in one click you can transfer them all to the other chain and lp into it and start farming sushi so yeah oh yeah i have two questions what are the tools for writing evolved strategy and the second is that in the process people register through our dap oh okay users and expectations can the dap make a withdrawal for all its users yeah yeah yeah so it can be done too yep so the first one uh you can go to uh sushi get sushi's get up and you can find oops

yep you can find a folder called as bento box strategies yep so you could find like how these strategies are written in this and it's pretty straightforward you have like a base strategy which basically you know kind of uh inherits uh which is get which gets inherited in the strategies so this is like an away strategy so you can see that there's a base strategy which gets inherited and you can write the underlying functions of harvest and skim and withdraw and exit so it basically contains all these functions that you can just code and you you have a strategy for ava right there so it's like 103 lines contract and you you basically invest on avid on the other question yes you can withdraw all the capital for your dap

for your users because they technically are inside your contract address in the bento box site it's still in the vendor box but it's under your dab address uh dap address account right so you can always withdraw pull it in if you want send it to the users seafood to your own doesn't matter you know you can do whatever you want sounds good yep [Applause] you