diff --git a/anchor/src/client/jupiter.ts b/anchor/src/client/jupiter.ts index 75a5ac1a..5215129e 100644 --- a/anchor/src/client/jupiter.ts +++ b/anchor/src/client/jupiter.ts @@ -254,7 +254,9 @@ export class JupiterClient { ); const delta = amount - wsolBalance; if (solBalance < delta) { - throw new Error("Insufficient balance in treasury for swap"); + throw new Error( + `Insufficient balance in treasury (${treasuryPda.toBase58()}) for swap. solBalance: ${solBalance}, lamports needed: ${delta}` + ); } if (delta > 0 && solBalance > delta) { preInstructions.push( diff --git a/anchor/src/client/staking.ts b/anchor/src/client/staking.ts index 25560060..cc1e19e4 100644 --- a/anchor/src/client/staking.ts +++ b/anchor/src/client/staking.ts @@ -216,9 +216,6 @@ export class StakingClient { withdrawAuthority ); - console.log("withdrawAuthority:", withdrawAuthority); - console.log("validatorStakeAccounts:", validatorStakeAccounts); - const stakeAccountId = Date.now().toString(); const [stakeAccountPda, bump] = this.getStakeAccountPDA( fund, diff --git a/anchor/tests/glam_api_tx.spec.ts b/anchor/tests/glam_api_tx.spec.ts index ec3c3c8e..7308fb42 100644 --- a/anchor/tests/glam_api_tx.spec.ts +++ b/anchor/tests/glam_api_tx.spec.ts @@ -188,13 +188,13 @@ describe("glam_api_tx", () => { }, 30_000); it("Natively stake 2 SOL to a validator", async () => { - const response = await fetch(`${API}/tx/stake/deposit`, { + const response = await fetch(`${API}/tx/stake/delegate`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ fund, signer: manager, - validator_vote: "J2nUHEAgZFRyuJbFjdqPrAa9gyWDuc7hErtDQHPhsYRp", + validator_vote: "GJQjnyhSG9jN1AdMHTSyTxUR44hJHEGCmNzkidw9z3y8", amount: 2_000_000_000, }), }); @@ -212,7 +212,7 @@ describe("glam_api_tx", () => { }); it("Stake 2 SOL to jito", async () => { - const response = await fetch(`${API}/tx/stakepool/deposit`, { + const response = await fetch(`${API}/tx/stakepool/deposit_sol`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ @@ -236,7 +236,7 @@ describe("glam_api_tx", () => { }); it("Withdraw 1 jitoSOL to a stake account", async () => { - const response = await fetch(`${API}/tx/stakepool/withdraw`, { + const response = await fetch(`${API}/tx/stakepool/withdraw_stake`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ @@ -317,7 +317,7 @@ describe("glam_api_tx", () => { }); it("Stake 0.1 SOL to marinade", async () => { - const response = await fetch(`${API}/tx/marinade/stake`, { + const response = await fetch(`${API}/tx/marinade/deposit_sol`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ manager, fund, amount: 100_000_000 }), @@ -336,7 +336,7 @@ describe("glam_api_tx", () => { }, 30_000); it("Order unstake #0: 0.01 mSOL", async () => { - const response = await fetch(`${API}/tx/marinade/unstake`, { + const response = await fetch(`${API}/tx/marinade/delayed_unstake`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ manager, fund, amount: 20_000_000 }), @@ -355,7 +355,7 @@ describe("glam_api_tx", () => { }, 30_000); it("Order unstake #1: 0.02 mSOL", async () => { - const response = await fetch(`${API}/tx/marinade/unstake`, { + const response = await fetch(`${API}/tx/marinade/delayed_unstake`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ manager, fund, amount: 10_000_000 }), @@ -376,7 +376,7 @@ describe("glam_api_tx", () => { it("Claim marinade tickets", async () => { // Before claiming we should have 2 tickets const { tickets } = await ( - await fetch(`${API}/fund/${fund}/tickets`) + await fetch(`${API}/funds/${fund}/tickets`) ).json(); expect(tickets.length).toBe(2); @@ -384,7 +384,7 @@ describe("glam_api_tx", () => { await sleep(30_000); // Claim tickets - const response = await fetch(`${API}/tx/marinade/unstake/claim`, { + const response = await fetch(`${API}/tx/marinade/claim_tickets`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ manager, fund, tickets }), @@ -403,7 +403,7 @@ describe("glam_api_tx", () => { // After claiming we should have 0 tickets const { tickets: _tickets } = await ( - await fetch(`${API}/fund/${fund}/tickets`) + await fetch(`${API}/funds/${fund}/tickets`) ).json(); expect(_tickets.length).toBe(0); }, 35_000); diff --git a/anchor/tests/glam_staking.spec.ts b/anchor/tests/glam_staking.spec.ts index 71b111da..ce00bef2 100644 --- a/anchor/tests/glam_staking.spec.ts +++ b/anchor/tests/glam_staking.spec.ts @@ -39,7 +39,7 @@ describe("glam_staking", () => { try { const txSig = await glamClient.staking.initializeAndDelegateStake( fundPDA, - new PublicKey("J2nUHEAgZFRyuJbFjdqPrAa9gyWDuc7hErtDQHPhsYRp"), + new PublicKey("GJQjnyhSG9jN1AdMHTSyTxUR44hJHEGCmNzkidw9z3y8"), new BN(10_000_000_000) ); console.log("nativeStakeDeposit tx:", txSig); diff --git a/api/src/routers/tx.ts b/api/src/routers/tx.ts index f40d6b0f..bfd96cee 100644 --- a/api/src/routers/tx.ts +++ b/api/src/routers/tx.ts @@ -91,7 +91,7 @@ router.post("/tx/jupiter/swap", async (req, res) => { * Marinade */ -router.post("/tx/marinade/stake", async (req, res) => { +router.post("/tx/marinade/deposit_sol", async (req, res) => { const fund = validatePubkey(req.body.fund); const amount = validateBN(req.body.amount); @@ -99,11 +99,15 @@ router.post("/tx/marinade/stake", async (req, res) => { return res.status(400).send({ error: "Invalid fund or amount" }); } - const tx = await req.client.marinade.stakeTx(fund, amount, req.apiOptions); + const tx = await req.client.marinade.depositSolTx( + fund, + amount, + req.apiOptions + ); return await serializeTx(tx, res); }); -router.post("/tx/marinade/unstake", async (req, res) => { +router.post("/tx/marinade/delayed_unstake", async (req, res) => { const fund = validatePubkey(req.body.fund); const amount = validateBN(req.body.amount); @@ -119,7 +123,7 @@ router.post("/tx/marinade/unstake", async (req, res) => { return await serializeTx(tx, res); }); -router.post("/tx/marinade/unstake/claim", async (req, res) => { +router.post("/tx/marinade/claim_tickets", async (req, res) => { const fund = validatePubkey(req.body.fund); if (!fund) { return res.status(400).send({ error: "Invalid fund" }); @@ -138,7 +142,7 @@ router.post("/tx/marinade/unstake/claim", async (req, res) => { return validTicket; }); - const tx = await req.client.marinade.delayedUnstakeClaimTx( + const tx = await req.client.marinade.claimTicketsTx( fund, validatedTickets, req.apiOptions @@ -149,7 +153,7 @@ router.post("/tx/marinade/unstake/claim", async (req, res) => { /* * Stake pools */ -router.post("/tx/stakepool/deposit", async (req, res) => { +router.post("/tx/stakepool/deposit_sol", async (req, res) => { const fund = validatePubkey(req.body.fund); const stakePool = validatePubkey(req.body.stake_pool); const amount = validateBN(req.body.amount); @@ -169,7 +173,7 @@ router.post("/tx/stakepool/deposit", async (req, res) => { return await serializeTx(tx, res); }); -router.post("/tx/stakepool/withdraw", async (req, res) => { +router.post("/tx/stakepool/withdraw_stake", async (req, res) => { const fund = validatePubkey(req.body.fund); const stakePool = validatePubkey(req.body.stake_pool); const amount = validateBN(req.body.amount); @@ -193,7 +197,7 @@ router.post("/tx/stakepool/withdraw", async (req, res) => { * Stake program (aka native staking) */ -router.post("/tx/stake/deposit", async (req, res) => { +router.post("/tx/stake/delegate", async (req, res) => { const fund = validatePubkey(req.body.fund); const vote = validatePubkey(req.body.validator_vote); const amount = validateBN(req.body.amount); @@ -204,7 +208,7 @@ router.post("/tx/stake/deposit", async (req, res) => { .send({ error: "Invalid input of fund, stakePool, or amount" }); } - const tx = await req.client.staking.nativeStakeDepositTx( + const tx = await req.client.staking.initializeAndDelegateStakeTx( fund, vote, amount,