Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 206 forks source link

Peer-to-peer Lending Contract Using Vaults and Liquidation Bounty #5523

Closed jeetraut closed 9 months ago

jeetraut commented 2 years ago

Description

User A wishes to borrow an amount of some asset from User B. This contract would allow User A to lock up collateral of some form, at a value tracked by a mutually agreed upon oracle, with agreed upon interest rates and liquidation actions, in exchange for User B’s assets.

A contract can be instantiated to mediate this while requiring collateral and even allowing for automatic liquidation.

Vaults and liquidation contracts from the Inter Protocol can be modified and re-purposed to allow individual users to define this P2P contract. This contract would be installed on chain, and each use would instantiate a new version

Contract governance electorate would be defined as both users and require a unanimous vote to make changes. Governance must be able to define:

Note: ‘unanimous’ vote requirements out of scope. For contract governance, sufficient to use existing components such that they could be improved later.

Context

This contract would facilitate large OTC lending actions between consenting parties and allow them to structure their agreement to their liking. Initial use case could be traders looking to take a large on-chain short position of some asset not otherwise available.

Acceptance Criteria

A successful bounty would achieve the following:

Time Estimation

3 weeks

Reward

$9,600

Payment will be made in USD (fiat currency) via wire transfer. The developer is responsible for providing their completed tax documents (W9 for US based developers and/or W8 or W8-BEN-E for non-US based developers) and providing their banking details in order to receive payment.

Applicant Assessment Criteria

Important: Please provide a clear workplan for how you will approach this bounty. Use the work plan as an initial demonstration that you would be a good candidate. Bounties will require coordination with the Agoric team, so unfortunately only plans submitted in English will be considered.

Applicants will be assessed based on the following criteria:

Experience Write-up

As part of completing the bounty, we ask that you write up a short (or long!) summary of your experience building on Agoric. This is important feedback for us as we evolve the platform.

Review Process

References

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 264 years from now. Please review their action plans below:

1) jeffreybasden has applied to start work _(Funders only: approve worker | reject worker)_.

Hi, I would love to be approved to ha handle the task at hand. 2) ndidi090 has applied to start work _(Funders only: approve worker | reject worker)_.

Am ready to work with you I promise to complete the task 3) aktech297 has applied to start work _(Funders only: approve worker | reject worker)_.

I am from India. I have very good knowledge in smart contract writing and front end language react.js, javascript. I believe I can complete the this project as per your requirements. Pls let me know if you like to proceed further.. i am a software developer and having very good skills in c++, python, Solidity, javascript, react and web3. 4) bshevchenko has applied to start work _(Funders only: approve worker | reject worker)_.

Ready to start with this one, but only with advance payment (can be partial) in crypto. 5) spoff-jolt has applied to start work _(Funders only: approve worker | reject worker)_.

I'm an experienced go developer and am very interested in contributing to the Status project. My plan: 1) Meet with the team to understand the requirements. 2) Create basic contract architecture. 3) Implement collateral lockup. 4) Do oracle integration 5) Implement 2 party voting system. 6) Implement interest rate, fees and liquidation conditions. 7) Implement asset lending. 8) Deploy contract and test. 9) Create a basic UI for demo. 6) chainbl0ck has applied to start work _(Funders only: approve worker | reject worker)_.

Although i dont have much experience i do have the skills and talent to do the job....ive been a blockchain developer for 6 months i know its not too long but im confident i can provide what youre looking for.I am intrigued by youre offer,i look forward to your response........thanks email:gabguadana@gmail.com Telegram:bl0ck987 7) iotaaxel has applied to start work _(Funders only: approve worker | reject worker)_.

I've read the description and am crafting a basic roadmap that includes a testing / benchmarking phase.

Learn more on the Gitcoin Issue Details page.

onyea commented 2 years ago

Description

User A wishes to borrow an amount of some asset from User B. This contract would allow User A to lock up collateral of some form, at a value tracked by a mutually agreed upon oracle, with agreed upon interest rates and liquidation actions, in exchange for User B’s assets.

A contract can be instantiated to mediate this while requiring collateral and even allowing for automatic liquidation.

Vaults and liquidation contracts from the Inter Protocol can be modified and re-purposed to allow individual users to define this P2P contract. This contract would be installed on chain, and each use would instantiate a new version

Contract governance electorate would be defined as both users and require a unanimous vote to make changes. Governance must be able to define:

  • Liquidation contract (and pool used for liquidation if applicable) - liquidation itself out of scope for bounty. Sufficient to define a contract and assume it correctly liquidates
  • Interest rate
  • Loan origination fee
  • Oracle to be used to track collateral value and debt value - note, debt value is a departure from Inter Protocol vault contracts

