Skip to content

Commit

Permalink
Merge branch 'main' into fix/apollo-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax authored Aug 9, 2024
2 parents 43d9672 + 130f4ba commit 8acb55e
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/sdks

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/sdks

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/sdks
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
"version": "1.5.4",
"version": "1.5.6",
"npmClient": "yarn",
"useWorkspaces": true
}
8 changes: 8 additions & 0 deletions packages/blue-api-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-api-sdk

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-api-sdk

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-api-sdk
Expand Down
2 changes: 1 addition & 1 deletion packages/blue-api-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/blue-api-sdk",
"version": "1.5.4",
"version": "1.5.6",
"author": "Morpho Association <contact@morpho.org>",
"main": "src/index.ts",
"files": [
Expand Down
8 changes: 8 additions & 0 deletions packages/blue-sdk-ethers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-ethers

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-ethers

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-ethers
Expand Down
2 changes: 1 addition & 1 deletion packages/blue-sdk-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/blue-sdk-ethers",
"version": "1.5.4",
"version": "1.5.6",
"author": "Morpho Association <contact@morpho.org>",
"license": "MIT",
"main": "src/index.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/blue-sdk-viem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-viem

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-viem

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk-viem
Expand Down
2 changes: 1 addition & 1 deletion packages/blue-sdk-viem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/blue-sdk-viem",
"version": "1.5.4",
"version": "1.5.6",
"author": "Morpho Association <contact@morpho.org>",
"license": "MIT",
"main": "src/index.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/blue-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/blue-sdk
Expand Down
2 changes: 1 addition & 1 deletion packages/blue-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/blue-sdk",
"version": "1.5.4",
"version": "1.5.6",
"author": "Morpho Association <contact@morpho.org>",
"license": "MIT",
"main": "src/index.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/blue-sdk/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const addresses = {
aaveV2Bundler: "0xb3dCc75DB379925edFd3007511A8CE0cB4aa8e76" as const,
aaveV3Bundler: "0x98ccB155E86bb478d514a827d16f58c6912f9BDC" as const,
compoundV3Bundler: "0x3a0e2E9FB9c95fBc843daF166276C90B6C479558" as const,
compoundV2Bundler: "0x26bf52a84360ad3d01d7cdc28fc2ddc04d8c8647" as const,
adaptiveCurveIrm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" as const,
publicAllocator: "0xfd32fA2ca22c76dD6E550706Ad913FC6CE91c75D" as const,

Expand Down Expand Up @@ -76,6 +77,7 @@ export const addresses = {
morpho: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb" as const,
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3" as const,
bundler: "0x23055618898e202386e6c13955a58D3C68200BFB" as const,
compoundV2Bundler: "0x123f3167a416cA19365dE03a65e0AF3532af7223" as const,
aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108" as const,
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA" as const,
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687" as const,
Expand All @@ -96,6 +98,7 @@ export interface ChainAddresses {
aaveV2Bundler?: Address;
aaveV3Bundler?: Address;
compoundV3Bundler?: Address;
compoundV2Bundler?: Address;
adaptiveCurveIrm?: Address;
publicAllocator?: Address;

Expand Down
24 changes: 11 additions & 13 deletions packages/blue-sdk/src/maths/MathLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,27 @@ export class MathLib {
}

/**
* Converts an apr to compounded apy
* Converts an rate to compounded apy
*
* @param apr The rate to convert (in WAD)
* @param compounding The compounding basis
* @param rate The rate to convert (in WAD)
* @param period The compounding basis
*/
static rateToApy(rate: BigIntish, unit: Time.Unit) {
const factor = Time[unit].from.y(1n);
static rateToApy(rate: BigIntish, period: Time.PeriodLike) {
const { unit, duration } = Time.toPeriod(period);
const factor = Time[unit].from.y(1) / duration;

return (
(1 + Number(format.number.of(BigInt(rate), 18))) ** Number(factor) - 1
);
return (1 + Number(format.number.of(BigInt(rate), 18))) ** factor - 1;
}

/**
* Converts an apr to compounded apy
*
* @param apr The yearly apr to convert (in WAD)
* @param apr The apr to convert (in WAD)
* @param compounding The compounding basis
*/
static aprToApy(apr: BigIntish, compounding: Time.Unit) {
const factor = Time[compounding].from.y(1n);

const rate = BigInt(apr) / factor;
static aprToApy(apr: BigIntish, compounding: Time.PeriodLike) {
const { unit, duration } = Time.toPeriod(compounding);
const rate = (BigInt(apr) * BigInt(duration)) / Time[unit].from.y(1n);

return this.rateToApy(rate, compounding);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/morpho-test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-test

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-test

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-test
Expand Down
2 changes: 1 addition & 1 deletion packages/morpho-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/morpho-test",
"version": "1.5.4",
"version": "1.5.6",
"main": "src/index.ts",
"files": [
"lib"
Expand Down
8 changes: 8 additions & 0 deletions packages/morpho-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 1.5.6 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-ts

## 1.5.5 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-ts

## 1.5.4 (2024-08-07)

**Note:** Version bump only for package @morpho-org/morpho-ts
Expand Down
2 changes: 1 addition & 1 deletion packages/morpho-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morpho-org/morpho-ts",
"version": "1.5.4",
"version": "1.5.6",
"author": "Morpho Association <contact@morpho.org>",
"license": "MIT",
"main": "src/index.ts",
Expand Down
16 changes: 15 additions & 1 deletion packages/morpho-ts/src/time/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const toNumberish = (returnValue: bigint, initialValue: bigint | number) => {
};

const UNITS = ["ms", "s", "min", "h", "d", "w", "mo", "y"] as const;
export type TUnit = (typeof UNITS)[number];
type TUnit = (typeof UNITS)[number];
type TPeriod = {
unit: TUnit;
duration: number;
};

type P = {
[U in TUnit]: <T extends number | bigint>(
Expand Down Expand Up @@ -99,6 +103,16 @@ Object.defineProperties(

export namespace Time {
export type Unit = TUnit;
export type Period = TPeriod;
export type PeriodLike = TPeriod | TUnit;

export function toPeriod(periodLike: PeriodLike): Period {
if (typeof periodLike === "object") return periodLike;
return {
unit: periodLike,
duration: 1,
};
}

export async function wait<T>(ms: number, value?: T) {
return new Promise((resolve) => setTimeout(() => resolve(value), ms));
Expand Down

0 comments on commit 8acb55e

Please sign in to comment.