Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CONFIG_INDEXER_URL=https://dev.ponder.testnet.juicedollar.com/
CONFIG_INDEXER_FALLBACK_URL=https://dev.ponder.testnet.juicedollar.com/
CONFIG_CHAIN=testnet

RPC_URL_MAINNET=https://rpc.testnet.juiceswap.com/
RPC_URL_MAINNET=https://rpc.citrea.xyz
RPC_URL_TESTNET=https://rpc.testnet.citrea.xyz

COINGECKO_API_KEY=[API-KEY]

Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Code Owners for JuiceDollar/api
# These users must approve all pull requests to protected branches

# Default owners for everything in the repo
* @Danswar @TaprootFreak
13 changes: 10 additions & 3 deletions .github/workflows/api-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
env:
DOCKER_TAGS: dfxswiss/juicedollar-api:beta
AZURE_RESOURCE_GROUP: rg-dfx-api-dev
AZURE_CONTAINER_APP: ca-dfx-jdta-dev
AZURE_CONTAINER_APP_1: ca-dfx-jdta-dev
AZURE_CONTAINER_APP_2: ca-dfx-jdma-dev
DEPLOY_INFO: ${{ github.ref_name }}-${{ github.sha }}

jobs:
Expand Down Expand Up @@ -43,11 +44,17 @@ jobs:
with:
creds: ${{ secrets.DFX_DEV_CREDENTIALS }}

- name: Update Azure Container App
- name: Update Azure Container App 1
uses: azure/CLI@v2
with:
inlineScript: |
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP_1 }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}

- name: Update Azure Container App 2
uses: azure/CLI@v2
with:
inlineScript: |
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP_2 }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}

- name: Logout from Azure
run: |
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/api-prd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
env:
DOCKER_TAGS: dfxswiss/juicedollar-api:latest
AZURE_RESOURCE_GROUP: rg-dfx-api-prd
AZURE_CONTAINER_APP: ca-dfx-jdta-prd
AZURE_CONTAINER_APP_1: ca-dfx-jdta-prd
AZURE_CONTAINER_APP_2: ca-dfx-jdma-prd
DEPLOY_INFO: ${{ github.ref_name }}-${{ github.sha }}

jobs:
Expand Down Expand Up @@ -43,11 +44,17 @@ jobs:
with:
creds: ${{ secrets.DFX_PRD_CREDENTIALS }}

- name: Update Azure Container App
- name: Update Azure Container App 1
uses: azure/CLI@v2
with:
inlineScript: |
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP_1 }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}

- name: Update Azure Container App 2
uses: azure/CLI@v2
with:
inlineScript: |
az containerapp update --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --name ${{ env.AZURE_CONTAINER_APP_2 }} --image ${{ env.DOCKER_TAGS }} --set-env-vars DEPLOY_INFO=${{ env.DEPLOY_INFO }}

- name: Logout from Azure
run: |
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
pull_request:
branches: [develop, main]
push:
branches: [develop, main]

jobs:
build:
name: Build & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Lint
run: yarn lint
continue-on-error: true
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
MIT License

Copyright (c) 2024 frankencoin
Copyright (c) 2024 samclassix
Copyright (c) 2024 deuro
Copyright (c) 2025 juicedollar
Copyright (c) 2026 juicedollar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 7 additions & 5 deletions api.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Chain, createPublicClient, http } from 'viem';

import { Logger } from '@nestjs/common';
import { testnet } from 'chains';
import { mainnet, testnet } from 'chains';
import * as dotenv from 'dotenv';
dotenv.config();

// Verify environment
if (process.env.RPC_URL_MAINNET === undefined) throw new Error('RPC_URL_MAINNET not available');
const isMainnet = process.env.CONFIG_CHAIN === 'mainnet';
if (isMainnet && process.env.RPC_URL_MAINNET === undefined) throw new Error('RPC_URL_MAINNET not available');
if (!isMainnet && process.env.RPC_URL_TESTNET === undefined) throw new Error('RPC_URL_TESTNET not available');
if (process.env.COINGECKO_API_KEY === undefined) throw new Error('COINGECKO_API_KEY not available');

