Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
816d3ed
Add initial error codes and trait usage for YieldCraft contract
adeshola-code Nov 22, 2024
e7655f3
Define data variables for YieldCraft contract
adeshola-code Nov 22, 2024
5707dae
Add data map for protocols in YieldCraft contract
adeshola-code Nov 22, 2024
dd0bba4
Add data map for user deposits in YieldCraft contract
adeshola-code Nov 22, 2024
b873894
Add data map for protocol assets in YieldCraft contract
adeshola-code Nov 22, 2024
f9a8e39
Add public function to add new protocol in YieldCraft contract
adeshola-code Nov 22, 2024
fc50687
Add public function for smart deposit in YieldCraft contract
adeshola-code Nov 22, 2024
523f73f
Add public function for asset withdrawal in YieldCraft contract
adeshola-code Nov 22, 2024
70f33a3
Add public function to claim rewards in YieldCraft contract
adeshola-code Nov 22, 2024
3e94bbe
Add public function to update protocol stats in YieldCraft contract
adeshola-code Nov 22, 2024
4d0b6d1
Add read-only function to get the best protocol in YieldCraft contract
adeshola-code Nov 22, 2024
ebbf1dc
Add read-only function to get user deposit in YieldCraft contract
adeshola-code Nov 22, 2024
97e8d86
Add read-only function to get deposit block height in YieldCraft cont…
adeshola-code Nov 22, 2024
a6c26be
Add private function to calculate rewards in YieldCraft contract
adeshola-code Nov 22, 2024
c597f35
Add private functions to calculate fee and update protocol TVL in Yie…
adeshola-code Nov 22, 2024
1ad07b9
Add private functions to check protocol activity and contract ownersh…
adeshola-code Nov 22, 2024
ea42faa
Add private function to compare protocols in YieldCraft contract
adeshola-code Nov 22, 2024
2bfa4aa
Add private function to generate sequence of numbers in YieldCraft co…
adeshola-code Nov 22, 2024
16ac363
Add contract initialization in YieldCraft contract
adeshola-code Nov 22, 2024
67e9869
Add protocol and SIP-010 traits with basic functions in YieldCraft co…
adeshola-code Nov 22, 2024
3c81bfb
Refactor protocol selection logic and add error handling for inactive…
adeshola-code Nov 22, 2024
91f08dd
Add functions to retrieve protocol APY and determine the best protoco…
adeshola-code Nov 22, 2024
cf38dea
Add private functions for protocol comparison, reward calculation, an…
adeshola-code Nov 22, 2024
ebb7382
Refactor protocol comparison and retrieval functions for improved APY…
adeshola-code Nov 22, 2024
c1ad2f1
Enhance YieldCraft contract with improved deposit handling, token val…
adeshola-code Nov 25, 2024
b87a7af
Add protocol address validation helper function in YieldCraft contract
adeshola-code Nov 25, 2024
fdf6f70
Add protocol type validation and enhance token validation in YieldCra…
adeshola-code Nov 25, 2024
24c534f
Add token validation to prevent self-calling and enhance deposit func…
adeshola-code Nov 25, 2024
9046cbf
Add comprehensive README for YieldCraft Protocol Aggregator from main…
adeshola-code Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
[project]
name = "YieldCraft"
description = ""
name = 'YieldCraft'
description = ''
authors = []
telemetry = true
cache_dir = "./.cache"
cache_dir = './.cache'
requirements = []

# [contracts.counter]
# path = "contracts/counter.clar"
[contracts.protocol-trait]
path = 'contracts/protocol-trait.clar'
clarity_version = 2
epoch = 2.5

[contracts.sip-010-trait]
path = 'contracts/sip-010-trait.clar'
clarity_version = 2
epoch = 2.5

[contracts.yield-craft]
path = 'contracts/yield-craft.clar'
clarity_version = 2
epoch = 2.5
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
passes = ['check_checker']

# Check-checker settings:
# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
# callee_filter: if true, untrusted data may be passed into a private function without a
# warning, if it gets checked inside. This check will also propagate up to the
# caller.
# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# YieldCraft Protocol Aggregator

## Overview

YieldCraft is a smart contract designed to aggregate multiple yield protocols, allowing users to efficiently manage and optimize their asset deposits across different DeFi platforms.

## Features

- Aggregate multiple yield protocols
- Automatic selection of best-yielding protocol
- Secure asset management
- Flexible protocol addition and management
- Reward calculation and claiming
- Platform fee mechanism

## Smart Contract Capabilities

### Core Functions

- `deposit-to-best-protocol`: Deposit assets into the highest-yielding protocol
- `withdraw-from-protocol`: Withdraw assets from a specific protocol
- `claim-rewards`: Claim accumulated rewards
- `add-protocol`: Add new protocols to the aggregator
- `update-protocol-stats`: Update protocol rates and statistics

### Key Components

- Protocol management with active/inactive states
- User deposit tracking
- Dynamic APY and TVL calculation
- Token validation
- Platform fee calculation

## Error Handling

The contract includes comprehensive error codes for scenarios like:
- Unauthorized actions
- Invalid protocols
- Insufficient balances
- Slippage limits
- Protocol activation status

## Configuration Parameters

- Minimum deposit: 1,000,000 smallest token units
- Maximum slippage: 0.5%
- Platform fee: 0.1%
- Maximum protocols: 50

## Security Considerations

- Owner-only protocol management
- Token and protocol address validation
- Deposit and withdrawal checks
- Rewards calculation safeguards

## Deployment Requirements

- Stacks blockchain environment
- SIP-010 compatible tokens
- Protocol trait implementation

## Usage Example

1. Add protocols
2. Deposit assets
3. Automatically get best yield
4. Claim rewards
5. Withdraw assets

## Potential Integrations

- Lending protocols
- Staking platforms
- Yield farming strategies

## Limitations

- Limited to 50 protocols
- Requires ongoing manual protocol stats updates

## Contributing

- Protocol additions
- Performance optimizations
- Additional validation logic
18 changes: 18 additions & 0 deletions contracts/protocol-trait.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(define-trait protocol-trait
(
;; Deposit tokens into the protocol
(deposit (uint) (response uint uint))

;; Withdraw tokens from the protocol
(withdraw (uint) (response uint uint))

;; Get current APY
(get-apy () (response uint uint))

;; Get protocol TVL
(get-tvl () (response uint uint))

;; Get protocol type
(get-protocol-type () (response (string-ascii 20) uint))
)
)
24 changes: 24 additions & 0 deletions contracts/sip-010-trait.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(define-trait sip-010-trait
(
;; Transfer from the caller to a new principal
(transfer (uint principal principal (optional (buff 34))) (response bool uint))

;; Get the token balance of the specified principal
(get-balance (principal) (response uint uint))

;; Get the current total supply
(get-total-supply () (response uint uint))

;; Get the token's name
(get-name () (response (string-ascii 32) uint))

;; Get the token's symbol
(get-symbol () (response (string-ascii 32) uint))

;; Get the token's decimals
(get-decimals () (response uint uint))

;; Get the token URI
(get-token-uri () (response (optional (string-utf8 256)) uint))
)
)
Loading