Skip to content

Commit

Permalink
chore(deps): update dependency prettier to v3 (#119)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency prettier to v3

* new prettier

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Aaron <[email protected]>
  • Loading branch information
renovate[bot] and aaronmgdr authored Nov 30, 2023
1 parent ad663a7 commit 4ff0968
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 108 deletions.
20 changes: 10 additions & 10 deletions apps/firebase/scripts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yargs
'deploy:functions',
'Deploy Project firebase functions',
(x) => x,
() => deployFunctions()
() => deployFunctions(),
)
.command(
'accounts:get',
Expand All @@ -24,7 +24,7 @@ yargs
description: 'Name of network',
demandOption: true,
}),
(args) => printAccounts(args.net)
(args) => printAccounts(args.net),
)
.command(
'accounts:clear',
Expand All @@ -35,7 +35,7 @@ yargs
description: 'Name of network',
demandOption: true,
}),
(args) => clearAccounts(args.net)
(args) => clearAccounts(args.net),
)
.command(
'accounts:add <pk> <address>',
Expand All @@ -56,7 +56,7 @@ yargs
description: 'Address. Format 0x...',
})
.demand(['pk', 'address']),
(args) => addAccount(args.net, args.pk, args.address)
(args) => addAccount(args.net, args.pk, args.address),
)
.command(
'faucet:request <to>',
Expand All @@ -73,7 +73,7 @@ yargs
description: 'Address',
demand: true,
}),
(args) => enqueueFundRequest(args.net, args.to)
(args) => enqueueFundRequest(args.net, args.to),
)
.command(
'config:get',
Expand All @@ -83,7 +83,7 @@ yargs
type: 'string',
description: 'Name of network',
}),
(args) => printConfig(args.net)
(args) => printConfig(args.net),
)
.command(
'config:set',
Expand Down Expand Up @@ -144,7 +144,7 @@ yargs
if (args.deploy) {
deployFunctions()
}
}
},
).argv

function setConfig(network: string, config: Partial<NetworkConfig>) {
Expand All @@ -157,13 +157,13 @@ function setConfig(network: string, config: Partial<NetworkConfig>) {
setIfPresent('authenticated_gold_amount', config.authenticatedGoldAmount),
setIfPresent(
'authenticated_stable_amount',
config.authenticatedStableAmount
config.authenticatedStableAmount,
),
setIfPresent('big_faucet_safe_address', config.bigFaucetSafeAddress),
setIfPresent('big_faucet_safe_amount', config.bigFaucetSafeAmount),
setIfPresent(
'big_faucet_safe_stables_amount',
config.bigFaucetSafeStablesAmount
config.bigFaucetSafeStablesAmount,
),
].join(' ')
execSync(`yarn firebase functions:config:set ${variables}`, {
Expand Down Expand Up @@ -222,6 +222,6 @@ function deployFunctions() {
`yarn firebase deploy --only functions:faucetRequestProcessor,functions:bigFaucetFunder,functions:topUp`,
{
stdio: 'inherit',
}
},
)
}
4 changes: 2 additions & 2 deletions apps/firebase/scripts/transfer-funds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ yargs
console.error('Failed')
console.error(err)
}
}
},
).argv

async function transferFunds(args: {
Expand Down Expand Up @@ -91,7 +91,7 @@ async function transferFunds(args: {
console.log('receipt', await tx?.sendAndWaitForReceipt())
}
await retryAsync(transferHelper, 3, [], 500)
})
}),
)
}

