-
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 #347 from balancer-labs/develop
Release 1.0.0
- Loading branch information
Showing
143 changed files
with
13,356 additions
and
4,274 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
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules | ||
dist | ||
**/examples | ||
**/generated |
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ dist/ | |
src/subgraph/generated/ | ||
cache/ | ||
balancer-js.iml | ||
temp/ |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,63 @@ | ||
@startuml | ||
'https://plantuml.com/class-diagram | ||
|
||
class BalancerSDK | ||
|
||
class ClaimService { | ||
} | ||
|
||
interface IClaimService { | ||
+getClaimableRewardTokens(userAddress):LiquidityGauge[] | ||
+buildClaimRewardTokensRequest(gaugeAddresses, userAddress):TransactionData | ||
+getClaimableVeBalTokens(userAddress): TokenBalance[] | ||
+buildClaimVeBalTokensRequest(userAddress): TransactionData | ||
} | ||
|
||
interface BaseFeeDistributor { | ||
multicallData: (ts: number) => Promise<FeeDistributorData>; | ||
getClaimableBalances(userAddress: string, claimableTokens: string[]): Promise<TokenBalance>; | ||
claimBalances(userAddress: string, claimableTokens: string[]): string; | ||
} | ||
class FeeDistributorRepository { | ||
} | ||
|
||
class FeeDistributor <<Contract>> { | ||
+claimTokens(userAddress, tokens): TokenBalance | ||
} | ||
|
||
class TokenBalance { | ||
[key:string]:BigNumber | ||
} | ||
|
||
interface TransactionData { | ||
+to: string | ||
+from: string | ||
+functionName: string | ||
+args: any[] | ||
+data: string | ||
} | ||
|
||
interface LiquidityGauge { | ||
id: string; | ||
address: string; | ||
name: string; | ||
poolId?: Maybe<string>; | ||
poolAddress: string; | ||
totalSupply: number; | ||
workingSupply: number; | ||
relativeWeight: number; | ||
} | ||
|
||
BalancerSDK -l-> ClaimService | ||
|
||
ClaimService .up.|> IClaimService | ||
ClaimService -l-> FeeDistributorRepository | ||
|
||
ClaimService .down. "produces" TransactionData | ||
ClaimService .down. "update" LiquidityGauge | ||
|
||
LiquidityGauge --> "*" TokenBalance: claimableTokens | ||
|
||
FeeDistributorRepository .up.|> BaseFeeDistributor | ||
FeeDistributorRepository -left-> FeeDistributor | ||
@enduml |
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,54 @@ | ||
import {Network} from "@/lib/constants"; | ||
import {BalancerSDK} from "@/modules/sdk.module"; | ||
import {forkSetup} from "@/test/lib/utils"; | ||
import hardhat from "hardhat"; | ||
|
||
const userAddress = '0x549c660ce2B988F588769d6AD87BE801695b2be3'; | ||
|
||
const rpcUrl = 'http://127.0.0.1:8545'; | ||
const blockNumber = 16361617; | ||
const { ethers } = hardhat; | ||
const provider = new ethers.providers.JsonRpcProvider(rpcUrl, 1); | ||
const signer = provider.getSigner(); | ||
const jsonRpcUrl = 'https://rpc.ankr.com/eth'; | ||
const sdk = new BalancerSDK( | ||
{ | ||
network: Network.MAINNET, | ||
rpcUrl: rpcUrl | ||
}); | ||
const { claimService } = sdk; | ||
|
||
(async function () { | ||
|
||
await forkSetup(signer, [], [], [], jsonRpcUrl as string, blockNumber); | ||
|
||
if (!claimService) throw new Error("ClaimService not defined"); | ||
const balanceGauges = await claimService.getClaimableRewardTokens(userAddress); | ||
console.table(balanceGauges.map((it) => it.claimableTokens)); | ||
const gauges = balanceGauges.map((it) => it.address); | ||
let data = await claimService.buildClaimRewardTokensRequest(gauges.slice(0,1), userAddress); | ||
console.log(`\nSingle Gauge Claim ( gauge: ${gauges.slice(0,1)}) | ||
to: ${data.to} - BalancerMinter Address ${sdk.networkConfig.addresses.contracts.balancerMinterAddress} | ||
from: ${data.from} - User Address ${userAddress} | ||
tokensOut: ${data.tokensOut} | ||
expectedTokensValue: ${data.expectedTokensValue} | ||
functionName: ${data.functionName} | ||
callData: ${data.callData.slice(0, 10)}...${data.callData.slice(-5)} | ||
`) | ||
data = await claimService.buildClaimRewardTokensRequest(gauges, userAddress); | ||
console.log(`\nMultiple Gauges Claim | ||
to: ${data.to} - BalancerMinter Address ${sdk.networkConfig.addresses.contracts.balancerMinterAddress} | ||
from: ${data.from} - User Address ${userAddress} | ||
tokensOut: ${data.tokensOut} | ||
expectedTokensValue: ${data.expectedTokensValue} | ||
functionName: ${data.functionName} | ||
callData: ${data.callData.slice(0, 10)}...${data.callData.slice(-5)} | ||
`) | ||
|
||
console.log(`\n\nfinally: | ||
const tx = { to: data.to', data: callData }; | ||
const receipt = await (await signer.sendTransaction(tx)).wait(); | ||
`) | ||
|
||
})(); |
Oops, something went wrong.