# @bluejayfinance/functions

> This repository contains different serverless function used in the operations of the protocol.

Latest version **0.1.8** (published 2022-05-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @bluejayfinance/functions
pnpm add @bluejayfinance/functions
yarn add @bluejayfinance/functions
bun add @bluejayfinance/functions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2022-05-10 |
| First published | 2021-10-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 20 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 (+24 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | nebulis, whitefables |

## Links

- npm: https://www.npmjs.com/package/@bluejayfinance/functions
- npm.io page: https://npm.io/package/@bluejayfinance/functions

## Dependencies (20)

- [axios](https://npm.io/package/axios.md) ^0.22.0
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [middy](https://npm.io/package/middy.md) ^0.24.0
- [ethers](https://npm.io/package/ethers.md) ^5.0.24
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.655.0
- [ethcall](https://npm.io/package/ethcall.md) ^4.4.0
- [date-fns](https://npm.io/package/date-fns.md) ^2.16.1
- [runtypes](https://npm.io/package/runtypes.md) ^6.4.1
- [telegraf](https://npm.io/package/telegraf.md) ^4.4.2
- [serverless](https://npm.io/package/serverless.md) ^1.62.0
- [@middy/core](https://npm.io/package/@middy/core.md) ^1.5.0
- [@types/uuid](https://npm.io/package/@types/uuid.md) ^8.3.0
- [http-errors](https://npm.io/package/http-errors.md) ^1.7.3
- [user-agents](https://npm.io/package/user-agents.md) ^1.0.800
- [aws-xray-sdk-core](https://npm.io/package/aws-xray-sdk-core.md) ^2.5.0
- [serverless-dotenv-plugin](https://npm.io/package/serverless-dotenv-plugin.md) ^1.2.0
- [@bluejayfinance/contracts](https://npm.io/package/@bluejayfinance/contracts.md) ^0.1.8
- [@middy/http-security-headers](https://npm.io/package/@middy/http-security-headers.md) ^1.5.0
- [middy-middleware-json-error-handler](https://npm.io/package/middy-middleware-json-error-handler.md) ^1.0.0

## Recent versions

- 0.1.8 (latest) — 2022-05-10
- 0.1.7 — 2022-05-07
- 0.1.6 — 2021-10-25
- 0.1.5 — 2021-10-21
- 0.1.4 — 2021-10-19
- 0.1.3 — 2021-10-13
- 0.1.2 — 2021-10-12
- 0.1.1 — 2021-10-11

## README

# Serverless Functions

This repository contains different serverless function used in the operations of the protocol.

## Functions

### /debug

This is a debug function that returns a status "OK" and prints call information to the logs. 

You may use this in local development to test out calls easily. 

### /updateOracles

This function updates the BLU/DAI TWAP oracle and the SGD/DAI TWAP oracle. It's scheduled to run at fixed interval to update stale results on the oracle. 

Set the env `ORACLE_UPDATE_SGD` to allow this function to update the SGD/DAI oracle when the oracle is available.

## Development

### Set environment variables

For development, copy the `.env.example` to `.env` and set the necessary environment variables:

`NETWORK` - Choose between "local", "development" or "production". Local runs against a local blockchain, development runs against the rinkeby blockchain and production runs against mainnet.

`ALCHEMY_KEY` - API key from alchemy for the providers.

`TELEGRAM_BOT_TOKEN` & `TELEGRAM_CHAT_ID` - To configure the telegram bot. Use botfather to create a new bot when testing locally.

`ORACLE_UPDATER_KEY` - Private key with Ethers on the network defined in `NETWORK`. Does not require special permission since the oracle can be updated by anyone. In local environment, you can use key #1 or #2.

`ORACLE_UPDATE_SGD` - Allow `updateOracle` to update SGD/DAI oracle.

### Running the functions locally.

Run `npm run dev` and visit `localhost:3000/debug` to visit the debug function.

### Creating new functions

1. Read https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml
2. Configure the routes at `serverless.yml`
3. Add the functions logic in `src/functionHandlers` using one of the request handlers in `src/middlewares` (see debug function for template)

---
_Source: https://npm.io/package/@bluejayfinance/functions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
