Skip to content

Add JustLend DAO Lending skill#8

Open
M2M-TRC8004-Registry wants to merge 4 commits intoBofAI:mainfrom
M2M-TRC8004-Registry:add-justlend-skill
Open

Add JustLend DAO Lending skill#8
M2M-TRC8004-Registry wants to merge 4 commits intoBofAI:mainfrom
M2M-TRC8004-Registry:add-justlend-skill

Conversation

@M2M-TRC8004-Registry
Copy link
Copy Markdown
Contributor

Summary

  • Adds justlend-skill for supplying and borrowing assets on JustLend DAO (TRON's largest lending protocol)
  • Browse lending markets with APY rates
  • View lending positions and health factor
  • Supply and withdraw assets
  • Borrow and repay loans

Scripts

  • markets.js — Browse available lending markets
  • position.js — View lending positions and health
  • supply.js — Supply assets to earn interest
  • withdraw.js — Withdraw supplied assets
  • borrow.js — Borrow against collateral
  • repay.js — Repay borrowed assets

Source: https://github.com/M2M-TRC8004-Registry/justlend-skill

@boboliu-1010
Copy link
Copy Markdown
Collaborator

Thank you for this comprehensive JustLend integration! Lending and borrowing capabilities are foundational for maximizing an agent's capital efficiency, and we have this PR on our radar.

We are currently establishing whitelisting mechanisms and security standards for core capabilities, so the merge of this large-scale DeFi Skill will be postponed.

Since lending inherently carries liquidation risks, to meet our merge criteria, we highly recommend adding monitoring logic for the Health Factor. For example: How does the agent estimate the new health factor before borrowing? How can we set a safety threshold (e.g., 1.2) to prevent risky borrowing behaviors?

@M2M-TRC8004-Registry
Copy link
Copy Markdown
Contributor Author

Updated to address review feedback:

  • Health Factor config: Added health_factor.min_threshold (default 1.2) and warn_threshold (default 1.5) in justlend_contracts.json
  • Pre-borrow estimation: borrow.js now calls estimateHealthFactorAfterBorrow() using on-chain oracle prices to project the post-borrow health factor before executing
  • Borrow safeguard: Transactions are blocked if estimated health factor would drop below min_threshold; warnings emitted below warn_threshold
  • Position monitoring: position.js now includes health_factor in output with critical/warning alerts
  • Oracle integration: Added price_oracle address and getUnderlyingPrice ABI for USD valuation of borrows across all markets

@boboliu-1010
Copy link
Copy Markdown
Collaborator

Thanks for the update. I re-checked the latest head after your comment.

I still see one blocking issue before approval: the supported market table in SKILL.md still does not match the jToken addresses in justlend_contracts.json. Please update the documentation so the published addresses match the actual config used by the scripts.

…ad-only client

- Update all 7 jToken addresses in SKILL.md to match justlend_contracts.json
- Add missing WIN and BTC markets to the supported markets table
- Add getTronWebReadOnly() to utils.js for queries that don't need a private key
- markets.js: switch to getTronWebReadOnly() (fully read-only, no key required)
- position.js: use getTronWebReadOnly() when explicit wallet address provided
- SKILL.md/README.md: fix cd path from justlend to justlend-skill
@boboliu-1010
Copy link
Copy Markdown
Collaborator

I was able to install this PR locally, but I could not validate the write-path in our current Nile QA setup.

dry-run for supply.js fails immediately with:

Unknown asset "TRX". Available:

After checking resources/justlend_contracts.json, this skill currently appears to define markets only for mainnet, with no nile configuration.

Please clarify the intended scope:

  • If this skill is meant to support Nile QA, it needs a Nile market/config mapping.
  • If it is mainnet-only, that should be stated explicitly in the README / SKILL.md so QA does not try to validate it against Nile.

JustLend contract addresses and market configs are defined for
TRON Mainnet only. Added explicit notices so QA does not attempt
Nile/Shasta validation.
@M2M-TRC8004-Registry
Copy link
Copy Markdown
Contributor Author

I would have added testnet support, but I wasn't able to find any deployments on testnet

Copy link
Copy Markdown
Collaborator

@boboliu-1010 boboliu-1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review found two blocking issues:

  • repay.js mishandles TRX all: the script maps all to MAX_UINT256, but in the native TRX branch it then sends callValue: 0, so node scripts/repay.js TRX all submits a transaction that does not repay the outstanding borrow.
  • borrow.js estimates health factor before processing the optional --collateral market entry. That means a borrow can be rejected based on the pre-entry state even when the user explicitly asked to enable collateral first. The safeguard needs to reflect the post-entry state, or the collateral entry has to happen before the estimate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants