Skip to content

Commit

Permalink
Merge pull request #974 from TempleDAO/stage
Browse files Browse the repository at this point in the history
stage -> main
  • Loading branch information
frontier159 authored Feb 28, 2024
2 parents e490852 + c66b148 commit 59df61c
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 55 deletions.
2 changes: 1 addition & 1 deletion apps/automation-v2/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
4 changes: 2 additions & 2 deletions apps/automation-v2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Stage 1
FROM node:18-alpine AS appbuild
FROM node:20-alpine AS appbuild
WORKDIR /app
COPY package.json yarn.lock tsconfig.json ./
COPY ./abi ./abi
Expand All @@ -8,7 +8,7 @@ RUN yarn install
RUN yarn build

# Build Stage 2 (ie just the esbuild out)
FROM node:18-alpine
FROM node:20-alpine
WORKDIR /app
COPY --from=appbuild /app/dist/main.js main.js
CMD ["node", "main.js"]
4 changes: 2 additions & 2 deletions apps/automation-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "temple-tasks",
"name": "@temple/tasks",
"version": "0.0.1",
"description": "temple automation tasks using overlord framework",
"license": "AGPL-3.0-or-later",
Expand Down Expand Up @@ -39,6 +39,6 @@
]
},
"engines": {
"node": "18.x"
"node": ">=20.0.0"
}
}
2 changes: 1 addition & 1 deletion apps/automation-v2/src/config/prodnets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TLC_BATCH_LIQUIDATE_CONFIG: TlcBatchLiquidateConfig = {
MIN_ETH_BALANCE_WARNING: parseEther('0.1'),
GAS_LIMIT: 1_000_000n,
SUBGRAPH_URL: 'https://api.thegraph.com/subgraphs/name/medariox/v2-mainnet',
SUBGRAPH_ALCHEMY_URL: 'https://subgraph.satsuma-prod.com/a912521dd162/templedao/temple-v2-mainnet/version/v0.1.0/api',
SUBGRAPH_ALCHEMY_URL: 'https://subgraph.satsuma-prod.com/a912521dd162/templedao/temple-v2-mainnet/api',
SUBGRAPH_RETRY_LIMIT: 3,
};

