Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazia authored and github-actions[bot] committed Nov 21, 2023
1 parent 4c362d8 commit 9f4c6a5
Show file tree
Hide file tree
Showing 6 changed files with 2,179 additions and 2,367 deletions.
12 changes: 3 additions & 9 deletions packages/balancer/src/Balancer.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { apply } from '@rabbitholegg/questdk/filter'
import { apply } from '@rabbitholegg/questdk/filter'
import { describe, expect, test } from 'vitest'
import { DEFAULT_TOKEN_LIST } from './contract-addresses'
import { failingTestCases, passingTestCases } from './test-setup'
import { getAddress } from 'viem'

describe('Given the balancer plugin', () => {
describe('When handling the bridge', () => {
test('should return a valid action filter', () => {})

test('should return a valid action filter', () => {

})
test('should pass filter with valid transactions', () => {})

test('should pass filter with valid transactions', () => {

})

describe('should pass filter when all parameters are valid', () => {
passingTestCases.forEach((testCase) => {
const { transaction, params, description } = testCase
Expand Down Expand Up @@ -54,6 +49,5 @@ describe('Given the balancer plugin', () => {
expect(notChecksummed).to.be.empty
})
})

})
})
26 changes: 15 additions & 11 deletions packages/balancer/src/Balancer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

import { type TransactionFilter, type SwapActionParams, compressJson } from '@rabbitholegg/questdk'
import {
type TransactionFilter,
type SwapActionParams,
compressJson,
} from '@rabbitholegg/questdk'
import { type Address } from 'viem'
import { BALANCER_ABI } from './abi'
import { FilterOperator } from '@rabbitholegg/questdk'


export const buildPathQuery = (In?: string, Out?: string) => {
// v2 paths are formatted as [<token>, <token>]
const conditions: FilterOperator[] = []
Expand All @@ -22,7 +24,9 @@ export const buildPathQuery = (In?: string, Out?: string) => {
}
}

export const swap = async (swap: SwapActionParams): Promise<TransactionFilter> => {
export const swap = async (
swap: SwapActionParams,
): Promise<TransactionFilter> => {
const {
chainId,
contractAddress,
Expand All @@ -36,7 +40,7 @@ export const swap = async (swap: SwapActionParams): Promise<TransactionFilter> =
// We always want to return a compressed JSON object which we'll transform into a TransactionFilter
return compressJson({
chainId: chainId, // The chainId of the source chain
to: 0x0, // The contract address of the bridge
to: 0x0, // The contract address of the bridge
input: {
$abiAbstract: BALANCER_ABI,
$or: [
Expand All @@ -52,18 +56,18 @@ export const swap = async (swap: SwapActionParams): Promise<TransactionFilter> =
assets: buildPathQuery(tokenIn, tokenOut),
recipient: recipient,
limits: buildPathQuery(amountIn, amountOut),
}
]
}, // The input object is where we'll put the ABI and the parameters
},
],
}, // The input object is where we'll put the ABI and the parameters
})
}

