Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LINK as input units to fund and withdraw funds from aggregators #459

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import { PublicKey } from '@solana/web3.js'
import { createTransferInstruction, getAssociatedTokenAddress } from '@solana/spl-token'
import { CONTRACT_LIST, getContract } from '../../../lib/contracts'
import { logger, BN, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { TOKEN_DECIMALS } from '../../../lib/constants'

type Input = {
amount: number
amount: number | string
link: string
}

export default class Fund extends SolanaCommand {
static id = 'ocr2:fund'
static category = CONTRACT_LIST.OCR_2

static examples = ['yarn gauntlet ocr2:fund --network=devnet --amount=[AMOUNT] [AGGREGATOR_ADDRESS]']
static examples = ['yarn gauntlet ocr2:fund --network=devnet --amount=[AMOUNT in LINK] [AGGREGATOR_ADDRESS]']

input: Input

Expand All @@ -39,7 +40,7 @@ export default class Fund extends SolanaCommand {
const link = this.flags.link || process.env.LINK
this.require(link, 'Please provide a link address with --link or env LINK')
return {
amount: this.flags.amount,
amount: (BigInt(this.flags.amount) * BigInt(10) ** BigInt(TOKEN_DECIMALS)).toString(),
link: this.flags.link || process.env.LINK,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token'
import { utils } from '@project-serum/anchor'
import { logger, BN, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { CONTRACT_LIST, getContract } from '../../../lib/contracts'
import { TOKEN_DECIMALS } from '../../../lib/constants'

type Input = {
amountGjuels: number | string
Expand All @@ -16,7 +17,7 @@ export default class WithdrawFunds extends SolanaCommand {
static category = CONTRACT_LIST.OCR_2

static examples = [
'yarn gauntlet ocr2:withdraw_funds --network=devnet --amount=NUM_GJUELS --recipient=YOUR_LINK_ACCOUNT AGGREGATOR_ADDR',
'yarn gauntlet ocr2:withdraw_funds --network=devnet --amount=NUM_LINK --recipient=YOUR_LINK_ACCOUNT AGGREGATOR_ADDR',
'yarn gauntlet ocr2:withdraw_funds --network=devnet --amount=100 --recipient=FTH1Kqvr5BhiAA786DdQVBQYJ1bs5XhKwTEETKCqYwMh 9hBz81AnfoeGgqVqQHKBiAXGJ2hKAs7A2KYFxn5yGgat',
]

Expand All @@ -26,15 +27,15 @@ export default class WithdrawFunds extends SolanaCommand {
if (userInput) return userInput as Input

if (!this.flags.amount) {
throw Error('Please specify --amount to withdraw')
throw Error('Please specify --amount to withdraw (in LINK)')
}

if (!this.flags.recipient) {
throw Error('Please specify --recipient of withdrawal')
}

return {
amountGjuels: this.flags.amount,
amountGjuels: (BigInt(this.flags.amount) * BigInt(10) ** BigInt(TOKEN_DECIMALS)).toString(),
recipient: new PublicKey(this.flags.recipient),
}
}
Expand Down