Initial commit from template
This commit is contained in:
23
.eslintrc.js
Normal file
23
.eslintrc.js
Normal file
@@ -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",
|
||||||
|
},
|
||||||
|
};
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
target/
|
||||||
|
*.so
|
||||||
|
.DS_Store
|
||||||
11
.stackclass/compile.sh
Normal file
11
.stackclass/compile.sh
Normal file
@@ -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
|
||||||
11
.stackclass/run.sh
Normal file
11
.stackclass/run.sh
Normal file
@@ -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 "$@"
|
||||||
19
Anchor.toml
Normal file
19
Anchor.toml
Normal file
@@ -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"
|
||||||
21
Cargo.toml
Normal file
21
Cargo.toml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"programs/*"
|
||||||
|
]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "stackclass-solana-lending-program"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["StackClass <hello@stackclass.dev>"]
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
overflow-checks = true
|
||||||
|
lto = "fat"
|
||||||
|
codegen-units = 1
|
||||||
|
|
||||||
|
[profile.release.build-override]
|
||||||
|
opt-level = 3
|
||||||
|
incremental = false
|
||||||
|
codegen-units = 1
|
||||||
14
migrations/deploy.ts
Normal file
14
migrations/deploy.ts
Normal file
@@ -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;
|
||||||
|
});
|
||||||
24
package.json
Normal file
24
package.json
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
programs/lending/Cargo.toml
Normal file
24
programs/lending/Cargo.toml
Normal file
@@ -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"
|
||||||
19
programs/lending/src/lib.rs
Normal file
19
programs/lending/src/lib.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use anchor_lang::prelude::*;
|
||||||
|
|
||||||
|
declare_id!("LendZ1111111111111111111111111111111111111");
|
||||||
|
|
||||||
|
#[program]
|
||||||
|
pub mod lending_program {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Accounts)]
|
||||||
|
pub struct Initialize<'info> {
|
||||||
|
#[account(mut)]
|
||||||
|
pub user: Signer<'info>,
|
||||||
|
pub system_program: Program<'info, System>,
|
||||||
|
}
|
||||||
18
stackclass.yml
Normal file
18
stackclass.yml
Normal file
@@ -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
|
||||||
34
tests/lending.ts
Normal file
34
tests/lending.ts
Normal file
@@ -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<Lending>;
|
||||||
|
|
||||||
|
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
|
||||||
|
});
|
||||||
|
});
|
||||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
24
your_program.sh
Normal file
24
your_program.sh
Normal file
@@ -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 "$@"
|
||||||
Reference in New Issue
Block a user