// Config type
Expand Down Expand Up @@ -40,10 +42,10 @@ export const CONFIG: ConfigType = {
indexer: process.env.CONFIG_INDEXER_URL,
indexerFallback: process.env.CONFIG_INDEXER_FALLBACK_URL,
coingeckoApiKey: process.env.COINGECKO_API_KEY,
chain: testnet,
chain: isMainnet ? mainnet : testnet,
network: {
mainnet: process.env.RPC_URL_MAINNET,
testnet: process.env.RPC_URL_MAINNET,
testnet: process.env.RPC_URL_TESTNET,
},
telegram: {
botToken: process.env.TELEGRAM_BOT_TOKEN,
Expand Down Expand Up @@ -72,7 +74,7 @@ process.env.NTBA_FIX_350 = 'true';
export const VIEM_CHAIN = CONFIG.chain;
export const VIEM_CONFIG = createPublicClient({
chain: VIEM_CHAIN,
transport: http(CONFIG.network.mainnet),
transport: http(isMainnet ? CONFIG.network.mainnet : CONFIG.network.testnet),
batch: {
multicall: {
wait: 200,
Expand Down
7 changes: 3 additions & 4 deletions chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export const testnet = defineChain({
},
});

// Juice Mainnet - To define later, same as testnet for now
export const mainnet = defineChain({
id: 62831,
id: 4114,
name: 'Mainnet',
nativeCurrency: { name: 'cBTC', symbol: 'cBTC', decimals: 18 },
rpcUrls: {
default: { http: ['https://rpc.testnet.citrea.xyz'] },
default: { http: ['https://rpc.citrea.xyz'] },
},
blockExplorers: {
default: { name: 'Juice Explorer', url: 'https://explorer.testnet.citrea.xyz' },
default: { name: 'Citrea Explorer', url: 'https://explorer.citrea.xyz' },
},
});
12 changes: 1 addition & 11 deletions ecosystem/ecosystem.collateral.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ export class EcosystemCollateralService {

const protocolStablecoinAddress = this.pricesService.getMint()?.address;
if (!protocolStablecoinAddress) return null;
const protocolStablecoinPrice = prices[protocolStablecoinAddress.toLowerCase()]?.price?.usd as number;
if (!protocolStablecoinPrice) return null;
if (!prices[protocolStablecoinAddress.toLowerCase()]?.price?.usd) return null;

const ecosystemTotalValueLocked: PriceQueryCurrencies = {};
const map: { [key: Address]: ApiEcosystemCollateralStatsItem } = {};
Expand All @@ -106,7 +105,6 @@ export class EcosystemCollateralService {
const totalBalanceNumUsd = parseInt(formatUnits(totalBalance, c.decimals)) * price;
const totalValueLocked: PriceQueryCurrencies = {
usd: totalBalanceNumUsd,
eur: totalBalanceNumUsd / protocolStablecoinPrice,
};

// upsert ecosystemTotalValueLocked usd
Expand All @@ -116,13 +114,6 @@ export class EcosystemCollateralService {
ecosystemTotalValueLocked.usd += totalValueLocked.usd;
}

// upsert ecosystemTotalValueLocked eur
if (!ecosystemTotalValueLocked.eur) {
ecosystemTotalValueLocked.eur = totalValueLocked.eur;
} else {
ecosystemTotalValueLocked.eur += totalValueLocked.eur;
}

// upsert map
map[c.address.toLowerCase() as Address] = {
address: c.address,
Expand All @@ -142,7 +133,6 @@ export class EcosystemCollateralService {
totalValueLocked,
price: {
usd: price,
eur: Math.round((price / protocolStablecoinPrice) * 100) / 100,
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juicedollar/api",
"version": "0.0.1",
"version": "1.1.0",
"private": false,
"license": "MIT",
"homepage": "https://api.juicedollar.com",
Expand Down Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@apollo/client": "^3.10.5",
"@juicedollar/jusd": "1.0.6",
"@juicedollar/jusd": "^1.1.0",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^10.0.0",
Expand Down
1 change: 1 addition & 0 deletions positions/positions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class PositionsService {
expiration: cached.expiration,
reserveContribution: cached.reserveContribution,
annualInterestPPM: cached.annualInterestPPM,
principal: cached.principal,
};
}

Expand Down
1 change: 1 addition & 0 deletions positions/positions.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ export type ApiPositionDefault = {
expiration: number;
reserveContribution: number;
annualInterestPPM: number;
principal: string;
};
8 changes: 0 additions & 8 deletions prices/prices.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ export class PricesController {
return this.pricesService.getCollateral();
}

@Get('eur')
@ApiResponse({
description: 'Returns the price of EUR in USD',
})
getEuroPrice(): Promise<PriceQueryCurrencies> {
return this.pricesService.getEuroPrice();
}

@Get('poolshares')
@ApiResponse({
description: `Returns the current price of the ${POOL_SHARES_SYMBOL} token`,
Expand Down
Loading
Loading