Expand Down
66 changes: 33 additions & 33 deletions apps/firebase/src/celo-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CeloAdapter {

async transferGold(
to: string,
amount: string
amount: string,
): Promise<CeloTransactionObject<boolean>> {
const goldToken = await this.kit.contracts.getGoldToken()
return goldToken.transfer(to, amount)
Expand All @@ -68,7 +68,7 @@ export class CeloAdapter {
await this.kit.celoTokens.forStableCeloToken(async (info) => {
try {
const stableToken = await this.kit.celoTokens.getWrapper(
info.symbol as StableToken
info.symbol as StableToken,
)
const faucetBalance = await stableToken.balanceOf(this.defaultAddress)
const MIN_BALANCE_IN_WEI = '25000000000000000000000' // 25K
Expand All @@ -81,7 +81,7 @@ export class CeloAdapter {
if (mento) {
const allowanceTxObj = await mento.increaseTradingAllowance(
stableToken.address,
amount
amount,
)

const allowanceTx = await this.signer.sendTransaction(allowanceTxObj)
Expand All @@ -90,22 +90,22 @@ export class CeloAdapter {
const quoteAmountOut = await mento.getAmountOut(
stableToken.address,
celoContractAddress,
amount
amount,
)
const expectedAmountOut = quoteAmountOut.mul(99).div(100) // allow 1% slippage from quote
const swapTxObj = await mento.swapIn(
stableToken.address,
celoContractAddress,
amount,
expectedAmountOut
expectedAmountOut,
)
const swapTx = await this.signer.sendTransaction(swapTxObj)
return swapTx.wait()
} else {
// Remove block once Broker contract issues are sorted out
console.info('Using exchange contract for extra stables conversion')
const exchangeContract = await this.kit.contracts.getContract(
info.exchangeContract
info.exchangeContract,
)

const [quote] = await Promise.all([
Expand All @@ -117,7 +117,7 @@ export class CeloAdapter {

const tx = exchangeContract.sellStable(
amount,
quote.multipliedBy(0.99).integerValue(BigNumber.ROUND_UP)
quote.multipliedBy(0.99).integerValue(BigNumber.ROUND_UP),
)
return tx.sendAndWaitForReceipt()
}
Expand All @@ -135,7 +135,7 @@ export class CeloAdapter {
async transferStableTokens(
to: string,
amount: string,
alwaysTransfer: boolean = false
alwaysTransfer: boolean = false,
) {
const mento = this.mento
if (!mento && this.useMento) {
Expand All @@ -146,7 +146,7 @@ export class CeloAdapter {
return this.kit.celoTokens.forStableCeloToken(
async (info: StableTokenInfo) => {
const token = await this.kit.celoTokens.getWrapper(
info.symbol as StableToken
info.symbol as StableToken,
)
const [faucetBalance, recipientBalance] = await Promise.all([
token.balanceOf(this.defaultAddress),
Expand All @@ -158,52 +158,52 @@ export class CeloAdapter {
const realAmount = this.fadeOutAmount(
recipientBalance,
amount,
alwaysTransfer
alwaysTransfer,
)

if (realAmount.eq(0)) {
console.info(
`skipping ${
info.symbol
} for ${to} balance already ${recipientBalance.toString()}`
} for ${to} balance already ${recipientBalance.toString()}`,
)
return false
}
console.info(
`sending ${to} ${realAmount.toString()}${
info.symbol
}. Balance ${recipientBalance.toString()}`
}. Balance ${recipientBalance.toString()}`,
)

if (faucetBalance.isLessThanOrEqualTo(realAmount)) {
if (mento) {
const quoteAmountIn = await mento.getAmountIn(
celoToken.address,
stableTokenAddr,
realAmount.toString()
realAmount.toString(),
)
console.info(
`swap quote ${quoteAmountIn.toString()} for ${realAmount.toString()} `
`swap quote ${quoteAmountIn.toString()} for ${realAmount.toString()} `,
)
const maxCeloToTrade = quoteAmountIn.div(100).mul(103).toString() // 3% slippage
await this.increaseAllowanceIfNeeded(
new BigNumber(maxCeloToTrade),
info
info,
)

const swapTxObj = await mento.swapOut(
celoToken.address,
stableTokenAddr,
realAmount.toString(),
maxCeloToTrade.toString()
maxCeloToTrade.toString(),
)
console.info('swap TX', swapTxObj)
await this.signer.sendTransaction(swapTxObj)
} else {
// Remove block once Broker contract issues are sorted out
console.info('Using exchange contract for token swaps')
const exchangeContract = await this.kit.contracts.getContract(
info.exchangeContract
info.exchangeContract,
)

// this surprised me but if you want to send CELO and receive an Amount of stable, quoteGoldBuy is the function to call not quoteStableBuy
Expand All @@ -214,7 +214,7 @@ export class CeloAdapter {
.integerValue(BigNumber.ROUND_UP)
await this.increaseAllowanceIfNeeded(
maxCeloToTrade as unknown as BigNumber,
info
info,
)

await exchangeContract
Expand All @@ -224,7 +224,7 @@ export class CeloAdapter {
}

return token.transfer(to, realAmount.toString())
}
},
)
}

Expand All @@ -240,13 +240,13 @@ export class CeloAdapter {

const allowance = await celoERC20Wrapper.allowance(
this.defaultAddress,
brokerContractAddress
brokerContractAddress,
)
if (allowance.isLessThanOrEqualTo(amount)) {
// multiply by 10 so we don't have to be setting this for every transaction
const allowanceTxObj = await mento.increaseTradingAllowance(
celoERC20Wrapper.address,
amount.multipliedBy(10).integerValue(BigNumber.ROUND_UP).toString()
amount.multipliedBy(10).integerValue(BigNumber.ROUND_UP).toString(),
)
const allowanceTx = await this.signer.sendTransaction(allowanceTxObj)
const allowanceReceipt = await allowanceTx.wait()
Expand All @@ -257,18 +257,18 @@ export class CeloAdapter {
// Remove block once Broker contract issues are sorted out
console.info('Increasing allowance with exchance contract')
const exchangeContractAddress = await this.kit.registry.addressFor(
info.exchangeContract
info.exchangeContract,
)

const allowance = await celoERC20Wrapper.allowance(
this.defaultAddress,
exchangeContractAddress
exchangeContractAddress,
)
if (allowance.isLessThanOrEqualTo(amount)) {
// multiply by 10 so we don't have to be setting this for every transaction
const transaction = celoERC20Wrapper.increaseAllowance(
exchangeContractAddress,
amount.multipliedBy(10).integerValue(BigNumber.ROUND_UP)
amount.multipliedBy(10).integerValue(BigNumber.ROUND_UP),
)
const receipt = await transaction.sendAndWaitForReceipt()
console.log('increasedAllowance', receipt.transactionHash)
Expand All @@ -281,7 +281,7 @@ export class CeloAdapter {
tempWallet: string,
amount: string,
expirySeconds: number,
minAttestations: number
minAttestations: number,
): Promise<CeloTransactionObject<boolean>> {
const escrow = await this.kit.contracts.getEscrow()
const stableToken = await this.kit.contracts.getStableToken()
Expand All @@ -293,21 +293,21 @@ export class CeloAdapter {
amount,
expirySeconds,
tempWallet,
minAttestations
minAttestations,
)
}

async getDollarsBalance(
accountAddress: string = this.defaultAddress
accountAddress: string = this.defaultAddress,
): Promise<BigNumber> {
const stableToken = await this.kit.contracts.getStableToken()
return stableToken.balanceOf(
accountAddress
accountAddress,
) as unknown as Promise<BigNumber>
}

async getGoldBalance(
accountAddress: string = this.defaultAddress
accountAddress: string = this.defaultAddress,
): Promise<BigNumber> {
const goldToken = await this.kit.contracts.getGoldToken()
return goldToken.balanceOf(accountAddress) as unknown as Promise<BigNumber>
Expand All @@ -322,27 +322,27 @@ export class CeloAdapter {
fadeOutAmount(
recipientBalance: BigNumber,
amount: string,
useGivenAmount: boolean
useGivenAmount: boolean,
) {
const nextAmount = new BigNumber(amount)

if (useGivenAmount) {
return nextAmount
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(75).dividedBy(100)
HUNDRED_IN_WIE.multipliedBy(75).dividedBy(100),
)
) {
return new BigNumber(0)
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(50).dividedBy(100)
HUNDRED_IN_WIE.multipliedBy(50).dividedBy(100),
)
) {
return nextAmount.dividedBy(4)
} else if (
recipientBalance.isGreaterThan(
HUNDRED_IN_WIE.multipliedBy(25).dividedBy(100)
HUNDRED_IN_WIE.multipliedBy(25).dividedBy(100),
)
) {
return nextAmount.dividedBy(2)
Expand Down
Loading

1 comment on commit 4ff0968

@vercel
Copy link

@vercel vercel bot commented on 4ff0968 Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.