Skip to content

Commit

Permalink
Merge pull request #25 from invariant-labs/mint-lp
Browse files Browse the repository at this point in the history
Mint Entrypoint
  • Loading branch information
none00y authored Aug 21, 2024
2 parents cb5cb26 + a767fcf commit 56a1eb2
Show file tree
Hide file tree
Showing 18 changed files with 1,421 additions and 256 deletions.
2 changes: 1 addition & 1 deletion protocol/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

set -e

# Define the keypair JSON content
protocol='[125,25,103,8,46,252,74,11,10,231,221,13,113,82,123,17,118,205,218,140,247,37,159,150,140,109,50,158,185,90,57,107,244,112,134,82,19,192,92,70,188,247,227,156,239,127,119,76,193,85,143,146,12,43,48,189,79,193,48,21,49,108,226,209]'
Expand Down
1 change: 1 addition & 0 deletions protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test:token": "anchor test --skip-build tests/token.test.ts",
"test:invoke": "anchor test --skip-build tests/invoke.test.ts",
"test:init-lp-pool": "anchor test --skip-build tests/init-lp-pool.test.ts",
"test:mint": "anchor test --skip-build tests/mint.test.ts",
"test:math": "anchor test --skip-build tests/math.test.ts"
},
"keywords": [],
Expand Down
8 changes: 5 additions & 3 deletions protocol/programs/protocol/src/contexts/init_pool.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::states::{DerivedAccountIdentifier, LpPool, LP_TOKEN_IDENT};
use crate::states::{DerivedAccountIdentifier, LpPool, INVARIANT_POOL_IDENT, LP_TOKEN_IDENT};
use crate::ErrorCode::*;
use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
Expand Down Expand Up @@ -39,7 +39,7 @@ pub struct InitPoolCtx<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(
seeds = [b"poolv1", token_x.key().as_ref(), token_y.key().as_ref(), &pool.load()?.fee.v.to_le_bytes(), &pool.load()?.tick_spacing.to_le_bytes()],
seeds = [INVARIANT_POOL_IDENT, token_x.key().as_ref(), token_y.key().as_ref(), &pool.load()?.fee.v.to_le_bytes(), &pool.load()?.tick_spacing.to_le_bytes()],
bump = pool.load()?.bump,
seeds::program = invariant::ID
)]
Expand Down Expand Up @@ -70,20 +70,22 @@ pub struct InitPoolCtx<'info> {
}

impl InitPoolCtx<'_> {
pub fn process(&mut self, bump: u8) -> Result<()> {
pub fn process(&mut self, token_bump: u8, bump: u8) -> Result<()> {
let token_x = self.token_x.key();
let token_y = self.token_y.key();
let lp_pool = &mut self.lp_pool.load_init()?;
let pool = &self.pool.load()?;

**lp_pool = LpPool {
invariant_position: Pubkey::default(),
position_bump: 0,
leftover_x: 0,
leftover_y: 0,
token_x,
token_y,
tick_spacing: pool.tick_spacing,
fee: crate::decimals::FixedPoint::new(pool.fee.v),
token_bump,
bump,
};

Expand Down
Loading

0 comments on commit 56a1eb2

Please sign in to comment.