Skip to content

Poolside on Arbitrum #99

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/deploy/arbitrum/adapters/poolside/poolside.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const {deployAdapter, addresses} = require('../../../utils')
const {ButtonTokenFactory, PoolsideV1Factory} = addresses.arbitrum.other

const networkName = 'arbitrum'
const tags = ['poolside']
const name = 'PoolsideV1Adapter'
const contractName = 'PoolsideV1Adapter'

const gasEstimate = 415_000
const _buttonswapFactory = PoolsideV1Factory
const _buttonTokenFactory = ButtonTokenFactory
const args = [name, _buttonswapFactory, _buttonTokenFactory, gasEstimate]

module.exports = deployAdapter(networkName, tags, name, contractName, args)
8 changes: 6 additions & 2 deletions src/misc/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"STG": "0x6694340fc020c5E6B96567843da2df01b2CE1eb6",
"USDs": "0xD74f5255D557944cf7Dd0E45FF521520002D5748",
"ARB": "0x912CE59144191C1204E64559FE8253a0e49E6548",
"crvUSD": "0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5"
"crvUSD": "0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5",
"cbETH": "0x1DEBd73E752bEaF79865Fd6446b0c970EaE7732f",
"rcbETH": "0xdB719A1A0fB8E2eB362A4d919a2e27e4275aCccD"
},
"sushiswap": {
"router": "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
Expand Down Expand Up @@ -142,7 +144,9 @@
"other": {
"woofiV2Pool": "0xeFF23B4bE1091b53205E35f3AfCD9C7182bf3062",
"lb_router": "0x7BFd7192E76D950832c77BB412aaE841049D8D9B",
"algebraQuoter": "0x11E68A3CE9A5A0F95ca9c4B0B8F17849752e24DD"
"algebraQuoter": "0x11E68A3CE9A5A0F95ca9c4B0B8F17849752e24DD",
"PoolsideV1Factory": "0xdb55fdd06134424372eF3458Da3CcC20e3A6Ca16",
"ButtonTokenFactory": "0x06fE30A0A8E2eC5c8a9C9643F32acA8DB909227F"
}
},
"aurora": {
Expand Down
84 changes: 84 additions & 0 deletions src/test/spec/arbitrum/adapters/poolside.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const {setTestEnv, addresses} = require('../../../utils/test-env')
const {ButtonTokenFactory, PoolsideV1Factory} = addresses.arbitrum.other


describe('YakAdapter - PoolsideV1', () => {

let testEnv
let tkns
let ate // adapter-test-env

before(async () => {
const networkName = 'arbitrum'
const forkBlockNumber = 189980639
testEnv = await setTestEnv(networkName, forkBlockNumber)
tkns = testEnv.supportedTkns

const contractName = 'PoolsideV1Adapter'
const adapterArgs = ['PoolsideV1Adapter', PoolsideV1Factory, ButtonTokenFactory, 415_000]
ate = await testEnv.setAdapterEnv(contractName, adapterArgs)
})

beforeEach(async () => {
testEnv.updateTrader()
})

const testConfigs = [
// WETH -> cbETH direction:
// zero hops, swap using PoolsideV1
{tokenIn: 'WETH', tokenOut: 'rcbETH'},
// zero hops, swap using ButtonWrappers
{tokenIn: 'rcbETH', tokenOut: 'cbETH'},
// one hop, swap via PoolsideV1 then swap via ButtonWrappers
{tokenIn: 'WETH', tokenOut: 'cbETH'},

// cbETH -> WETH direction:
// zero hops, swap using ButtonWrappers
{tokenIn: 'cbETH', tokenOut: 'rcbETH'},
// zero hops, swap using PoolsideV1
{tokenIn: 'rcbETH', tokenOut: 'WETH'},
// one hop, swap via ButtonWrappers then swap via PoolsideV1
{tokenIn: 'cbETH', tokenOut: 'WETH'},
];

describe('Query is non-zero for supported pairs', async () => {
for (const {tokenIn, tokenOut} of testConfigs) {
it(`${tokenIn} -> ${tokenOut}`, async () => {
await ate.checkQueryReturnsNonZeroForSupportedTkns(tkns[tokenIn], tkns[tokenOut]);
});
}
})

describe('Swapping matches query', async () => {
for (const {tokenIn, tokenOut} of testConfigs) {
if (tokenIn === 'rcbETH') {
// re-enable if a workaround for setERC20Bal not working for rcbETH is found
continue;
}
it(`${tokenIn} -> ${tokenOut}`, async () => {
await ate.checkQueryReturnsNonZeroForSupportedTkns(tkns[tokenIn], tkns[tokenOut]);
});
}
})

it('Query returns zero if tokens not found', async () => {
const supportedTkn = tkns.WETH
ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn)
})

describe('Max-gas-used is less than 110% gas-estimate', async () => {
for (const {tokenIn, tokenOut} of testConfigs) {
if (tokenIn === 'rcbETH') {
// re-enable if a workaround for setERC20Bal not working for rcbETH is found
continue;
}
it(`${tokenIn} -> ${tokenOut}`, async () => {
const options = [
['1', tkns[tokenIn], tkns[tokenOut]]
];
await ate.checkGasUsedBelowEstimate(options);
});
}
})

})