Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
pair balanceof helper, factory getpair helper updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammad-Mubeen committed Oct 21, 2021
1 parent 8a10cb9 commit d0ed020
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion JsClients/FACTORY/test/installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const getPair = async (contractHash:string,TOKEN0_CONTRACT:string,TOKEN1_
console.log(`... Contract Hash: ${contractHash}`);

// We don't need hash- prefix so i'm removing it
await factory.setContractHash(contractHash.slice(5));
await factory.setContractHash(contractHash);

//pair
let pair = await factory.getPair(TOKEN0_CONTRACT, TOKEN1_CONTRACT);
Expand Down
6 changes: 4 additions & 2 deletions JsClients/PAIR/test/installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,15 @@ const test = async () => {

//test();

export const balanceOf = async (contractHash:string,key:string) => {
export const balanceOf = async (contractHash:string, key:string) => {

console.log(`... Contract Hash: ${contractHash}`);

// We don't need hash- prefix so i'm removing it
await pair.setContractHash(contractHash.slice(5));
await pair.setContractHash(contractHash);

//how to convert string into AccountHash

//balanceof
//let balance = await pair.balanceOf(key);
//console.log(`... Balance of account ${key.toAccountHashStr()}`);
Expand Down
12 changes: 4 additions & 8 deletions graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,9 @@ const handleTransfer = {
}

if (from != ADDRESS_ZERO && from != pair.id) {
//let Balance =await PairContract.balanceOf(event.address,from);
createLiquidityPosition(address, from, args.value);
// fromUserLiquidityPosition.liquidityTokenBalance = convertTokenToDecimal(
// pairContract.balanceOf(event.address,from),
// BI_18
// );

let fromUserLiquidityPosition = null;
while (fromUserLiquidityPosition == null) {
fromUserLiquidityPosition = await LiquidityPosition.findOne({
Expand All @@ -430,11 +428,9 @@ const handleTransfer = {
}

if (to != ADDRESS_ZERO && to != pair.id) {
//let Balance = await PairContract.balanceOf(event.address,to);
createLiquidityPosition(address, to, args.value);
// toUserLiquidityPosition.liquidityTokenBalance = convertTokenToDecimal(
// pairContract.balanceOf(event.address,to),
// BI_18
// );

let toUserLiquidityPosition = null;
while (toUserLiquidityPosition == null) {
toUserLiquidityPosition = await LiquidityPosition.findOne({
Expand Down
2 changes: 1 addition & 1 deletion graphql/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function findEthPerToken(token) {
}
// loop through whitelist and check if paired with any
for (let i = 0; i < WHITELIST.length; ++i) {
//let pairAddress = factoryContract.getPair(process.env.FACTORY_ADDRESS,Address.fromString(token.id), Address.fromString(WHITELIST[i]));
//let pairAddress = await factory.getPair(process.env.FACTORY_ADDRESS,token.id, WHITELIST[i]);

let pairAddress =
"hash-0000000000000000000000000000000000000000000000000000000000000000";
Expand Down

0 comments on commit d0ed020

Please sign in to comment.