Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions contracts/src/interfaces/ierc20.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use starknet::ContractAddress;

#[starknet::interface]
pub trait IERC20<TContractState> {
fn name(self: @TContractState) -> ByteArray;
fn symbol(self: @TContractState) -> ByteArray;
fn decimals(self: @TContractState) -> u8;

fn total_supply(self: @TContractState) -> u256;
fn balance_of(self: @TContractState, account: ContractAddress) -> u256;
fn allowance(self: @TContractState, owner: ContractAddress, spender: ContractAddress) -> u256;
fn approve(ref self: TContractState, spender: ContractAddress, amount: u256) -> bool;
fn transfer(ref self: TContractState, recipient: ContractAddress, amount: u256) -> bool;
fn transfer_from(
ref self: TContractState, sender: ContractAddress, recipient: ContractAddress, amount: u256
) -> bool;

fn mint(ref self: TContractState, recipient: ContractAddress, amount: u256) -> bool;
}
24 changes: 24 additions & 0 deletions contracts/src/interfaces/ivault.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use core::starknet::ContractAddress;
use core::starknet::ClassHash;
use win_saved::types::{YieldSourceData, VaultDetails};

#[derive(Drop, Serde)]
pub struct WinnerStruct {
pub address: ContractAddress,
pub date: u64,
pub amount: u256
}

#[starknet::interface]
pub trait IVault<TContractState> {
fn get_vault_details(self: @TContractState) -> VaultDetails;
fn deposit(ref self: TContractState, amount: u256);
fn withdraw(ref self: TContractState, amount: u256);
fn draw(ref self: TContractState, random_value: u32);
fn get_total_assets(self: @TContractState) -> u256;
fn get_yield_source_data(self: @TContractState) -> YieldSourceData;
fn get_recent_winners(self: @TContractState) -> Array<WinnerStruct>;
fn pause(ref self: TContractState);
fn unpause(ref self: TContractState);
fn upgrade(ref self: TContractState, new_class_hash: ClassHash);
}
4 changes: 2 additions & 2 deletions contracts/src/interfaces/iyieldsource.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub trait IYieldSource<TContractState> {
fn withdraw(ref self: TContractState, token: ContractAddress, amount: felt252);
fn withdraw_yield(ref self: TContractState, token: ContractAddress);
fn get_supply_pool_data(self: @TContractState, token: ContractAddress) -> YieldSourceData;
fn get_yield_generated(self: @TContractState, token: ContractAddress) -> u128;
fn get_total_value_locked(self: @TContractState, token: ContractAddress) -> u128;
fn get_yield_generated(self: @TContractState, token: ContractAddress) -> u256;
fn get_total_value_locked(self: @TContractState, token: ContractAddress) -> u256;
fn get_supported_assets(self: @TContractState) -> Array<ContractAddress>;
fn get_source_class_hash(self: @TContractState) -> ClassHash;
fn get_source_contract_address(self: @TContractState) -> ContractAddress;
Expand Down
9 changes: 6 additions & 3 deletions contracts/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pub mod connectors {
pub mod zklend;
}
pub mod types;

pub mod interfaces {
pub mod ivault;
pub mod ierc20;
pub mod iyieldsource;
}

pub mod vault;

29 changes: 29 additions & 0 deletions contracts/src/types.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use starknet::ContractAddress;

#[derive(Copy, Drop, Serde)]
pub struct YieldSourceData {
pub lending_accumulator: felt252,
pub deposit_limit: felt252,
}

#[derive(Copy, Drop, Serde)]
pub struct UserBalanceStruct {
pub address: ContractAddress,
pub amount: u256,
}

#[derive(Drop, Serde)]
pub struct TokenData {
pub symbol: ByteArray,
pub address: ContractAddress
}

#[derive(Drop, Serde)]
pub struct VaultDetails {
pub yield_token: TokenData,
pub vault_token: TokenData,
pub APY: felt252,
pub owner: ContractAddress,
pub total_deposit: u256,
pub total_yield: u256
}
Loading
Loading