-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from balancer-labs/develop
Release 0.1.29
- Loading branch information
Showing
50 changed files
with
21,774 additions
and
889 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { BalancerSDK } from '../../src/modules/sdk.module'; | ||
import { Network } from '../../src'; | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const sdk = new BalancerSDK( | ||
{ | ||
network: Network.GOERLI, | ||
rpcUrl: `https://goerli.infura.io/v3/${process.env.INFURA}` | ||
}); | ||
const { veBal } = sdk.contracts; | ||
|
||
async function main() { | ||
|
||
if (!veBal) throw new Error('veBal address must be defined'); | ||
|
||
const USER = "0x91F450602455564A64207414c7Fbd1F1F0EbB425"; | ||
|
||
const lockInfo = await veBal.getLockInfo(USER); | ||
console.log("veBAL lock info for user", lockInfo); | ||
} | ||
|
||
main(); | ||
|
||
// npm run examples:run -- ./examples/contracts/veBAL.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Network } from '../../src/index'; | ||
import { BalancerSDK } from '../../src/modules/sdk.module'; | ||
|
||
const sdk = new BalancerSDK( | ||
{ | ||
network: Network.MAINNET, | ||
rpcUrl: '' | ||
}); | ||
const { gaugeShares } = sdk.data; | ||
|
||
(async function() { | ||
|
||
if (!gaugeShares) throw 'Gauge Subgraph must be initialized'; | ||
|
||
const USER_ADDR = '0x00676e437f1945b85ec3a3c90aae35e0352115ed'; | ||
const GAUGE_ID = '0xc5f8b1de80145e3a74524a3d1a772a31ed2b50cc'; | ||
const GAUGESHARE_ID = `${USER_ADDR}-${GAUGE_ID}`; | ||
const GAUGESHARE_ID2 = "0x79c17982020abb9a2214aa952308e104e5840e2d-0xc5f8b1de80145e3a74524a3d1a772a31ed2b50cc"; | ||
|
||
let result; | ||
|
||
result = await gaugeShares.find(GAUGESHARE_ID); | ||
console.log('Gauge share by id', result); | ||
|
||
result = await gaugeShares.findByUser(USER_ADDR); | ||
console.log('Gauge shares by user', result); | ||
|
||
result = await gaugeShares.findByGauge(GAUGE_ID, 5); | ||
console.log('Gauge shares by gauge (first 5)', result); | ||
|
||
result = await gaugeShares.findByGauge(GAUGE_ID, 2, 1); | ||
console.log('Gauge shares by gauge (#2 & #3)', result); | ||
|
||
result = await gaugeShares.query({ where: { id_in: [ GAUGESHARE_ID, GAUGESHARE_ID2 ] }}); | ||
console.log('Gauge shares subgraph query', result); | ||
// Gauges subgraph : https://thegraph.com/hosted-service/subgraph/balancer-labs/balancer-gauges | ||
|
||
})(); | ||
|
||
// npm run examples:run -- ./examples/data/gauge-shares.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Network } from '../../src/index'; | ||
import { BalancerSDK } from '../../src/modules/sdk.module'; | ||
|
||
const sdk = new BalancerSDK( | ||
{ | ||
network: Network.MAINNET, | ||
rpcUrl: '' | ||
}); | ||
const { poolShares } = sdk.data; | ||
|
||
(async function() { | ||
|
||
const POOLSHARE_ID = '0x01abc00e86c7e258823b9a055fd62ca6cf61a163-0x2da1bcb14be26be6812e0e871e8dc4f4c0d92629'; | ||
const POOL_ID = '0x01abc00e86c7e258823b9a055fd62ca6cf61a16300010000000000000000003b' | ||
const USER_ADDR = '0xba12222222228d8ba445958a75a0704d566bf2c8'; | ||
|
||
let result; | ||
|
||
result = await poolShares.find(POOLSHARE_ID); | ||
console.log('Pool share by id', result); | ||
|
||
result = await poolShares.findByUser(USER_ADDR); | ||
console.log('Pool shares by user', result); | ||
|
||
result = await poolShares.findByUser(USER_ADDR, 5); | ||
console.log('Pool shares by user (first 5)', result); | ||
|
||
result = await poolShares.findByPool(POOL_ID); | ||
console.log('Pool shares by pool', result); | ||
|
||
result = await poolShares.findByPool(POOL_ID, 2, 1); | ||
console.log('Pool shares by pool (#2 & #3)', result); | ||
|
||
result = await poolShares.query({ where: { poolId: POOL_ID, balance_gt: '0' }, first: 3 }); | ||
console.log('Pool shares subgraph query', result); | ||
// Balancer subgraph : https://thegraph.com/hosted-service/subgraph/balancer-labs/balancer-v2 | ||
|
||
})(); | ||
|
||
// npm run examples:run -- ./examples/data/pool-shares.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Network } from '../../src/index'; | ||
import { BalancerSDK } from '../../src/modules/sdk.module'; | ||
|
||
const sdk = new BalancerSDK({ | ||
network: Network.MAINNET, | ||
rpcUrl: '' | ||
}); | ||
const { pools } = sdk.data; | ||
|
||
async function main() { | ||
|
||
const POOL_ID1 = '0x2d011adf89f0576c9b722c28269fcb5d50c2d17900020000000000000000024d'; | ||
const POOL_ID2 = '0x4aa462d59361fc0115b3ab7e447627534a8642ae000100000000000000000158'; | ||
const POOL_IDs = [ POOL_ID1, POOL_ID2 ]; | ||
|
||
let result; | ||
|
||
result = await pools.find(POOL_ID1); | ||
console.log('Fetch pool by id', result); | ||
|
||
result = await pools.all(); | ||
console.log('Fetch all pools', result); | ||
|
||
result = await pools.where(pool => POOL_IDs.includes(pool.id)); | ||
console.log('Filter pools by attributes', result); | ||
} | ||
|
||
main(); | ||
|
||
// npm run examples:run -- ./examples/data/pools.ts |
Oops, something went wrong.