Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorovdg committed Mar 2, 2025
1 parent 72a7cee commit a4d221c
Show file tree
Hide file tree
Showing 22 changed files with 921 additions and 175 deletions.
858 changes: 802 additions & 56 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";
import { ethers } from "ethers";
import memoize from "memoizee";
import BigNumber from 'bignumber.js';
import { llamalend } from "./lending.js";
import { llamalend } from "./llamalend.js";
import {
IExtendedPoolDataFromApi,
INetworkName,
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ethers, Networkish } from "ethers";
import { OneWayMarketTemplate, getOneWayMarket } from "./markets/index.js";
import { LlammaTemplate, getLlamma} from "./llammas";
import { llamalend as _llamalend} from "./lending.js";
import { llamalend as _llamalend} from "./llamalend.js";
import {
getBalances,
getAllowance,
Expand Down Expand Up @@ -63,7 +63,7 @@ function setCustomFeeData (customFeeData: { gasPrice?: number, maxFeePerGas?: nu
_llamalend.setCustomFeeData(customFeeData);
}

const lending = {
const llamalend = {
init,
chainId: 0,
signerAddress: '',
Expand Down Expand Up @@ -125,4 +125,4 @@ const lending = {
},
}

export default lending;
export default llamalend;
2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface IOneWayMarket {
collateral_token: ICoin,
}

export interface ILending {
export interface ILlamalend {
provider: ethers.BrowserProvider | ethers.JsonRpcProvider,
multicallProvider: MulticallProvider,
signer: ethers.Signer | null,
Expand Down
6 changes: 3 additions & 3 deletions src/llamalend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers,
import { Provider as MulticallProvider, Contract as MulticallContract, Call } from '@curvefi/ethcall';
import {
IChainId,
ILending,
ILlamalend,
ILlamma,
IDict,
INetworkName,
Expand Down Expand Up @@ -168,7 +168,7 @@ export const NETWORK_CONSTANTS: { [index: number]: any } = {
}


class Lending implements ILending {
class Llamalend implements ILlamalend {
address: string;
provider: ethers.BrowserProvider | ethers.JsonRpcProvider;
multicallProvider: MulticallProvider;
Expand Down Expand Up @@ -782,4 +782,4 @@ class Lending implements ILending {
}
}

export const llamalend = new Lending();
export const llamalend = new Llamalend();
2 changes: 1 addition & 1 deletion src/llammas/LlammaTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import memoize from "memoizee";
import BigNumber from "bignumber.js";
import { llamalend } from "../lending.js";
import { llamalend } from "../llamalend.js";
import {
_getAddress,
parseUnits,
Expand Down
2 changes: 1 addition & 1 deletion src/markets/MarketConstructor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OneWayMarketTemplate} from "./OneWayMarketTemplate.js";
import { llamalend } from "../lending.js";
import { llamalend } from "../llamalend.js";

export const getOneWayMarket = (oneWayMarketId: string): OneWayMarketTemplate => {
const marketData = llamalend.constants.ONE_WAY_MARKETS[oneWayMarketId];
Expand Down
2 changes: 1 addition & 1 deletion src/markets/OneWayMarketTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import memoize from "memoizee";
import BigNumber from "bignumber.js";
import { llamalend } from "../lending.js";
import { llamalend } from "../llamalend.js";
import {
_getAddress,
parseUnits,
Expand Down
2 changes: 1 addition & 1 deletion src/st-crvUSD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getBalances,
MAX_ALLOWANCE,
} from "./utils.js";
import { llamalend } from "./lending.js";
import { llamalend } from "./llamalend.js";
import { TAmount, TGas } from "./interfaces.js";

// ---------------- UTILS ----------------
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Call } from "@curvefi/ethcall";
import BigNumber from 'bignumber.js';
import { ICurveContract, IDict, TGas } from "./interfaces.js";
import { _getUsdPricesFromApi } from "./external-api.js";
import { llamalend } from "./lending.js";
import { llamalend } from "./llamalend.js";
import { JsonFragment } from "ethers/lib.esm";
import { L2Networks } from "./constants/L2Networks.js";
import memoize from "memoizee";
Expand Down
24 changes: 12 additions & 12 deletions test/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import lending from "../src/index.js";
import llamalend from "../src/index.js";
import {OneWayMarketTemplate} from "../src/markets";

function cloneDeep<T>(obj: T): T {
Expand Down Expand Up @@ -106,15 +106,15 @@ describe('Fetch Markets Test', async function () {
this.timeout(1200000);

before(async function () {
await lending.init('JsonRpc', {}, { gasPrice: 0 });
await llamalend.init('JsonRpc', {}, { gasPrice: 0 });
});

it('should fetch and compare market lists with and without parameter', async function () {
await lending.oneWayfactory.fetchMarkets(true);
const marketsWithDefault = lending.oneWayfactory.getMarketList();
await llamalend.oneWayfactory.fetchMarkets(true);
const marketsWithDefault = llamalend.oneWayfactory.getMarketList();

await lending.oneWayfactory.fetchMarkets(false);
const marketsWithFalse = lending.oneWayfactory.getMarketList();
await llamalend.oneWayfactory.fetchMarkets(false);
const marketsWithFalse = llamalend.oneWayfactory.getMarketList();

assert.deepEqual(
marketsWithDefault,
Expand All @@ -124,20 +124,20 @@ describe('Fetch Markets Test', async function () {
});

it('should compare market objects from API and Blockchain', async function () {
await lending.oneWayfactory.fetchMarkets(true);
const marketListAPI = await lending.oneWayfactory.getMarketList();
await llamalend.oneWayfactory.fetchMarkets(true);
const marketListAPI = await llamalend.oneWayfactory.getMarketList();

const marketsAPI: Record<string, any> = {};
marketListAPI.forEach((item: string) => {
marketsAPI[item] = cloneDeep(lending.getOneWayMarket(item));
marketsAPI[item] = cloneDeep(llamalend.getOneWayMarket(item));
});

await lending.oneWayfactory.fetchMarkets(false);
const marketListBlockchain = await lending.oneWayfactory.getMarketList();
await llamalend.oneWayfactory.fetchMarkets(false);
const marketListBlockchain = await llamalend.oneWayfactory.getMarketList();

const marketsBlockchain: Record<string, any> = {};
marketListBlockchain.forEach((item: string) => {
marketsBlockchain[item] = cloneDeep(lending.getOneWayMarket(item));
marketsBlockchain[item] = cloneDeep(llamalend.getOneWayMarket(item));
});

marketListAPI.forEach((item: string) => {
Expand Down
6 changes: 3 additions & 3 deletions test/general.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import lending from "../src/index.js";
import llamalend from "../src/index.js";
import { getOneWayMarket, OneWayMarketTemplate } from "../src/markets/index.js";
import { BN } from "../src/utils.js";

Expand Down Expand Up @@ -206,8 +206,8 @@ describe('General test', async function () {
this.timeout(120000);

before(async function () {
await lending.init('JsonRpc', {},{ gasPrice: 0 });
await lending.oneWayfactory.fetchMarkets();
await llamalend.init('JsonRpc', {},{ gasPrice: 0 });
await llamalend.oneWayfactory.fetchMarkets();
});

for (const oneWayMarketId of ONE_WAY_MARKETS) {
Expand Down
6 changes: 3 additions & 3 deletions test/leverageBorrowMore.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import lending from "../src/index.js";
import llamalend from "../src/index.js";
import { getOneWayMarket, OneWayMarketTemplate } from "../src/markets/index.js";
import { BN } from "../src/utils.js";

Expand Down Expand Up @@ -235,8 +235,8 @@ describe('Leverage borrowMore test', async function () {
this.timeout(180000);

before(async function () {
await lending.init('JsonRpc', {},{ gasPrice: 0 });
await lending.oneWayfactory.fetchMarkets();
await llamalend.init('JsonRpc', {},{ gasPrice: 0 });
await llamalend.oneWayfactory.fetchMarkets();
});

for (const oneWayMarketId of ONE_WAY_MARKETS) {
Expand Down
6 changes: 3 additions & 3 deletions test/leverageCreateLoan.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import lending from "../src/index.js";
import llamalend from "../src/index.js";
import { getOneWayMarket, OneWayMarketTemplate } from "../src/markets/index.js";
import { BN } from "../src/utils.js";

Expand Down Expand Up @@ -226,8 +226,8 @@ describe('Leverage createLoan test', async function () {
this.timeout(180000);

before(async function () {
await lending.init('JsonRpc', {},{ gasPrice: 0 });
await lending.oneWayfactory.fetchMarkets();
await llamalend.init('JsonRpc', {},{ gasPrice: 0 });
await llamalend.oneWayfactory.fetchMarkets();
});

for (const oneWayMarketId of ONE_WAY_MARKETS) {
Expand Down
6 changes: 3 additions & 3 deletions test/leverageRepay.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import lending from "../src/index.js";
import llamalend from "../src/index.js";
import { getOneWayMarket, OneWayMarketTemplate } from "../src/markets/index.js";
import { BN } from "../src/utils.js";

Expand Down Expand Up @@ -230,8 +230,8 @@ describe('Leverage repay test', async function () {
this.timeout(180000);

before(async function () {
await lending.init('JsonRpc', {},{ gasPrice: 0 });
await lending.oneWayfactory.fetchMarkets();
await llamalend.init('JsonRpc', {},{ gasPrice: 0 });
await llamalend.oneWayfactory.fetchMarkets();
});

for (const oneWayMarketId of ONE_WAY_MARKETS) {
Expand Down
Loading

0 comments on commit a4d221c

Please sign in to comment.