commit 132c6908bc99ab4a5e22ec98707b382f1adce130 Author: StackClass Date: Mon Dec 29 12:46:10 2025 +0000 Initial commit from template diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..c731480 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,23 @@ +module.exports = { + root: true, + env: { + es2020: true, + node: true, + }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + ], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + project: "./tsconfig.json", + }, + ignorePatterns: ["**/target/**", "node_modules"], + rules: { + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], + "@typescript-eslint/ban-ts-comment": "off", + }, +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..374397b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +*.so +.DS_Store diff --git a/.stackclass/compile.sh b/.stackclass/compile.sh new file mode 100644 index 0000000..d2b4072 --- /dev/null +++ b/.stackclass/compile.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# +# This script is used to compile your program on StackClass +# +# This runs before .stackclass/run.sh +# +# Learn more: https://docs.stackclass.dev/challenges/program-interface + +set -e # Exit on failure + +cargo build --release diff --git a/.stackclass/run.sh b/.stackclass/run.sh new file mode 100644 index 0000000..007230d --- /dev/null +++ b/.stackclass/run.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# +# This script is used to run your program on StackClass +# +# This runs after .stackclass/compile.sh +# +# Learn more: https://docs.stackclass.dev/challenges/program-interface + +set -e # Exit on failure + +exec target/release/stackclass-solana-lending-program "$@" diff --git a/Anchor.toml b/Anchor.toml new file mode 100644 index 0000000..c37c976 --- /dev/null +++ b/Anchor.toml @@ -0,0 +1,19 @@ +[toolchain] +anchor_version = "0.30.1" + +[features] +resolution = true +skip-lint = false + +[programs.localnet] +lending = "LendZ1111111111111111111111111111111111111" + +[registry] +url = "https://api.apr.dev" + +[provider] +cluster = "Localnet" +wallet = "~/.config/solana/id.json" + +[scripts] +test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ae85546 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,21 @@ +[workspace] +members = [ + "programs/*" +] +resolver = "2" + +[package] +name = "stackclass-solana-lending-program" +version = "0.1.0" +authors = ["StackClass "] +edition = "2021" + +[profile.release] +overflow-checks = true +lto = "fat" +codegen-units = 1 + +[profile.release.build-override] +opt-level = 3 +incremental = false +codegen-units = 1 diff --git a/migrations/deploy.ts b/migrations/deploy.ts new file mode 100644 index 0000000..541e3df --- /dev/null +++ b/migrations/deploy.ts @@ -0,0 +1,14 @@ +// Migrations are managed by Anchor +// This file can be used for custom deployment scripts + +import * as anchor from "@coral-xyz/anchor"; + +async function main() { + console.log("Running deployment script..."); + // Custom deployment logic can be added here +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..6db7f2a --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "solana-lending", + "version": "0.1.0", + "description": "Solana lending program built with Anchor", + "main": "index.js", + "scripts": { + "test": "anchor test", + "lint": "eslint --ext .ts tests/", + "build": "anchor build", + "deploy": "anchor deploy" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.30.0", + "@solana/web3.js": "^1.87.0" + }, + "devDependencies": { + "@types/mocha": "^10.0.0", + "@types/node": "^20.0.0", + "eslint": "^8.0.0", + "mocha": "^10.0.0", + "ts-mocha": "^10.0.0", + "typescript": "^5.0.0" + } +} diff --git a/programs/lending/Cargo.toml b/programs/lending/Cargo.toml new file mode 100644 index 0000000..5add716 --- /dev/null +++ b/programs/lending/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "lending" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "lending" + +[features] +default = [] +cpi = ["no-entrypoint"] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] + +[dependencies] +anchor-lang = { version="0.30.1", features=["init-if-needed"] } +anchor-spl = "0.30.1" +pyth-sdk-solana = "0.10.1" +pyth-solana-receiver-sdk = "0.3.1" +solana-program = "1.18.17" diff --git a/programs/lending/src/lib.rs b/programs/lending/src/lib.rs new file mode 100644 index 0000000..d19a836 --- /dev/null +++ b/programs/lending/src/lib.rs @@ -0,0 +1,19 @@ +use anchor_lang::prelude::*; + +declare_id!("LendZ1111111111111111111111111111111111111"); + +#[program] +pub mod lending_program { + use super::*; + + pub fn initialize(ctx: Context) -> Result<()> { + Ok(()) + } +} + +#[derive(Accounts)] +pub struct Initialize<'info> { + #[account(mut)] + pub user: Signer<'info>, + pub system_program: Program<'info, System>, +} diff --git a/stackclass.yml b/stackclass.yml new file mode 100644 index 0000000..3fe40aa --- /dev/null +++ b/stackclass.yml @@ -0,0 +1,18 @@ +# Set this to true if you want debug logs. +# +# These can be VERY verbose, so we suggest turning them off +# unless you really need them. +debug: false + +# Use this to change the Rust version used to run your code +# on StackClass. +# +# Available versions: rust-1.87 +language_pack: rust-1.87 + +# The executable required to build and run the this project, +# along with its minimum required version. +required_executable: cargo (1.87) + +# The main source file that users can edit for this project. +user_editable_file: programs/lending-program/src/lib.rs diff --git a/tests/lending.ts b/tests/lending.ts new file mode 100644 index 0000000..363ee0f --- /dev/null +++ b/tests/lending.ts @@ -0,0 +1,34 @@ +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import { Lending } from "../target/types/lending"; + +describe("lending", () => { + const provider = anchor.AnchorProvider.env(); + anchor.setProvider(provider); + + const program = anchor.workspace.Lending as Program; + + it("Initialize bank", async () => { + // Test initialization + }); + + it("Initialize user", async () => { + // Test user initialization + }); + + it("Deposit tokens", async () => { + // Test deposit functionality + }); + + it("Withdraw tokens", async () => { + // Test withdraw functionality + }); + + it("Borrow tokens", async () => { + // Test borrow functionality + }); + + it("Repay loan", async () => { + // Test repay functionality + }); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..fd00493 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "types": ["mocha"], + "lib": ["esnext"], + "module": "commonjs", + "target": "es2020", + "moduleResolution": "node", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "resolveJsonModule": true + } +} diff --git a/your_program.sh b/your_program.sh new file mode 100644 index 0000000..6d3e35f --- /dev/null +++ b/your_program.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Use this script to run your program LOCALLY. +# +# Note: Changing this script WILL NOT affect how StackClass runs your program. +# +# Learn more: https://docs.stackclass.dev/challenges/program-interface + +set -e # Exit early if any commands fail + +# Copied from .stackclass/compile.sh +# +# - Edit this to change how your program compiles locally +# - Edit .stackclass/compile.sh to change how your program compiles remotely +( + cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory + cargo build --release +) + +# Copied from .stackclass/run.sh +# +# - Edit this to change how your program runs locally +# - Edit .stackclass/run.sh to change how your program runs remotely +exec target/release/stackclass-solana-lending-program "$@"