Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix: solace fix addresses and style (#815)
Browse files Browse the repository at this point in the history
* fix: fix addresses and style

* fix: correct variable name
  • Loading branch information
leonardishere authored Jul 1, 2022
1 parent 4894859 commit 2659337
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const groupId = SOLACE_DEFINITION.groups.policies.id;
const network = Network.AURORA_MAINNET;

const DAI_ADDRESS = '0xe3520349f477a5f6eb06107066048508498a291b';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501acec83d440c00644ca5c48d059e1840852a64';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501aceb72d62c9875825b71d9f78a27780b5624d';
const SOLACE_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';

const PREMIUM_POOL_ADDRESS = '0x0436c20030d0c2e278e7e8e4b42d304a6420d3bb';
Expand All @@ -45,7 +45,7 @@ export class AuroraSolacePoliciesContractPositionFetcher implements PositionFetc
const tokens = [supplied(dai)];

let liquidity = 0;
for(var i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
for (let i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
const tokenAddr = PREMIUM_POOL_TOKENS[i];
const tokenContract = this.solaceContractFactory.erc20({ address: tokenAddr, network });
const [balanceOfRaw, decimals] = await Promise.all([
Expand All @@ -54,7 +54,7 @@ export class AuroraSolacePoliciesContractPositionFetcher implements PositionFetc
]);
const balanceOf = Number(balanceOfRaw) / 10 ** decimals;
const tokenZapper = baseTokens.find(t => t.address === tokenAddr)!;
if(!!tokenZapper) liquidity += balanceOf * tokenZapper.price;
if (tokenZapper) liquidity += balanceOf * tokenZapper.price;
}

const position: ContractPosition = {
Expand Down
13 changes: 3 additions & 10 deletions src/apps/solace/ethereum/solace.bonds.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { compact } from 'lodash';
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getImagesFromToken, getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { getImagesFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { ContractType } from '~position/contract.interface';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
Expand All @@ -18,7 +18,7 @@ const appId = SOLACE_DEFINITION.id;
const groupId = SOLACE_DEFINITION.groups.bonds.id;
const network = Network.ETHEREUM_MAINNET;

const SOLACE_TOKEN_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';
const SOLACE_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';

const BOND_TELLER_ADDRESSES = [
'0x501ace677634fd09a876e88126076933b686967a', // DAI Bond
Expand All @@ -40,14 +40,7 @@ export class EthereumSolaceBondsContractPositionFetcher implements PositionFetch
async getPositions() {
const multicall = this.appToolkit.getMulticall(network);
const baseTokens = await this.appToolkit.getBaseTokenPrices(network);
const appTokens = await this.appToolkit.getAppTokenPositions({
appId,
groupIds: [SOLACE_DEFINITION.groups.scp.id],
network,
});

const allTokens = [...appTokens, ...baseTokens];
const solaceToken = baseTokens.find(t => t.address === SOLACE_TOKEN_ADDRESS)!;
const solaceToken = baseTokens.find(t => t.address === SOLACE_ADDRESS)!;

const positions = await Promise.all(
BOND_TELLER_ADDRESSES.map(async bondTellerAddress => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const groupId = SOLACE_DEFINITION.groups.policies.id;
const network = Network.ETHEREUM_MAINNET;

const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501acebe29eabc346779bcb5fd62eaf6bfb5320e';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501aceb72d62c9875825b71d9f78a27780b5624d';
const SOLACE_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';

const PREMIUM_POOL_ADDRESS = '0x88fddce9ad3c5a12c06b597f0948f8eaffc3862d';
Expand All @@ -44,7 +44,7 @@ export class EthereumSolacePoliciesContractPositionFetcher implements PositionFe
const tokens = [supplied(dai)];

let liquidity = 0;
for(var i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
for (let i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
const tokenAddr = PREMIUM_POOL_TOKENS[i];
const tokenContract = this.solaceContractFactory.erc20({ address: tokenAddr, network });
const [balanceOfRaw, decimals] = await Promise.all([
Expand All @@ -53,7 +53,7 @@ export class EthereumSolacePoliciesContractPositionFetcher implements PositionFe
]);
const balanceOf = Number(balanceOfRaw) / 10 ** decimals;
const tokenZapper = baseTokens.find(t => t.address === tokenAddr)!;
if(!!tokenZapper) liquidity += balanceOf * tokenZapper.price;
if (tokenZapper) liquidity += balanceOf * tokenZapper.price;
}

const position: ContractPosition = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const groupId = SOLACE_DEFINITION.groups.policies.id;
const network = Network.FANTOM_OPERA_MAINNET;

const DAI_ADDRESS = '0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501acec83d440c00644ca5c48d059e1840852a64';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501aceb72d62c9875825b71d9f78a27780b5624d';
const SOLACE_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';

const PREMIUM_POOL_ADDRESS = '0xbff26e5d913738d073c515bee32035f2aff8c40c';
Expand All @@ -45,7 +45,7 @@ export class FantomSolacePoliciesContractPositionFetcher implements PositionFetc
const tokens = [supplied(dai)];

let liquidity = 0;
for(var i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
for (let i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
const tokenAddr = PREMIUM_POOL_TOKENS[i];
const tokenContract = this.solaceContractFactory.erc20({ address: tokenAddr, network });
const [balanceOfRaw, decimals] = await Promise.all([
Expand All @@ -54,7 +54,7 @@ export class FantomSolacePoliciesContractPositionFetcher implements PositionFetc
]);
const balanceOf = Number(balanceOfRaw) / 10 ** decimals;
const tokenZapper = baseTokens.find(t => t.address === tokenAddr)!;
if(!!tokenZapper) liquidity += balanceOf * tokenZapper.price;
if (tokenZapper) liquidity += balanceOf * tokenZapper.price;
}

const position: ContractPosition = {
Expand Down
4 changes: 2 additions & 2 deletions src/apps/solace/helpers/SolacePolicyBalanceHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SolaceContractFactory } from '../contracts';
import { SOLACE_DEFINITION } from '../solace.definition';

const SOLACE_COVER_POINTS_ADDRESS = '0x501ace72166956f57b44dbbcc531a8e741449997';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501ACeB72d62C9875825b71d9f78a27780B5624d';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501aceb72d62c9875825b71d9f78a27780b5624d';

@Injectable()
export class SolacePolicyBalanceHelper {
Expand All @@ -28,7 +28,7 @@ export class SolacePolicyBalanceHelper {
// does the user have a policy?
const spi = this.solaceContractFactory.solaceCoverProductV3({ address: SOLACE_COVER_PRODUCT_ADDRESS, network });
const policyID = await spi.policyOf(address);
if(policyID.eq(0)) return [];
if (policyID.eq(0)) return [];
// Resolve the staked token and reward token from the contract position object
const stakedToken = contractPosition.tokens.find(t => t.metaType === MetaType.SUPPLIED)!;
const scp = this.solaceContractFactory.erc20({ address: SOLACE_COVER_POINTS_ADDRESS, network });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const groupId = SOLACE_DEFINITION.groups.policies.id;
const network = Network.POLYGON_MAINNET;

const DAI_ADDRESS = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501acec83d440c00644ca5c48d059e1840852a64';
const SOLACE_COVER_PRODUCT_ADDRESS = '0x501aceb72d62c9875825b71d9f78a27780b5624d';
const SOLACE_ADDRESS = '0x501ace9c35e60f03a2af4d484f49f9b1efde9f40';

const PREMIUM_POOL_ADDRESS = '0x37cd57c6c7243455ac66631ce37bb7f977c71442';
Expand All @@ -45,7 +45,7 @@ export class PolygonSolacePoliciesContractPositionFetcher implements PositionFet
const tokens = [supplied(dai)];

let liquidity = 0;
for(var i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
for (let i = 0; i < PREMIUM_POOL_TOKENS.length; ++i) {
const tokenAddr = PREMIUM_POOL_TOKENS[i];
const tokenContract = this.solaceContractFactory.erc20({ address: tokenAddr, network });
const [balanceOfRaw, decimals] = await Promise.all([
Expand All @@ -54,7 +54,7 @@ export class PolygonSolacePoliciesContractPositionFetcher implements PositionFet
]);
const balanceOf = Number(balanceOfRaw) / 10 ** decimals;
const tokenZapper = baseTokens.find(t => t.address === tokenAddr)!;
if(!!tokenZapper) liquidity += balanceOf * tokenZapper.price;
if (tokenZapper) liquidity += balanceOf * tokenZapper.price;
}

const position: ContractPosition = {
Expand Down

0 comments on commit 2659337

Please sign in to comment.