Note: ‘unanimous’ vote requirements out of scope. For contract governance, sufficient to use existing components such that they could be improved later.

Context

This contract would facilitate large OTC lending actions between consenting parties and allow them to structure their agreement to their liking. Initial use case could be traders looking to take a large on-chain short position of some asset not otherwise available.

Acceptance Criteria

A successful bounty would achieve the following:

  • Details in ‘Description’ section implemented as indicated, with any modifications agreed upon by the Agoric team
  • Working user flow end to end to achieve the goal
  • Good faith effort to build out governance (not all desired components are currently available)
  • Finished bounty includes documented open source code and walkthrough presentation

Time Estimation

3 weeks

Reward

$9,600

Payment will be made in USD (fiat currency) via wire transfer. The developer is responsible for providing their completed tax documents (W9 for US based developers and/or W8 or W8-BEN-E for non-US based developers) and providing their banking details in order to receive payment.

Applicant Assessment Criteria

Important: Please provide a clear workplan for how you will approach this bounty. Use the work plan as an initial demonstration that you would be a good candidate. Bounties will require coordination with the Agoric team, so unfortunately only plans submitted in English will be considered.

Applicants will be assessed based on the following criteria:

  • Issue-specific domain experience
  • Issue-specific technical capability
  • Familiarity with Agoric's platform
  • JavaScript experience
  • Availability and communication

Experience Write-up As part of completing the bounty, we ask that you write up a short (or long!) summary of your experience building on Agoric. This is important feedback for us as we evolve the platform.

Review Process

  • Agoric team reviews your submitted workplan on Gitcoin

    • It is best to join our Discord and post your gitcoin name in the bounties channel, so that we can follow up with you. Otherwise, we will write on your gitcoin profile wall and say hello!
  • Agoric contacts you to provide reference projects / sample code for engineering review
  • Introductory call to discuss your plans and expected timeline
  • You join the Agoric Discord bounties channel (if you haven’t done so already)
  • Agoric accepts you on Gitcoin and you get started!

References

dckc commented 2 years ago

chatted with @shreyaspapi . We seem to be on the same page with something like:

sequenceDiagram
    dev->>Zoe: install(p2pLendingContract)
    B->>Zoe: startInstance(p2pLendingContract, {interestRate: 3%, electorate: {A, B}})
    A->>p2p: getInvitation()
    p2p->>A: inv1
    A->>Zoe: offer(inv1, collateralPmt)
    Zoe->>p2p: vaultOffer(collateralPmtAmount)
    p2p2->>Zoe: reallocate(100Atom), return vault
    Zoe->>A: payout: 100Atom, offerResult: vault

This diagram doesn't cover

regarding governance of Oracle to be used... let's make that a stretch goal; that might be tricky and I think it's OK if we don't make the Oracle governable to start.

as always, for orientation, I recommend https://agoric.com/documentation/guides/js-programming/ and the 4 part video series there.

thisispalash commented 1 year ago

Hi guys, sorry I haven't completed this yet since @jeetraut handed the bounty to me way back in January; the semester and post semester stuff took up a lot of time. That being said, I now have some time to work on this bounty and just wanted to confirm that this is still open and available. I think I last spoke to @dckc over a Wednesday dev call over the Summer, where he said it is still open.

I'll be diving into the documentation again over the weekend and should have some updates by the coming Wednesday dev call; provided the bounty is still open.

dckc commented 1 year ago

Thanks for the update!

Note: the 18 Oct Wednesday call is somewhat at-risk due to travel.

But I look forward to talking one of these weeks...

thisispalash commented 12 months ago

Note: the 18 Oct Wednesday call is somewhat at-risk due to travel.

That's okay, I can update you async.

To wit, I have set up the agoric environment and started a project. I am going through the diagram to understand the flow better. I am a little confused on how the original funds from User B are obtained (or is that within the contract instantiation?).

The diagram mentions startInstance(...) from B, but my assumption was that User A starts the process since they are requiring the loan, while User B has some funds deposited in a pool already. Or is the startInstance(...) effectively a very specific pool (for one) created? But it requires A to be part of the electorate, so unsure how this could happen async, which I presume is the goal?

I am also not sure what p2p and p2p2 stand for. Are they other new entities on chain? Other than that, while the governance and liquidation is out of scope for the bounty, I am not entirely sure how they would fit in the sequence diagram above. Are they other specific contracts, ie, one for governing this p2p-lend and one for liquidating (if need be)? If so, shouldn't governance be a core part of this contract or is it safe to assume that the terms are decided beforehand and B (or A) initiates the p2p lending? Hence the ...{electorate: {A,B}}... in the initial step(s)?