Skip to content

Commit ba3fb9d

Browse files
authored
Merge pull request #178 from balancer-labs/develop
Release 0.1.29
2 parents 7230a5b + 1a93bcb commit ba3fb9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+21774
-889
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { BalancerSDK } from '../../src/modules/sdk.module';
2+
import { Network } from '../../src';
3+
import dotenv from 'dotenv';
4+
5+
dotenv.config();
6+
7+
const sdk = new BalancerSDK(
8+
{
9+
network: Network.GOERLI,
10+
rpcUrl: `https://goerli.infura.io/v3/${process.env.INFURA}`
11+
});
12+
const { veBal } = sdk.contracts;
13+
14+
async function main() {
15+
16+
if (!veBal) throw new Error('veBal address must be defined');
17+
18+
const USER = "0x91F450602455564A64207414c7Fbd1F1F0EbB425";
19+
20+
const lockInfo = await veBal.getLockInfo(USER);
21+
console.log("veBAL lock info for user", lockInfo);
22+
}
23+
24+
main();
25+
26+
// npm run examples:run -- ./examples/contracts/veBAL.ts
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Network } from '../../src/index';
2+
import { BalancerSDK } from '../../src/modules/sdk.module';
3+
4+
const sdk = new BalancerSDK(
5+
{
6+
network: Network.MAINNET,
7+
rpcUrl: ''
8+
});
9+
const { gaugeShares } = sdk.data;
10+
11+
(async function() {
12+
13+
if (!gaugeShares) throw 'Gauge Subgraph must be initialized';
14+
15+
const USER_ADDR = '0x00676e437f1945b85ec3a3c90aae35e0352115ed';
16+
const GAUGE_ID = '0xc5f8b1de80145e3a74524a3d1a772a31ed2b50cc';
17+
const GAUGESHARE_ID = `${USER_ADDR}-${GAUGE_ID}`;
18+
const GAUGESHARE_ID2 = "0x79c17982020abb9a2214aa952308e104e5840e2d-0xc5f8b1de80145e3a74524a3d1a772a31ed2b50cc";
19+
20+
let result;
21+
22+
result = await gaugeShares.find(GAUGESHARE_ID);
23+
console.log('Gauge share by id', result);
24+
25+
result = await gaugeShares.findByUser(USER_ADDR);
26+
console.log('Gauge shares by user', result);
27+
28+
result = await gaugeShares.findByGauge(GAUGE_ID, 5);
29+
console.log('Gauge shares by gauge (first 5)', result);
30+
31+
result = await gaugeShares.findByGauge(GAUGE_ID, 2, 1);
32+
console.log('Gauge shares by gauge (#2 & #3)', result);
33+
34+
result = await gaugeShares.query({ where: { id_in: [ GAUGESHARE_ID, GAUGESHARE_ID2 ] }});
35+
console.log('Gauge shares subgraph query', result);
36+
// Gauges subgraph : https://thegraph.com/hosted-service/subgraph/balancer-labs/balancer-gauges
37+
38+
})();
39+
40+
// npm run examples:run -- ./examples/data/gauge-shares.ts
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Network } from '../../src/index';
2+
import { BalancerSDK } from '../../src/modules/sdk.module';
3+
4+
const sdk = new BalancerSDK(
5+
{
6+
network: Network.MAINNET,
7+
rpcUrl: ''
8+
});
9+
const { poolShares } = sdk.data;
10+
11+
(async function() {
12+
13+
const POOLSHARE_ID = '0x01abc00e86c7e258823b9a055fd62ca6cf61a163-0x2da1bcb14be26be6812e0e871e8dc4f4c0d92629';
14+
const POOL_ID = '0x01abc00e86c7e258823b9a055fd62ca6cf61a16300010000000000000000003b'
15+
const USER_ADDR = '0xba12222222228d8ba445958a75a0704d566bf2c8';
16+
17+
let result;
18+
19+
result = await poolShares.find(POOLSHARE_ID);
20+
console.log('Pool share by id', result);
21+
22+
result = await poolShares.findByUser(USER_ADDR);
23+
console.log('Pool shares by user', result);
24+
25+
result = await poolShares.findByUser(USER_ADDR, 5);
26+
console.log('Pool shares by user (first 5)', result);
27+
28+
result = await poolShares.findByPool(POOL_ID);
29+
console.log('Pool shares by pool', result);
30+
31+
result = await poolShares.findByPool(POOL_ID, 2, 1);
32+
console.log('Pool shares by pool (#2 & #3)', result);
33+
34+
result = await poolShares.query({ where: { poolId: POOL_ID, balance_gt: '0' }, first: 3 });
35+
console.log('Pool shares subgraph query', result);
36+
// Balancer subgraph : https://thegraph.com/hosted-service/subgraph/balancer-labs/balancer-v2
37+
38+
})();
39+
40+
// npm run examples:run -- ./examples/data/pool-shares.ts

balancer-js/examples/data/pools.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Network } from '../../src/index';
2+
import { BalancerSDK } from '../../src/modules/sdk.module';
3+
4+
const sdk = new BalancerSDK({
5+
network: Network.MAINNET,
6+
rpcUrl: ''
7+
});
8+
const { pools } = sdk.data;
9+
10+
async function main() {
11+
12+
const POOL_ID1 = '0x2d011adf89f0576c9b722c28269fcb5d50c2d17900020000000000000000024d';
13+
const POOL_ID2 = '0x4aa462d59361fc0115b3ab7e447627534a8642ae000100000000000000000158';
14+
const POOL_IDs = [ POOL_ID1, POOL_ID2 ];
15+
16+
let result;
17+
18+
result = await pools.find(POOL_ID1);
19+
console.log('Fetch pool by id', result);
20+
21+
result = await pools.all();
22+
console.log('Fetch all pools', result);
23+
24+
result = await pools.where(pool => POOL_IDs.includes(pool.id));
25+
console.log('Filter pools by attributes', result);
26+
}
27+
28+
main();
29+
30+
// npm run examples:run -- ./examples/data/pools.ts

0 commit comments

Comments
 (0)