Initial commit from template
This commit is contained in:
12
programs/swap-program/Cargo.toml
Normal file
12
programs/swap-program/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "swap-program"
|
||||
version = "0.1.0"
|
||||
description = "Solana swap program"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = "0.30.1"
|
||||
anchor-spl = "0.30.1"
|
||||
42
programs/swap-program/src/lib.rs
Normal file
42
programs/swap-program/src/lib.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use anchor_lang::prelude::*;
|
||||
|
||||
declare_id!("11111111111111111111111111111111");
|
||||
|
||||
#[program]
|
||||
pub mod swap {
|
||||
use super::*;
|
||||
|
||||
pub fn make_offer(
|
||||
ctx: Context<MakeOffer>,
|
||||
id: u64,
|
||||
token_a_offered_amount: u64,
|
||||
token_b_wanted_amount: u64,
|
||||
) -> Result<()> {
|
||||
// Students will implement this function
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn take_offer(ctx: Context<TakeOffer>) -> Result<()> {
|
||||
// Students will implement this function
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
#[instruction(id: u64)]
|
||||
pub struct MakeOffer<'info> {
|
||||
pub maker: Signer<'info>,
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct TakeOffer<'info> {
|
||||
pub taker: Signer<'info>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_sample() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user