-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from 00labs/solana-autoredeem-upgrade
Solana autoredeem upgrade [do not merge]
- Loading branch information
Showing
8 changed files
with
1,528 additions
and
1,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js' | ||
import { | ||
AnchorProvider, | ||
BN, | ||
setProvider, | ||
Wallet, | ||
web3, | ||
} from '@coral-xyz/anchor' | ||
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared' | ||
import { HumaSolanaContext, HumaSolanaProgramHelper } from '@huma-finance/sdk' | ||
|
||
require('dotenv').config() | ||
|
||
async function main() { | ||
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY | ||
const connection = new Connection( | ||
'https://api.devnet.solana.com', | ||
'confirmed', | ||
) | ||
|
||
const keypair = web3.Keypair.fromSecretKey( | ||
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)), | ||
) | ||
const wallet = new Wallet(keypair) | ||
setProvider(new AnchorProvider(connection, wallet)) | ||
|
||
const solanaHumaContext = new HumaSolanaContext({ | ||
publicKey: wallet.publicKey, | ||
connection: connection, | ||
chainId: SolanaChainEnum.SolanaDevnet, | ||
poolName: POOL_NAME.ArfCreditPool3Months, | ||
}) | ||
|
||
const humaSolanaProgramHelper = new HumaSolanaProgramHelper({ | ||
solanaContext: solanaHumaContext, | ||
}) | ||
|
||
const tx = await humaSolanaProgramHelper.buildWithdrawYieldsTransaction() | ||
|
||
console.log(tx) | ||
|
||
const txResult = await sendAndConfirmTransaction(connection, tx, [keypair]) | ||
console.log(txResult) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.