dharmaprotocol / charta

New & improved contracts for Dharma protocol
98 stars 50 forks source link

Borrower/Debtor address #183

Open curiousgiraffe opened 5 years ago

curiousgiraffe commented 5 years ago

Hi Team What is the recommended way to derive the borrower address for any given debt order? It doesn't seem to be present in any of the contracts' events, or query'able via the subgraph. Am I missing something?

nadavhollander commented 5 years ago

The debt order should have the borrower address present in it, per Dharma Protocol (http://whitepaper.dharma.io/#debt-orders).

In what context are you retrieving the debt order?

curiousgiraffe commented 5 years ago

Thanks for the info! Currently we are only using event data, across all the contracts. I would have thought (and hoped) the borrower address would have been important enough to be present in one of the events arguments (like LogInsertEntry on the DebtRegistry or DebtKernel for example) One can monitor function calls in debt order transactions, but its just not as elegant as being event driven. In the next upgrade to the relevant smart contracts, if possible it would be great if the debtor address could be included in event args along with beneficiary and the other key loan parameters. If you have any other tips on extracting borrower for a given agreementId please let me know. thanks!

nadavhollander commented 5 years ago

Indeed, we had made a mistake in not including the borrower address in the emitted events.  However, you can use the agreementId to call the public getter for agreementToCollateralizer on the Collateralizer.sol contract.  This should give you the address of the borrower (who is the "collateralizer", so to speak).

Nadav Hollander Founder & CEO - Dharma 949.293.5907

Sent via Superhuman ( https://sprh.mn/?vip=nadav@dharma.io )

On Mon, Feb 11, 2019 at 9:01 PM, Curious Giraffe < notifications@github.com > wrote:

Thanks for the info! Currently we are only using event data, across all the contracts. I would have thought (and hoped) the borrower address would have been important enough to be present in one of the events arguments (like LogInsertEntry on the DebtRegistry or DebtKernel for example) One can monitor function calls in debt order transactions, but its just not as elegant as being event driven. In the next upgrade to the relevant smart contracts, if possible it would be great if the debtor address could be included in event args along with beneficiary and the other key loan parameters. If you have any other tips on extracting borrower for a given agreementId please let me know. thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub ( https://github.com/dharmaprotocol/charta/issues/183#issuecomment-462616742 ) , or mute the thread ( https://github.com/notifications/unsubscribe-auth/ADF3XlY64q_66QVLwrQKuhXyMkl2ByYZks5vMkqigaJpZM4ay_DD ).

curiousgiraffe commented 5 years ago

Thanks for the help Nadav. That seems to work for a small handful of the collateralized loans (most return 0x0000... though), and could't work for loans using term contracts other than the sample CollateralizedSimpleInterestTermsContract. I will carry on experimenting! Cheers

edit: please also let me know if there is a discord/telegram/anywhere channel where the community/devs hang out. thanks!

nadavhollander commented 5 years ago

So you are likely seeing loans originated from Lever, which leverages a different terms contract that we've yet to open-source (we will very soon!).

If you call marginPositions(agreementId) on that terms contract, it will return a struct containing two fields:

https://cl.ly/8a87092d0633

This should give you what you're looking for!

Nadav

Nadav Hollander Founder & CEO - Dharma 949.293.5907

Sent via Superhuman ( https://sprh.mn/?vip=nadav@dharma.io )

On Wed, Feb 13, 2019 at 9:42 AM, Curious Giraffe < notifications@github.com > wrote:

Thanks for the help Nadav. That seems to work for a small handful of the collateralized loans (most return 0x0000... though), and could't work for loans using term contracts other than the sample CollateralizedSimpleInterestTermsContract. I will carry on experimenting! Cheers

— You are receiving this because you commented. Reply to this email directly, view it on GitHub ( https://github.com/dharmaprotocol/charta/issues/183#issuecomment-463295268 ) , or mute the thread ( https://github.com/notifications/unsubscribe-auth/ADF3XsO_gj_y5qLEa0bOuRTcacA3wiSaks5vNE59gaJpZM4ay_DD ).