Skip to content

Commit

Permalink
fatcat: stake
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ece committed Jan 28, 2025
1 parent 1b9e254 commit 3dec231
Show file tree
Hide file tree
Showing 12 changed files with 473 additions and 1,359 deletions.
1 change: 1 addition & 0 deletions anchor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "TypeScript SDK for GLAM Protocol",
"main": "./index.cjs",
"module": "./index.esm.js",
"exports": "./src",
"homepage": "https://www.glam.systems",
"repository": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions anchor/programs/glam/src/instructions/jupiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub fn init_locked_voter_escrow_handler<'info>(ctx: Context<InitLockedVoterEscro
locker: ctx.accounts.locker.to_account_info(),
escrow: ctx.accounts.escrow.to_account_info(),
escrow_owner: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.signer.to_account_info(),
system_program: ctx.accounts.system_program.to_account_info(),
},
vault_signer_seeds,
Expand Down Expand Up @@ -444,7 +444,7 @@ pub fn increase_locked_amount_handler<'info>(
locker: ctx.accounts.locker.to_account_info(),
escrow: ctx.accounts.escrow.to_account_info(),
escrow_tokens: ctx.accounts.escrow_jup_ata.to_account_info(),
payer: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.signer.to_account_info(),
source_tokens: ctx.accounts.vault_jup_ata.to_account_info(),
token_program: ctx.accounts.token_program.to_account_info(),
},
Expand Down Expand Up @@ -575,7 +575,7 @@ pub fn withdraw_all_staked_jup_handler<'info>(ctx: Context<WithdrawAllStakedJup>
escrow_owner: ctx.accounts.vault.to_account_info(),
escrow_tokens: ctx.accounts.escrow_jup_ata.to_account_info(),
destination_tokens: ctx.accounts.vault_jup_ata.to_account_info(),
payer: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.signer.to_account_info(),
token_program: ctx.accounts.token_program.to_account_info(),
},
vault_signer_seeds,
Expand Down Expand Up @@ -633,7 +633,7 @@ pub fn withdraw_partial_unstaking_handler<'info>(
partial_unstake: ctx.accounts.partial_unstake.to_account_info(),
escrow_tokens: ctx.accounts.escrow_jup_ata.to_account_info(),
destination_tokens: ctx.accounts.vault_jup_ata.to_account_info(),
payer: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.signer.to_account_info(),
token_program: ctx.accounts.token_program.to_account_info(),
},
vault_signer_seeds,
Expand Down Expand Up @@ -678,7 +678,7 @@ pub fn new_vote_handler<'info>(ctx: Context<NewVote>) -> Result<()> {
JupNewVote {
proposal: ctx.accounts.proposal.to_account_info(),
vote: ctx.accounts.vote.to_account_info(),
payer: ctx.accounts.vault.to_account_info(),
payer: ctx.accounts.signer.to_account_info(),
system_program: ctx.accounts.system_program.to_account_info(),
},
vault_signer_seeds,
Expand Down
4 changes: 3 additions & 1 deletion anchor/src/client/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ export class BaseClient {
isPhantom(): boolean {
// TODO: Phantom can automatically estimates fees
// https://docs.phantom.app/developer-powertools/solana-priority-fees#how-phantom-applies-priority-fees-to-dapp-transactions
return false;
return (
window?.phantom?.solana?.isPhantom && window?.phantom?.solana?.isConnected
);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions anchor/src/client/jupiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export class JupiterClient {
const escrowAccountInfo =
await this.base.provider.connection.getAccountInfo(escrow);
const escrowCreated = escrowAccountInfo ? true : false;
const preInstructions = [];
const preInstructions = txOptions.preInstructions || [];
console.log("preInstructions", preInstructions);
if (!escrowCreated) {
console.log("Will create escrow account:", escrow.toBase58());
preInstructions.push(
Expand All @@ -149,7 +150,7 @@ export class JupiterClient {
),
);

return await this.base.program.methods
const tx = await this.base.program.methods
.increaseLockedAmount(amount)
.accounts({
state: statePda,
Expand All @@ -159,7 +160,15 @@ export class JupiterClient {
vaultJupAta,
})
.preInstructions(preInstructions)
.rpc();
.transaction();

const vTx = await this.base.intoVersionedTransaction({
tx,
lookupTables: [],
...txOptions,
});

return await this.base.sendAndConfirm(vTx);
}

public async unstakeJup(statePda: PublicKey, txOptions: TxOptions = {}) {
Expand Down
1 change: 0 additions & 1 deletion apps/fatcat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lint": "next lint"
},
"dependencies": {
"@glamsystems/glam-sdk": "file:../../anchor",
"@heroicons/react": "^2.1.5",
"@hookform/resolvers": "^3.9.1",
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
Expand Down
Loading

0 comments on commit 3dec231

Please sign in to comment.