export const getSupportedTokenAddresses = async (_chainId: number): Promise<Address[]> => {
export const getSupportedTokenAddresses = async (
_chainId: number,
): Promise<Address[]> => {
// Given a specific chain we would expect this function to return a list of supported token addresses
}


export const getSupportedChainIds = async (): Promise<number[]> => {
// This should return all of the ChainIds that are supported by the Project we're integrating

}
234 changes: 117 additions & 117 deletions packages/balancer/src/abi.ts
Original file line number Diff line number Diff line change
@@ -1,183 +1,183 @@
export const BALANCER_ABI = [
{
"inputs": [
inputs: [
{
"internalType": "enum IVault.SwapKind",
"name": "kind",
"type": "uint8"
internalType: 'enum IVault.SwapKind',
name: 'kind',
type: 'uint8',
},
{
"components": [
components: [
{
"internalType": "bytes32",
"name": "poolId",
"type": "bytes32"
internalType: 'bytes32',
name: 'poolId',
type: 'bytes32',
},
{
"internalType": "uint256",
"name": "assetInIndex",
"type": "uint256"
internalType: 'uint256',
name: 'assetInIndex',
type: 'uint256',
},
{
"internalType": "uint256",
"name": "assetOutIndex",
"type": "uint256"
internalType: 'uint256',
name: 'assetOutIndex',
type: 'uint256',
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
internalType: 'uint256',
name: 'amount',
type: 'uint256',
},
{
"internalType": "bytes",
"name": "userData",
"type": "bytes"
}
internalType: 'bytes',
name: 'userData',
type: 'bytes',
},
],
"internalType": "struct IVault.BatchSwapStep[]",
"name": "swaps",
"type": "tuple[]"
internalType: 'struct IVault.BatchSwapStep[]',
name: 'swaps',
type: 'tuple[]',
},
{
"internalType": "contract IAsset[]",
"name": "assets",
"type": "address[]"
internalType: 'contract IAsset[]',
name: 'assets',
type: 'address[]',
},
{
"components": [
components: [
{
"internalType": "address",
"name": "sender",
"type": "address"
internalType: 'address',
name: 'sender',
type: 'address',
},
{
"internalType": "bool",
"name": "fromInternalBalance",
"type": "bool"
internalType: 'bool',
name: 'fromInternalBalance',
type: 'bool',
},
{
"internalType": "address payable",
"name": "recipient",
"type": "address"
internalType: 'address payable',
name: 'recipient',
type: 'address',
},
{
"internalType": "bool",
"name": "toInternalBalance",
"type": "bool"
}
internalType: 'bool',
name: 'toInternalBalance',
type: 'bool',
},
],
"internalType": "struct IVault.FundManagement",
"name": "funds",
"type": "tuple"
internalType: 'struct IVault.FundManagement',
name: 'funds',
type: 'tuple',
},
{
"internalType": "int256[]",
"name": "limits",
"type": "int256[]"
internalType: 'int256[]',
name: 'limits',
type: 'int256[]',
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}
internalType: 'uint256',
name: 'deadline',
type: 'uint256',
},
],
"name": "batchSwap",
"outputs": [
name: 'batchSwap',
outputs: [
{
"internalType": "int256[]",
"name": "assetDeltas",
"type": "int256[]"
}
internalType: 'int256[]',
name: 'assetDeltas',
type: 'int256[]',
},
],
"stateMutability": "payable",
"type": "function"
stateMutability: 'payable',
type: 'function',
},
{
"inputs": [
inputs: [
{
"components": [
components: [
{
"internalType": "bytes32",
"name": "poolId",
"type": "bytes32"
internalType: 'bytes32',
name: 'poolId',
type: 'bytes32',
},
{
"internalType": "enum IVault.SwapKind",
"name": "kind",
"type": "uint8"
internalType: 'enum IVault.SwapKind',
name: 'kind',
type: 'uint8',
},
{
"internalType": "contract IAsset",
"name": "assetIn",
"type": "address"
internalType: 'contract IAsset',
name: 'assetIn',
type: 'address',
},
{
"internalType": "contract IAsset",
"name": "assetOut",
"type": "address"
internalType: 'contract IAsset',
name: 'assetOut',
type: 'address',
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
internalType: 'uint256',
name: 'amount',
type: 'uint256',
},
{
"internalType": "bytes",
"name": "userData",
"type": "bytes"
}
internalType: 'bytes',
name: 'userData',
type: 'bytes',
},
],
"internalType": "struct IVault.SingleSwap",
"name": "singleSwap",
"type": "tuple"
internalType: 'struct IVault.SingleSwap',
name: 'singleSwap',
type: 'tuple',
},
{
"components": [
components: [
{
"internalType": "address",
"name": "sender",
"type": "address"
internalType: 'address',
name: 'sender',
type: 'address',
},
{
"internalType": "bool",
"name": "fromInternalBalance",
"type": "bool"
internalType: 'bool',
name: 'fromInternalBalance',
type: 'bool',
},
{
"internalType": "address payable",
"name": "recipient",
"type": "address"
internalType: 'address payable',
name: 'recipient',
type: 'address',
},
{
"internalType": "bool",
"name": "toInternalBalance",
"type": "bool"
}
internalType: 'bool',
name: 'toInternalBalance',
type: 'bool',
},
],
"internalType": "struct IVault.FundManagement",
"name": "funds",
"type": "tuple"
internalType: 'struct IVault.FundManagement',
name: 'funds',
type: 'tuple',
},
{
"internalType": "uint256",
"name": "limit",
"type": "uint256"
internalType: 'uint256',
name: 'limit',
type: 'uint256',
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}
internalType: 'uint256',
name: 'deadline',
type: 'uint256',
},
],
"name": "swap",
"outputs": [
name: 'swap',
outputs: [
{
"internalType": "uint256",
"name": "amountCalculated",
"type": "uint256"
}
internalType: 'uint256',
name: 'amountCalculated',
type: 'uint256',
},
],
"stateMutability": "payable",
"type": "function"
}
]
stateMutability: 'payable',
type: 'function',
},
]
Loading

0 comments on commit 9f4c6a5

Please sign in to comment.