Skip to content

Commit

Permalink
[crucible-erc20-balance-of] Update - Edge Case Resolution - Padding A…
Browse files Browse the repository at this point in the history
…ddresses (snapshot-labs#55)

* add test for shorter decimals

* pad hex to cover edge case of short decimals
  • Loading branch information
joehquak authored Sep 12, 2021
1 parent 0d8366a commit 29e27c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/strategies/crucible-erc20-balance-of/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"strategy": {
"name": "crucible-erc20-balance-of",
"params": {
"symbol": "ABC",
"symbol": "MIST-WETH LP (Uni V2)",
"crucible_factory": "0x54e0395CFB4f39beF66DBCd5bD93Cca4E9273D56",
"erc20_address": "0xCD6bcca48069f8588780dFA274960F15685aEe0e",
"erc20_decimals": 18
Expand All @@ -20,7 +20,8 @@
"0x5E91d547A6f279E6d59086E30e25C964EFE4b463",
"0xB59212Bd19aE722F1cc97A3A93542D573534cf70",
"0x777B0884f97Fd361c55e472530272Be61cEb87c8",
"0x63060f713b377AF8D7D50669ec0fDcE1D31E3f28"
"0x63060f713b377AF8D7D50669ec0fDcE1D31E3f28",
"0xA5109D7E4790143a91D673Ba545405Bf396806CF"
],
"snapshot": 13062462
}
Expand Down
5 changes: 3 additions & 2 deletions src/strategies/crucible-erc20-balance-of/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { BigNumber } from '@ethersproject/bignumber';
import { hexZeroPad } from '@ethersproject/bytes';
import { formatUnits } from '@ethersproject/units';
import { Multicaller } from '../../utils';

export const author = 'thegostep';
export const version = '0.1.0';
export const version = '0.1.1';

const abi = [
'function balanceOf(address owner) external view returns (uint256)',
Expand Down Expand Up @@ -84,7 +85,7 @@ export async function strategy(
walletIDToCrucibleAddresses
)) {
callCrucibleToLpBalance.call(walletID, options.erc20_address, 'balanceOf', [
crucibleAddress.toHexString()
hexZeroPad(crucibleAddress.toHexString(), 20)
]);
}
const walletIDToLpBalance: Record<
Expand Down

0 comments on commit 29e27c8

Please sign in to comment.