{"id":29124845,"url":"https://github.com/hirosystems/platform-template-stx-defi","last_synced_at":"2026-02-02T07:03:54.587Z","repository":{"id":263040189,"uuid":"886906618","full_name":"hirosystems/platform-template-stx-defi","owner":"hirosystems","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-14T22:26:45.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-23T06:43:50.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clarity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hirosystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-11T20:26:37.000Z","updated_at":"2025-11-14T22:26:46.000Z","dependencies_parsed_at":"2025-07-03T18:39:32.388Z","dependency_job_id":null,"html_url":"https://github.com/hirosystems/platform-template-stx-defi","commit_stats":null,"previous_names":["hiro-platform-templates/stx-defi","hirosystems/platform-template-stx-defi"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/hirosystems/platform-template-stx-defi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirosystems%2Fplatform-template-stx-defi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirosystems%2Fplatform-template-stx-defi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirosystems%2Fplatform-template-stx-defi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirosystems%2Fplatform-template-stx-defi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hirosystems","download_url":"https://codeload.github.com/hirosystems/platform-template-stx-defi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirosystems%2Fplatform-template-stx-defi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29007305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T06:37:10.400Z","status":"ssl_error","status_checked_at":"2026-02-02T06:37:09.383Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-29T21:06:57.043Z","updated_at":"2026-02-02T07:03:54.572Z","avatar_url":"https://github.com/hirosystems.png","language":"Clarity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Decenntralized Finance (DeFi) Loans using STX\n\nA DeFi loan utilizes smart contracts to enforce compliance with loan conditions, such as the application of interest rates and the automated distribution of yields on deposited assets.\n\n\u003e **NOTE**: Normally, DeFi loans permit the borrowing of liquidated assets by using cryptocurrency as collateral. However, to simplify and effectively teach the use-case in a straightforward way, this particular DeFi loan example showcases both deposits and lending using the same STX asset.\n\n## Know your Contract\n\nThe [stx-defi.clar](/examples/stx-defi/contracts/stx-defi.clar) contract includes the following public functions.\n\n+ `deposit` function for users to deposit STX into the contract\n+ `borrow` function for users to borrow STX based on their deposits\n+ `repay` function for users to repay their STX loans\n+ `get-amount-owed` function to get the total amount owed by the user\n+ `claim-yield` function for users to claim their yield based on the pool reserve and their deposits\n\nTo add a new contract, use [Clarinet](https://docs.hiro.so/stacks/clarinet).\n\n## Test your contract\n\nYou can manually test your contract in the Clarinet console. After entering the console with `clarinet console` you can make contract function calls to verify the protocol functionality:\n\n`(contract-call? .stx-defi deposit u1000)`\n\n`(contract-call? .stx-defi borrow u7)`\n\n`(contract-call? .stx-defi get-amount-owed)`\n\nAlternatively, you can run the unit tests included in the `tests/` folder. From the terminal session, navigate to `/clarity-example/stx-defi` folder, and run `npm test`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirosystems%2Fplatform-template-stx-defi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirosystems%2Fplatform-template-stx-defi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirosystems%2Fplatform-template-stx-defi/lists"}