Skip to content

Commit

Permalink
Redeem and cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
mliu committed Sep 7, 2024
1 parent f4e6f3d commit 702ced7
Show file tree
Hide file tree
Showing 25 changed files with 4,596 additions and 2,520 deletions.
2 changes: 1 addition & 1 deletion packages/huma-shared/src/solana/ProgramHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AnchorProvider, Program } from '@coral-xyz/anchor'
import { AnchorWallet } from '@solana/wallet-adapter-react'
import { Connection } from '@solana/web3.js'
import { HumaSolana as HumaSolanaDevnet } from '../v2/idl/devnet'
import { Huma as HumaSolanaDevnet } from '../v2/idl/devnet'
import HumaDevnetIDL from '../v2/idl/devnet.json'
import { SolanaChainEnum } from '../utils'

Expand Down
30 changes: 27 additions & 3 deletions packages/huma-shared/src/solana/TokenAccountHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { SolanaPoolInfo } from '../v2'
export const getTokenAccounts = (
poolInfo: SolanaPoolInfo,
account: PublicKey,
): [PublicKey, PublicKey, PublicKey] => {
): {
underlyingTokenATA: PublicKey
seniorTrancheATA: PublicKey
juniorTrancheATA: PublicKey
poolSeniorTrancheATA: PublicKey
poolJuniorTrancheATA: PublicKey
} => {
const underlyingTokenATA = getAssociatedTokenAddressSync(
new PublicKey(poolInfo.underlyingMint.address),
account,
Expand All @@ -22,11 +28,29 @@ export const getTokenAccounts = (
TOKEN_2022_PROGRAM_ID,
)
const seniorTrancheATA = getAssociatedTokenAddressSync(
new PublicKey(poolInfo.juniorTrancheMint),
new PublicKey(poolInfo.seniorTrancheMint),
account,
false,
TOKEN_2022_PROGRAM_ID,
)
const poolJuniorTrancheATA = getAssociatedTokenAddressSync(
new PublicKey(poolInfo.juniorTrancheMint),
new PublicKey(poolInfo.poolAuthority),
true,
TOKEN_2022_PROGRAM_ID,
)
const poolSeniorTrancheATA = getAssociatedTokenAddressSync(
new PublicKey(poolInfo.seniorTrancheMint),
new PublicKey(poolInfo.poolAuthority),
true,
TOKEN_2022_PROGRAM_ID,
)

return [underlyingTokenATA, juniorTrancheATA, seniorTrancheATA]
return {
underlyingTokenATA,
seniorTrancheATA,
juniorTrancheATA,
poolJuniorTrancheATA,
poolSeniorTrancheATA,
}
}
Loading

0 comments on commit 702ced7

Please sign in to comment.