Skip to content

Instantly share code, notes, and snippets.

View sabbyanandan's full-sized avatar
💭
😃

Sabby Anandan sabbyanandan

💭
😃
View GitHub Profile
@sabbyanandan
sabbyanandan / stx-defi-example.clar
Created March 19, 2024 19:11
A simpler DeFi protocol that hopes to demonstrate lending/borrowing of STX. Authored by @kenrogers.
;; Define the contract's data variables
;; Maps a user's principal address to their deposited amount.
(define-map deposits { owner: principal } { amount: uint })
;; Maps a borrower's principal address to their loan details: amount and the last interaction block.
(define-map loans principal { amount: uint, last-interaction-block: uint })
;; Holds the total amount of deposits in the contract, initialized to 0.
(define-data-var total-deposits uint u0)
CF:
cf push cf-time -p time-source/target/time-source-1.0.0.BUILD-SNAPSHOT-exec.jar --no-start
cf push cf-log -p log-sink/target/log-sink-1.0.0.BUILD-SNAPSHOT-exec.jar --no-start
cf bs cf-time redis
cf bs cf-log redis
cf start cf-time