Expand Down
4 changes: 2 additions & 2 deletions apps/automation-v2/src/tlc/batch-liquidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export async function batchLiquidate(
let res: AxiosResponse<GetUserResponse> | undefined = undefined;
const randomUrlFirstAlchemyApi = Math.random() < 0.5;
try {
// try subgraph call with thegraph api endpoint
// try first random subgraph api endpoint
res = await getTlcUsers(
ctx,
randomUrlFirstAlchemyApi ? config.SUBGRAPH_ALCHEMY_URL : config.SUBGRAPH_URL,
config.SUBGRAPH_RETRY_LIMIT
);
} catch (e) {
// fallback subgraph call to try with alchemy api endpoint
// if first fails, try the second endpoint option
res = await getTlcUsers(
ctx,
randomUrlFirstAlchemyApi ? config.SUBGRAPH_URL : config.SUBGRAPH_ALCHEMY_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function transpose(data: V2StrategySnapshot[], metric: V2SnapshotMetric, format:

type MetricFormatter = (v: string) => number;

const parseNumericMetric = (v: string)=> Math.round(parseFloat(v))
const parseNumericMetric = (v: string) => Math.round(parseFloat(v));

const metricFormatters: { [k in V2SnapshotMetric]: MetricFormatter } = {
accruedInterestUSD: parseNumericMetric,
Expand All @@ -72,14 +72,18 @@ const V2StrategyMetricsChart: React.FC<{
selectedMetric: V2SnapshotMetric;
selectedInterval: ChartSupportedTimeInterval;
}> = ({ dashboardType, selectedMetric, selectedInterval, strategyNames }) => {
// uncamel-case the metric names
const formatMetricName = (name: string) =>
`${name
// insert a space before all caps
.replace(/([A-Z][a-z])/g, ' $1')
// uppercase the first character
.replace(/^./, (str) => str.toUpperCase())
.replace(/USD/, '')}`;

// format only the selected metric name (the selected metric or all lines in a TRV chart)
name === selectedMetric || dashboardType === DashboardType.TREASURY_RESERVES_VAULT
? name
// // insert a space before all caps
.replace(/([A-Z][a-z])/g, ' $1')
// // uppercase the first character
.replace(/^./, (str) => str.toUpperCase())
.replace(/USD$/, '')
: // Individual debt token tickers remain unchanged
name;
const tooltipValuesFormatter = (value: number, name: string) => [
numberFormatter.format(value),
formatMetricName(name),
Expand Down Expand Up @@ -117,7 +121,7 @@ const V2StrategyMetricsChart: React.FC<{
// toggle this for inverted Debt

const strategyTokens = Object.fromEntries(
m.strategyTokens.map((t) => [`${selectedMetric}: ${t.symbol}`, parseNumericMetric(t[strategyTokenMetric])])
m.strategyTokens.map((t) => [`${t.symbol}`, parseNumericMetric(t[strategyTokenMetric])])
);
return { ...data, ...strategyTokens };
}
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/src/constants/env/production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const env: Environment = {
{ name: 'Epoch 22b', address: '0x9516E1ad540573a6704f2b7fbA165bC05821e552' },
{ name: 'Epoch 22c', address: '0x57cE4E4dcA88A5E1f3788D8e47c46687F91B6AfE' },
{ name: 'Epoch 23a', address: '0xC05C4123a4870293521980640ddFE37eb5c32dB6' },
{ name: 'Epoch 23b', address: '0xBd64922E156175972356D4Ef362b22a6806D61Ff' },
],
temple: '0x470ebf5f030ed85fc1ed4c2d36b9dd02e77cf1b7',
templeStaking: '0x4D14b24EDb751221B3Ff08BBB8bd91D4b1c8bc77',
Expand Down
5 changes: 5 additions & 0 deletions apps/dapp/src/styles/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const theme: DefaultTheme = {
'#876FAC',
'#AF444A',
'#24809D',
'#9D2498',
'#9D4124',
'#9D7424',
'#588F22',
'#26249D',
],
enclave: {
structure: '#01806C',
Expand Down
2 changes: 2 additions & 0 deletions protocol/scripts/deploys/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface TeamPayments {
TEMPLE_TEAM_EPOCH_22B: string;
TEMPLE_TEAM_EPOCH_22C: string;
TEMPLE_TEAM_EPOCH_23A: string;
TEMPLE_TEAM_EPOCH_23B: string;
}

export interface DeployedContracts {
Expand Down Expand Up @@ -322,6 +323,7 @@ export const DEPLOYED_CONTRACTS: { [key: string]: DeployedContracts } = {
TEMPLE_TEAM_EPOCH_22B: '0x9516E1ad540573a6704f2b7fbA165bC05821e552',
TEMPLE_TEAM_EPOCH_22C: '0x57cE4E4dcA88A5E1f3788D8e47c46687F91B6AfE',
TEMPLE_TEAM_EPOCH_23A: '0xC05C4123a4870293521980640ddFE37eb5c32dB6',
TEMPLE_TEAM_EPOCH_23B: '0xBd64922E156175972356D4Ef362b22a6806D61Ff',
},

TEMPLE_TEAM_PAYMENTS_IMPLEMENTATION: '',
Expand Down
2 changes: 1 addition & 1 deletion protocol/scripts/deploys/mainnet/team-payments/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectAddressWithPrivateKey,
toAtto,
} from '../../helpers';
import snapshot from './json/epoch23a.json';
import snapshot from './json/epoch23b.json';

// TODO: Add command line arguments for json allocations file
async function main() {
Expand Down
18 changes: 18 additions & 0 deletions protocol/scripts/deploys/mainnet/team-payments/json/epoch23b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"0x6D4FB10bb34A2Ed1dB0f208349a906EDd2567d45": 400,
"0xE58C06c3372687039140ceb64cB05f78D71fA133": 5100,
"0x072d76b501E364FCA58B6A7fe16a88c74D64924c": 500,
"0xB8C400E4E9360ae7a3480A2F63e2A5aA85696148": 250,
"0xe07d083d4A8810E5b35300a6De579fB2AF525e2F": 9000,
"0x14d62c8faC60d71714F54bd3f7dF18433475968b": 12000,
"0x66a60022c7B15BBbBe265C55Ad096e44f1138e19": 14000,
"0xF26c0eBb04e794c666730233842Ca854D1747deF": 250,
"0x97Ec4001aD1d2a1FBb581ea34C5C0Bd4a210C25C": 42500,
"0x9F7eE729DDE0D95ffCf69F5606D534Ee47b303C0": 20000,
"0x6e85a8c802dcA39bEB4cE6Eb4C6acD1eB2742564": 10000,
"0x588282ADA5B9D872d0eBF506c5C1b541e2a60BBa": 14000,
"0x07dA99dff5F996FaD9FCe0e15a20edC4DBeAe028": 23900,
"0xe345e9605391c13Fd2502e7141D54b752AaDB184": 12000,
"0x038D946DD8488237D8E710a45b6E801F1Ee4dc01": 14000,
"0x1cCbe98Ce51d3ba16A5F29b7f970c3e101ded67f": 10000
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ contract TempleCircuitBreakerTestPreCheck is TempleCircuitBreakerTestBase {
}

uint256 avgGas = totalGas / 4000;
assertLt(avgGas, 11_600);
assertLt(avgGas, 94_600);

if (LOG) console2.log("totalGas:", totalGas, totalGas/4000);
}
Expand Down
18 changes: 9 additions & 9 deletions protocol/test/forge/v2/templeLineOfCredit/TlcBorrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,18 @@ contract TempleLineOfCreditTestBorrow is TlcBaseTest {
function test_borrow_gas() public {
// With unoptmised solc FOUNDRY_PROFILE=lite
(uint256 first, uint256 second, uint256 third) = _borrowIteration(makeAddr("acct1"));
assertLt(first, 304_000, "acct1 1");
assertLt(second, 70_000, "acct1 2");
assertLt(third, 95_000, "acct1 3");
assertLt(first, 310_500, "acct1 1");
assertLt(second, 210_800, "acct1 2");
assertLt(third, 241_500, "acct1 3");

(first, second, third) = _borrowIteration(makeAddr("acct2"));
assertLt(first, 113_000, "acct2 1");
assertLt(second, 70_000, "acct2 2");
assertLt(third, 92_000, "acct2 3");
assertLt(first, 247_400, "acct2 1");
assertLt(second, 210_800, "acct2 2");
assertLt(third, 241_500, "acct2 3");

(first, second, third) = _borrowIteration(makeAddr("acct3"));
assertLt(first, 113_000, "acct3 1");
assertLt(second, 70_000, "acct3 2");
assertLt(third, 92_000, "acct3 3");
assertLt(first, 247_400, "acct3 1");
assertLt(second, 210_800, "acct3 2");
assertLt(third, 241_400, "acct3 3");
}
}
36 changes: 18 additions & 18 deletions protocol/test/forge/v2/templeLineOfCredit/TlcCollateral.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,19 @@ contract TempleLineOfCreditTest_Collateral is TlcBaseTest {
function test_addCollateral_gas() public {
// With unoptmised solc FOUNDRY_PROFILE=lite
(uint256 first, uint256 second, uint256 third) = _addCollateralIteration(makeAddr("acct1"));
assertLt(first, 85_000, "acct1 1");
assertLt(second, 14_000, "acct1 2");
assertLt(third, 14_000, "acct1 3");
assertLt(first, 115_000, "acct1 1");
assertLt(second, 61_200, "acct1 2");
assertLt(third, 51_600, "acct1 3");

(first, second, third) = _addCollateralIteration(makeAddr("acct2"));
assertLt(first, 36_000, "acct2 1");
assertLt(second, 14_000, "acct2 2");
assertLt(third, 14_000, "acct2 3");
assertLt(first, 78_300, "acct2 1");
assertLt(second, 61_200, "acct2 2");
assertLt(third, 51_600, "acct2 3");

(first, second, third) = _addCollateralIteration(makeAddr("acct3"));
assertLt(first, 36_000, "acct3 1");
assertLt(second, 14_000, "acct3 2");
assertLt(third, 14_000, "acct3 3");
assertLt(first, 78_300, "acct3 1");
assertLt(second, 61_200, "acct3 2");
assertLt(third, 51_600, "acct3 3");
}

function _removeCollateralIteration(address account) internal returns (uint256 first, uint256 second, uint256 third) {
Expand All @@ -295,18 +295,18 @@ contract TempleLineOfCreditTest_Collateral is TlcBaseTest {
function test_removeCollateral_gas() public {
// With unoptmised solc FOUNDRY_PROFILE=lite
(uint256 first, uint256 second, uint256 third) = _removeCollateralIteration(makeAddr("acct1"));
assertLt(first, 134_000, "acct1 1");
assertLt(second, 30_000, "acct1 2");
assertLt(third, 41_000, "acct1 3");
assertLt(first, 167_500, "acct1 1");
assertLt(second, 143_000, "acct1 2");
assertLt(third, 142_000, "acct1 3");

(first, second, third) = _removeCollateralIteration(makeAddr("acct2"));
assertLt(first, 57_000, "acct2 1");
assertLt(second, 35_000, "acct2 2");
assertLt(third, 41_000, "acct2 3");
assertLt(first, 163_300, "acct2 1");
assertLt(second, 146_200, "acct2 2");
assertLt(third, 142_000, "acct2 3");

(first, second, third) = _removeCollateralIteration(makeAddr("acct3"));
assertLt(first, 57_000, "acct3 1");
assertLt(second, 35_000, "acct3 2");
assertLt(third, 41_000, "acct3 3");
assertLt(first, 163_300, "acct3 1");
assertLt(second, 146_200, "acct3 2");
assertLt(third, 141_900, "acct3 3");
}
}
18 changes: 9 additions & 9 deletions protocol/test/forge/v2/templeLineOfCredit/TlcRepay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,18 @@ contract TempleLineOfCreditTestRepay is TlcBaseTest {
function test_repay_gas() public {
// With unoptmised solc FOUNDRY_PROFILE=lite
(uint256 first, uint256 second, uint256 third) = _repayIteration(makeAddr("acct1"));
assertLt(first, 89_000, "acct1 1");
assertLt(second, 85_000, "acct1 2");
assertLt(third, 103_000, "acct1 3");
assertLt(first, 167_100, "acct1 1");
assertLt(second, 167_100, "acct1 2");
assertLt(third, 175_500, "acct1 3");

(first, second, third) = _repayIteration(makeAddr("acct2"));
assertLt(first, 85_000, "acct2 1");
assertLt(second, 85_000, "acct2 2");
assertLt(third, 100_000, "acct2 3");
assertLt(first, 167_200, "acct2 1");
assertLt(second, 167_200, "acct2 2");
assertLt(third, 175_500, "acct2 3");

(first, second, third) = _repayIteration(makeAddr("acct3"));
assertLt(first, 85_000, "acct3 1");
assertLt(second, 85_000, "acct3 2");
assertLt(third, 100_000, "acct3 3");
assertLt(first, 167_200, "acct3 1");
assertLt(second, 167_200, "acct3 2");
assertLt(third, 175_500, "acct3 3");
}
}

0 comments on commit 59df61c

Please sign in to comment.