Skip to content

Commit

Permalink
Merge develop.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Aug 30, 2023
2 parents af598c8 + a56a2fa commit f85e4b4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions balancer-js/examples/swaps/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ async function getAndProcessSwaps(
}

async function swapExample() {
const network = Network.POLYGON;
const network = Network.MAINNET;
const rpcUrl = 'https://rpc.ankr.com/polygon';
const tokenIn = '0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4'; // stMatic
const tokenOut = AddressZero; // Matic
const tokenIn = AddressZero; // stMatic
const tokenOut = '0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4'; // Matic
const swapType = SwapTypes.SwapExactIn;
const amount = parseFixed('20', 18);
const amount = parseFixed('1', 18);
// Currently Relayer only suitable for ExactIn and non-eth swaps
const canUseJoinExitPaths = canUseJoinExit(swapType, tokenIn, tokenOut);

Expand Down
2 changes: 1 addition & 1 deletion 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.4",
"version": "1.1.5-beta.1",
"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
3 changes: 3 additions & 0 deletions balancer-js/src/lib/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export const BALANCER_NETWORK_CONFIG: Record<Network, BalancerNetworkConfig> = {
'0xf22ff21e17157340575158ad7394e068048dd98b',
'0xf71d0774b214c4cf51e33eb3d30ef98132e4dbaa',
'0xe0e8ac08de6708603cfd3d23b613d2f80e3b7afb',
'0xf01b0684c98cd7ada480bfdf6e43876422fa1fc1', // GyroE incorrect version
'0xe0e8ac08de6708603cfd3d23b613d2f80e3b7afb', // GyroE incorrect version
'0xf7a826d47c8e02835d94fb0aa40f0cc9505cb134', // GyroE incorrect version
],
sorConnectingTokens: [
{
Expand Down
5 changes: 3 additions & 2 deletions balancer-js/src/modules/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { Contracts } from '../contracts/contracts.module';

export class Data implements BalancerDataRepositories {
pools;
poolsForSor;
poolsForSimulations;
poolsOnChain;
yesterdaysPools;
poolShares;
Expand Down Expand Up @@ -83,7 +83,8 @@ export class Data implements BalancerDataRepositories {
query: subgraphQuery,
});

this.poolsForSor = new SubgraphPoolDataService(
// Used for VaultModel and Simulations
this.poolsForSimulations = new SubgraphPoolDataService(
createSubgraphClient(networkConfig.urls.subgraph),
provider,
networkConfig,
Expand Down
2 changes: 1 addition & 1 deletion balancer-js/src/modules/pools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Pools implements Findable<PoolWithMethods> {
);
this.simulationService = new Simulation(
networkConfig,
this.repositories.poolsForSor
this.repositories.poolsForSimulations
);
this.graphService = new PoolGraph(this.repositories.poolsOnChain);
this.joinService = new Join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { ALCHEMY_URL_POLYGON: jsonRpcUrl } = process.env;
const rpcUrl = 'http://127.0.0.1:8137';
const provider = new ethers.providers.JsonRpcProvider(rpcUrl, network);
const signer = provider.getSigner();
const blockNumber = 46572274;
const blockNumber = 46939238;
let balancer: BalancerSDK;

describe.skip('ComposableStable - recovery', () => {
Expand Down Expand Up @@ -229,7 +229,7 @@ describe.skip('ComposableStable - recovery', () => {
context('buildRecoveryExit', async () => {
context('PoolWithMethods', async () => {
it('should recovery exit', async () => {
const bptAmount = parseFixed('1.34', 18).toString();
const bptAmount = parseFixed('0.001', 18).toString();
const slippage = '10'; // 10 bps = 0.1%
const pool = await balancer.pools.find(poolId);
if (!pool) throw Error('Pool not found');
Expand All @@ -252,7 +252,7 @@ describe.skip('ComposableStable - recovery', () => {
});
context('Pool & refresh', async () => {
it('should recovery exit', async () => {
const bptAmount = parseFixed('1.34', 18).toString();
const bptAmount = parseFixed('0.00001', 18).toString();
const slippage = '10'; // 10 bps = 0.1%
let pool = await balancer.data.pools.find(poolId);
if (!pool) throw Error('Pool not found');
Expand Down
2 changes: 1 addition & 1 deletion balancer-js/src/modules/sdk.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class BalancerSDK implements BalancerSDKRoot {
});
}
this.vaultModel = new VaultModel(
this.data.poolsForSor,
this.data.poolsForSimulations,
this.networkConfig.addresses.tokens.wrappedNativeAsset
);
}
Expand Down
9 changes: 8 additions & 1 deletion balancer-js/src/modules/sor/sor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from '@/types';
import { SubgraphTokenPriceService } from './token-price/subgraphTokenPriceService';
import { getNetworkConfig } from '@/modules/sdk.helpers';
import { poolsToIgnore } from '@/lib/constants/poolsToIgnore';
import { getPoolAddress } from '@/pool-utils';

export class Sor extends SOR {
constructor(sdkConfig: BalancerSdkConfig) {
Expand Down Expand Up @@ -70,12 +72,17 @@ export class Sor extends SOR {
provider: Provider,
subgraphClient: SubgraphClient
) {
const poolsToIgnoreAddr = poolsToIgnore.map((id) => getPoolAddress(id));
// For SOR we want to ignore all configured pools (for Vault/Simulation we don't)
const allPoolsToIgnore = network.poolsToIgnore
? [...network.poolsToIgnore, ...poolsToIgnoreAddr]
: poolsToIgnoreAddr;
return typeof sorConfig.poolDataService === 'object'
? sorConfig.poolDataService
: new SubgraphPoolDataService(
subgraphClient,
provider,
network,
{ ...network, poolsToIgnore: allPoolsToIgnore },
sorConfig
);
}
Expand Down
2 changes: 1 addition & 1 deletion balancer-js/src/test/factories/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const repositores = ({
),
}): BalancerDataRepositories => ({
pools,
poolsForSor: {} as SubgraphPoolDataService,
poolsForSimulations: {} as SubgraphPoolDataService,
poolsOnChain,
yesterdaysPools,
tokenPrices,
Expand Down
2 changes: 1 addition & 1 deletion balancer-js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface BalancerDataRepositories {
*/
pools: Findable<Pool, PoolAttribute> & Searchable<Pool>;
// Does it need to be different from the pools repository?
poolsForSor: SubgraphPoolDataService;
poolsForSimulations: SubgraphPoolDataService;
poolGauges?: PoolGaugesRepository;
poolJoinExits: PoolJoinExitRepository;
// Perhaps better to use a function to get upto date balances when needed.
Expand Down

0 comments on commit f85e4b4

Please sign in to comment.