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

Release 1.1.4 #529

Merged
merged 115 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
2ea57f5
Add FX custom swap fees to multicall onChainData fetch
brunoguerios Jul 26, 2023
1dbcc8c
Bump SOR.
johngrantuk Jul 28, 2023
99c28a8
Merge pull request #502 from balancer/sor-4.1.1-beta.14
johngrantuk Jul 28, 2023
6bae400
chore: version bump v1.1.4-beta.0
johngrantuk Jul 28, 2023
0d81846
Add Base config
timjrobinson Jul 26, 2023
a1224b4
Merge pull request #503 from balancer/feat/base
johngrantuk Jul 31, 2023
a8e5c28
chore: version bump v1.1.4-beta.1
johngrantuk Jul 31, 2023
c0c288f
Add a launch.json file to improve vscode debugging
brunoguerios Jul 31, 2023
ad79392
Changing BAL address
Jul 31, 2023
7a25228
Merge pull request #505 from balancer/xave-apr-error
johngrantuk Aug 1, 2023
ca46dd6
chore: version bump v1.1.4-beta.2
johngrantuk Aug 1, 2023
372ce31
Add example for retrieving volume on Avalanche
timjrobinson Aug 1, 2023
d97eaf2
Add block number subgraph in config
timjrobinson Aug 1, 2023
ce471de
Merge pull request #506 from balancer/avalanche-volume
johngrantuk Aug 1, 2023
02f158c
chore: version bump v1.1.4-beta.3
johngrantuk Aug 1, 2023
53ed28c
Revert to layer0 BAL.
johngrantuk Aug 1, 2023
05b7b03
Merge pull request #507 from balancer/revert-bal-avax
johngrantuk Aug 1, 2023
d1780bb
chore: version bump v1.1.4-beta.4
johngrantuk Aug 1, 2023
ad1b01f
Add .vscode to gitignore
brunoguerios Aug 1, 2023
4af20d8
Remove FX filter.
johngrantuk Aug 1, 2023
ab4bb25
Delete launch.json
brunoguerios Aug 1, 2023
9fe2583
Merge pull request #508 from balancer/renable-fx
johngrantuk Aug 1, 2023
569225c
Merge pull request #504 from balancer/vscode-debugging-launch-json
johngrantuk Aug 1, 2023
23136e8
chore: version bump v1.1.4-beta.5
johngrantuk Aug 1, 2023
8dab23e
Bump SOR to sor-4.1.1-beta.15.
johngrantuk Aug 1, 2023
9e1a87f
Merge pull request #509 from balancer/sor-4.1.1-beta.15
johngrantuk Aug 1, 2023
de87c26
chore: version bump v1.1.4-beta.6
johngrantuk Aug 1, 2023
da98d40
Add Avax connecting tokens.
johngrantuk Aug 3, 2023
4bc51b3
Merge pull request #510 from balancer/connecting-tokens
johngrantuk Aug 3, 2023
1103c78
chore: version bump v1.1.4-beta.7
johngrantuk Aug 3, 2023
c110b6b
Add blockNumberSubgraph for Base
timjrobinson Aug 3, 2023
1af94bd
Merge pull request #511 from balancer/add-base-blocks
johngrantuk Aug 3, 2023
d2e1a40
chore: version bump v1.1.4-beta.8
johngrantuk Aug 3, 2023
70759e0
Adding fetch of protocol swap fee percentage from GyroConfig contract…
Aug 3, 2023
3fb00c5
Fixing Warning: Duplicate definition of ConfigChanged (ConfigChanged(…
Aug 4, 2023
986414d
Adding config for avalanche hardhat node;
Aug 4, 2023
3d9d65c
fix zkevm gauges inflation rate
mendesfabio Aug 4, 2023
714503f
update zkevm rpc url
mendesfabio Aug 4, 2023
3d017c4
Turning GyroConfig fetcher into a repository;
Aug 4, 2023
2ad2143
Merge pull request #514 from balancer/fix-zkevm-gauges-inflation-rate
johngrantuk Aug 6, 2023
b764d37
chore: version bump v1.1.4-beta.9
johngrantuk Aug 6, 2023
e5e873e
Merge pull request #499 from balancer/fx-custom-swap-fee
johngrantuk Aug 7, 2023
5ecb34f
chore: version bump v1.1.4-beta.10
johngrantuk Aug 7, 2023
8e4d44d
Merge pull request #513 from balancer/add-avax-node-config
johngrantuk Aug 7, 2023
afe38c3
chore: version bump v1.1.4-beta.11
johngrantuk Aug 7, 2023
cce49cf
Lint fix.
johngrantuk Aug 7, 2023
235c006
using multicall to verify keys on gyroConfig;
Aug 7, 2023
57e0421
fix lint;
Aug 8, 2023
e388da6
changing to if else;
Aug 8, 2023
12fd957
Make param and constant.
johngrantuk Aug 8, 2023
4168fca
Merge pull request #512 from balancer/apr-gyro-config
lgahdl Aug 8, 2023
5168c89
chore: version bump v1.1.4-beta.12
johngrantuk Aug 8, 2023
0f5fe95
Fix resetting skip variable when loading pools from Balancer API
timjrobinson Aug 9, 2023
5a75494
Bump SOR to 4.1.1-beta.16 - has tri hop support.
johngrantuk Aug 9, 2023
ceb0e9e
Add triPathMidPoolIds as part of config.
johngrantuk Aug 9, 2023
26d9b67
Add BASE staBal midpool id.
johngrantuk Aug 9, 2023
90719fd
Merge pull request #516 from balancer/sor-with-tripaths
johngrantuk Aug 9, 2023
9cd6305
chore: version bump v1.1.4-beta.13
johngrantuk Aug 9, 2023
8ef236f
Merge pull request #515 from balancer/fix-balancer-api-skipping
johngrantuk Aug 10, 2023
3798833
chore: version bump v1.1.4-beta.14
johngrantuk Aug 10, 2023
bbe699d
Using gaugeControllerCheckpointer for mainnet network;
Aug 11, 2023
0f45d2a
using gaugeController when a timestamp is passed, even on Mainnet;
Aug 11, 2023
1b5719b
Refactor Balancer API fetcher to pull all pools and always use the cache
timjrobinson Aug 14, 2023
8afc50a
Remove console logs
timjrobinson Aug 14, 2023
49f03d8
Add buildRecoveryExit to pools so it can be refreshed.
johngrantuk Aug 14, 2023
12e1783
Merge pull request #519 from balancer/pools-buildRecoveryExit
johngrantuk Aug 14, 2023
9bfded1
chore: version bump v1.1.4-beta.15
johngrantuk Aug 14, 2023
c63c155
Merge pull request #517 from balancer/gauge-weight-vebal-helpers
lgahdl Aug 15, 2023
7616aac
chore: version bump v1.1.4-beta.16
johngrantuk Aug 15, 2023
682aa9d
Add recovery tests following UI flow.
johngrantuk Aug 15, 2023
ff26158
Remove getWrappedTokenRate call and associated broken tests.
johngrantuk Aug 15, 2023
120cbbe
Converting multicall hex format to boolean;
Aug 15, 2023
1c5b082
Removing APR rate calls, defaulting to 1.
johngrantuk Aug 16, 2023
01e3ab3
Filter APRs based of poolsToIgnore list.
johngrantuk Aug 16, 2023
7933fbd
Merge pull request #520 from balancer/gyro-config-apr-fix
lgahdl Aug 16, 2023
7eaa1ff
chore: version bump v1.1.4-beta.17
johngrantuk Aug 16, 2023
7fb36d9
Update Linear tests to work with recovery.
johngrantuk Aug 16, 2023
e663ca7
Add bbausd v1 generalised exit tests (currently failing).
johngrantuk Aug 17, 2023
1d99a5e
Re-enable skipped generalised tests.
johngrantuk Aug 17, 2023
e21b74e
Add batchSwap handling for swaps>1.
johngrantuk Aug 17, 2023
1f10729
Renable onchain fetching for aaveLinear V1.
johngrantuk Aug 17, 2023
e8480b3
Fix broken block in test.
johngrantuk Aug 17, 2023
74cac01
Update recovery tests to work with alternative refresh flow.
johngrantuk Aug 17, 2023
d3cd4c4
Expose toInternal on buildRecovery.
johngrantuk Aug 17, 2023
5c47959
Merge pull request #522 from balancer/expose-tointernal
brunoguerios Aug 17, 2023
9c95c69
chore: version bump v1.1.4-beta.18
johngrantuk Aug 17, 2023
23ebfce
Update StablePhantom generalisedExit to go through the non-proportion…
brunoguerios Aug 17, 2023
c005705
Refactor tests so we're able to hold pool state between them when nec…
brunoguerios Aug 17, 2023
6ba5373
Move time logs to logger
brunoguerios Aug 17, 2023
82ff532
rather comment out the implementation than its usage
danielmkm Aug 18, 2023
7d1ece9
Default rates to 1 for recovery mode.
johngrantuk Aug 18, 2023
2e280bf
Add test for CS versions.
johngrantuk Aug 18, 2023
1ac3267
Add test for Weighted versions.
johngrantuk Aug 18, 2023
db289eb
Add live example.
johngrantuk Aug 18, 2023
8bf5357
Revert "Refactor tests so we're able to hold pool state between them …
brunoguerios Aug 18, 2023
aadc392
Remove exit by unwrapping test scenarios
brunoguerios Aug 18, 2023
d2c08af
Merge pull request #523 from balancer/generalised-exit-phantom-tests
johngrantuk Aug 18, 2023
56108ec
Merge pull request #521 from balancer/generalised-exit-phantom
johngrantuk Aug 18, 2023
45d97a4
chore: version bump v1.1.4-beta.19
johngrantuk Aug 18, 2023
3c60a55
Consolidate testRecoveryExit and assertRecoveryExit
brunoguerios Aug 18, 2023
b043249
Merge branch 'develop' into response-changes
johngrantuk Aug 21, 2023
e1747ef
Fix broken test helper.
johngrantuk Aug 21, 2023
9b2f905
Update block number for polygon tests.
johngrantuk Aug 21, 2023
52456c8
Merge remote-tracking branch 'origin/develop' into refactor-balancer-…
timjrobinson Aug 21, 2023
5ddd74d
Merge pull request #524 from balancer/hotfixes-multiple
johngrantuk Aug 22, 2023
2829532
chore: version bump v1.1.4-beta.20
johngrantuk Aug 22, 2023
a061a53
Merge pull request #518 from balancer/refactor-balancer-api-fetcher
gmbronco Aug 23, 2023
d8a20c9
chore: version bump v1.1.4-beta.21
johngrantuk Aug 23, 2023
c4fbc0e
Add mid pool ids to open Aura/AuraBAL paths.
johngrantuk Aug 25, 2023
4c49be9
Merge pull request #527 from balancer/arb-mid-pool-updates
johngrantuk Aug 25, 2023
5874ca9
chore: version bump v1.1.4-beta.22
johngrantuk Aug 25, 2023
8da4354
Add mid pool ids to open Aura/AuraBAL paths. Correctly!
johngrantuk Aug 25, 2023
e9c900f
Merge pull request #528 from balancer/arb-mid-pool-updates
johngrantuk Aug 25, 2023
3bbf775
chore: version bump v1.1.4-beta.23
johngrantuk Aug 25, 2023
ac1121e
Update to 1.1.4 for release.
johngrantuk Aug 25, 2023
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
2 changes: 2 additions & 0 deletions balancer-js/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ cache/
balancer-js.iml
temp/
src/contracts/

.vscode/*
9 changes: 9 additions & 0 deletions balancer-js/examples/helpers/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,12 @@ export const getTokenBalance = async (
const erc20 = new Contract(token, iERC20, provider);
return erc20.balanceOf(account);
};

export const getNativeAssetBalance = async (
account: string,
provider: JsonRpcProvider
): Promise<string> => {
return BigNumber.from(
await provider.send('eth_getBalance', [account, 'latest'])
).toString();
};
2 changes: 1 addition & 1 deletion balancer-js/examples/pools/aprs/aprs.polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { pools } = sdk;

const main = async () => {
const pool = await pools.find(
'0x216690738aac4aa0c4770253ca26a28f0115c595000000000000000000000b2c'
'0xf0ad209e2e969eaaa8c882aac71f02d8a047d5c2000200000000000000000b49'
);

if (pool) {
Expand Down
4 changes: 2 additions & 2 deletions balancer-js/examples/pools/aprs/aprs.zkevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { BalancerSDK } from '@balancer-labs/sdk';

const sdk = new BalancerSDK({
network: 1101,
rpcUrl: 'https://rpc.ankr.com/polygon_zkevm',
rpcUrl: 'https://zkevm-rpc.com',
});

const { pools } = sdk;

const main = async () => {
const pool = await pools.find(
'0xe1f2c039a68a216de6dd427be6c60decf405762a00000000000000000000000e'
'0x1d0a8a31cdb04efac3153237526fb15cc65a252000000000000000000000000f'
);

if (pool) {
Expand Down
108 changes: 84 additions & 24 deletions balancer-js/examples/pools/exit/recovery-exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,122 @@
* Run command:
* yarn example ./examples/pools/exit/recovery-exit.ts
*/
import { FORK_NODES } from '@/test/lib/utils';
import {
BalancerSDK,
insert,
removeItem,
Network,
truncateAddresses,
} from '@balancer-labs/sdk';
import { parseEther } from '@ethersproject/units';
import { getTokenBalance, reset, setTokenBalance } from 'examples/helpers';

async function recoveryExit() {
async function recoveryExitLive() {
const network = Network.MAINNET;
const rpcUrl = FORK_NODES[network];
const poolId =
'0x20b156776114e8a801e9767d90c6ccccc8adf398000000000000000000000499';
const userAddress = '0x0000000000000000000000000000000000000000';
const bptAmount = String(parseEther('1'));
const slippage = '1'; // 1 bps = 0.1%

const balancer = new BalancerSDK({
network,
rpcUrl,
});
const { poolsOnChain, pools } = balancer.data;

// Use SDK to find pool info
let pool = await pools.find(poolId);
if (!pool) throw 'POOL_DOESNT_EXIST';

// Refresh pool data from chain before building and sending tx
pool = await poolsOnChain.refresh(pool);

// Build transaction
const { expectedAmountsOut, minAmountsOut } =
balancer.pools.buildRecoveryExit({
pool,
bptAmount,
userAddress,
slippage,
});

console.log(expectedAmountsOut.toString());
console.log(minAmountsOut.toString());
}

async function recoveryExitFork() {
const poolId =
'0x20b156776114e8a801e9767d90c6ccccc8adf398000000000000000000000499';
const blockNo = 17700000;

const balancer = new BalancerSDK({
network: Network.MAINNET,
rpcUrl: 'http://127.0.0.1:8545', // Using local fork for simulation
});
const { poolsOnChain, pools } = balancer.data;

// Setup exit parameters
const signer = balancer.provider.getSigner();
const address = await signer.getAddress();

const poolId =
// '0x50cf90b954958480b8df7958a9e965752f62712400000000000000000000046f'; // bb-e-usd
// '0xd4e7c1f3da1144c9e2cfd1b015eda7652b4a439900000000000000000000046a'; // bb-e-usdc
// '0xa13a9247ea42d743238089903570127dda72fe4400000000000000000000035d'; // bb-a-usd
'0xa718042e5622099e5f0ace4e7122058ab39e1bbe000200000000000000000475'; // 50temple_50bb-e-usd
const userAddress = await signer.getAddress();

const bptIn = String(parseEther('1'));
const bptAmount = String(parseEther('1'));
const slippage = '200'; // 200 bps = 2%

// Use SDK to find pool info
const pool = await balancer.pools.find(poolId);
let pool = await pools.find(poolId);
if (!pool) throw 'POOL_DOESNT_EXIST';

// Prepare local fork for simulation
await reset(balancer.provider, 17700000);
await setTokenBalance(balancer.provider, address, pool.address, bptIn, 0);
await reset(balancer.provider, blockNo);
await setTokenBalance(
balancer.provider,
userAddress,
pool.address,
bptAmount,
0
);

// Refresh pool data from chain before building and sending tx
pool = await poolsOnChain.refresh(pool);

// Build transaction
const { to, data, expectedAmountsOut, minAmountsOut } =
pool.buildRecoveryExit(address, bptIn, slippage);
balancer.pools.buildRecoveryExit({
pool,
bptAmount,
userAddress,
slippage,
});

// Send transaction
await signer.sendTransaction({ to, data });

// Refresh pool data from chain before building and sending tx
pool = await poolsOnChain.refresh(pool);

const bptIndex = pool.tokensList.indexOf(pool.address);
const tokensWithoutBpt =
bptIndex === -1 ? pool.tokensList : removeItem(pool.tokensList, bptIndex);
// Check balances after transaction to confirm success
const balances = await Promise.all(
pool.tokensList.map((token) =>
getTokenBalance(token, address, balancer.provider)
)
);
const balances = await Promise.all([
...tokensWithoutBpt.map((token) =>
getTokenBalance(token, userAddress, balancer.provider)
),
getTokenBalance(pool.address, userAddress, balancer.provider),
]);

console.table({
tokensOut: truncateAddresses(pool.tokensList),
minAmountsOut: insert(minAmountsOut, pool.bptIndex, bptIn),
expectedAmountsOut: insert(expectedAmountsOut, pool.bptIndex, bptIn),
amountsOut: balances.map((b) => b.toString()),
tokensOut: truncateAddresses(tokensWithoutBpt),
minAmountsOut: minAmountsOut,
expectedAmountsOut: expectedAmountsOut,
amountsOut: removeItem(balances, balances.length - 1).map((b) =>
b.toString()
),
});
console.log(`BPT Balance: `, balances[balances.length - 1].toString());
}

recoveryExit();
// recoveryExitFork();
recoveryExitLive();
34 changes: 34 additions & 0 deletions balancer-js/examples/pools/volume/volume.avalanche.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Display APRs for pool ids hardcoded under `const ids`
*
* Run command:
* yarn example ./examples/pools/volume/volume.avalanche.ts
*/
import { BalancerSDK } from '@balancer-labs/sdk';

const sdk = new BalancerSDK({
network: 43114,
rpcUrl: 'https://avalanche.public-rpc.com',
});

const { pools } = sdk;

const main = async () => {
const pool = await pools.find(
'0xa1d14d922a575232066520eda11e27760946c991000000000000000000000012'
);

if (pool) {
const volume = await pools.volume(pool);
console.table([
{
id: pool.id,
type: pool.poolType,
totalVolume: pool.totalSwapVolume,
volume,
},
]);
}
};

main();
12 changes: 12 additions & 0 deletions balancer-js/hardhat.config.avalanche.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '@nomiclabs/hardhat-ethers';

/**
* @type import('hardhat/config').HardhatUserConfig
*/
export default {
networks: {
hardhat: {
chainId: 43114,
},
},
};
5 changes: 3 additions & 2 deletions balancer-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/sdk",
"version": "1.1.3",
"version": "1.1.4",
"description": "JavaScript SDK for interacting with the Balancer Protocol V2",
"license": "GPL-3.0-only",
"homepage": "https://github.com/balancer-labs/balancer-sdk#readme",
Expand Down Expand Up @@ -35,6 +35,7 @@
"node:arbitrum": "npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.arbitrum.ts node --fork $(. ./.env && echo $ALCHEMY_URL_ARBITRUM) --port 8161",
"node:gnosis": "npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.gnosis.ts node --fork $(. ./.env && echo $RPC_URL_GNOSIS) --port 8100",
"node:zkevm": "npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.zkevm.ts node --fork $(. ./.env && echo $ALCHEMY_URL_ZKEVM) --port 8101",
"node:avalanche": "npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.avalanche.ts node --fork $(. ./.env && echo $RPC_URL_AVALANCHE) --port 8114",
"typechain:generate": "npx typechain --target ethers-v5 --out-dir src/contracts './src/lib/abi/*.json'"
},
"devDependencies": {
Expand Down Expand Up @@ -87,7 +88,7 @@
"typescript": "^4.0.2"
},
"dependencies": {
"@balancer-labs/sor": "4.1.1-beta.13",
"@balancer-labs/sor": "^4.1.1-beta.16",
"@ethersproject/abi": "^5.4.0",
"@ethersproject/abstract-signer": "^5.4.0",
"@ethersproject/address": "^5.4.0",
Expand Down
Loading
Loading