Skip to content

Commit f2bdbd4

Browse files
committed
token swap example test working
1 parent b9f3d40 commit f2bdbd4

File tree

7 files changed

+9
-18
lines changed

7 files changed

+9
-18
lines changed

tokens/token-swap/anchor/Anchor.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolution = true
55
skip-lint = false
66

77
[programs.devnet]
8-
swap_example = "9mcG7PFTBuii5oyfHbJm3kL8eQZrYqNYe9NEgaME21ff"
8+
swap_example = "AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn"
99

1010
[registry]
1111
url = "https://api.apr.dev"

tokens/token-swap/anchor/programs/token-swap/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
2020
anchor-lang = { version = "0.30.0", features = ["init-if-needed"] }
2121
anchor-spl = { version = "0.30.0" }
2222
fixed = "1.23.1"
23-
half = "=2.2.1"
24-
fixed-sqrt = "0.2.5"
25-
solana-program = "1.18.10"
23+
2624

tokens/token-swap/anchor/programs/token-swap/src/instructions/create_pool.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use anchor_spl::{
66

77
use crate::{
88
constants::{AUTHORITY_SEED, LIQUIDITY_SEED},
9-
errors::*,
109
state::{Amm, Pool},
1110
};
1211

@@ -27,7 +26,7 @@ pub struct CreatePool<'info> {
2726
],
2827
bump,
2928
)]
30-
pub amm: Account<'info, Amm>,
29+
pub amm: Box<Account<'info, Amm>>,
3130

3231
#[account(
3332
init,
@@ -39,9 +38,8 @@ pub struct CreatePool<'info> {
3938
mint_b.key().as_ref(),
4039
],
4140
bump,
42-
constraint = mint_a.key() < mint_b.key() @ TutorialError::InvalidMint
4341
)]
44-
pub pool: Account<'info, Pool>,
42+
pub pool: Box<Account<'info, Pool>>,
4543

4644
/// CHECK: Read only authority
4745
#[account(

tokens/token-swap/anchor/programs/token-swap/src/instructions/deposit_liquidity.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct DepositLiquidity<'info> {
137137
has_one = mint_a,
138138
has_one = mint_b,
139139
)]
140-
pub pool: Account<'info, Pool>,
140+
pub pool: Box<Account<'info, Pool>>,
141141

142142
/// CHECK: Read only authority
143143
#[account(
@@ -193,16 +193,14 @@ pub struct DepositLiquidity<'info> {
193193
pub depositor_account_liquidity: Box<Account<'info, TokenAccount>>,
194194

195195
#[account(
196-
init_if_needed,
197-
payer = payer,
196+
mut,
198197
associated_token::mint = mint_a,
199198
associated_token::authority = depositor,
200199
)]
201200
pub depositor_account_a: Box<Account<'info, TokenAccount>>,
202201

203202
#[account(
204-
init_if_needed,
205-
payer = payer,
203+
mut,
206204
associated_token::mint = mint_b,
207205
associated_token::authority = depositor,
208206
)]

tokens/token-swap/anchor/programs/token-swap/src/instructions/withdraw_liquidity.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ pub struct WithdrawLiquidity<'info> {
153153
pub pool_account_b: Box<Account<'info, TokenAccount>>,
154154

155155
#[account(
156-
init_if_needed,
157-
payer = payer,
156+
mut,
158157
associated_token::mint = mint_liquidity,
159158
associated_token::authority = depositor,
160159
)]

tokens/token-swap/anchor/programs/token-swap/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod instructions;
88
mod state;
99

1010
// Set the correct key here
11-
declare_id!("9mcG7PFTBuii5oyfHbJm3kL8eQZrYqNYe9NEgaME21ff");
11+
declare_id!("AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn");
1212

1313
#[program]
1414
pub mod swap_example {

tokens/token-swap/anchor/tests/create-pool.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ describe("Create pool", () => {
2121
.accounts({ amm: values.ammKey, admin: values.admin.publicKey })
2222
.rpc();
2323

24-
console.log(values.ammKey);
25-
2624
await mintingTokens({
2725
connection,
2826
creator: values.admin,

0 commit comments

Comments
 (0)