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
452 changes: 451 additions & 1 deletion README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/llamalend-api",
"version": "1.0.42",
"version": "1.1.0",
"description": "JavaScript library for Curve Lending",
"main": "lib/index.js",
"author": "Macket",
Expand All @@ -16,6 +16,7 @@
"scripts": {
"build": "rm -rf lib && tsc --project tsconfig.build.json",
"lint": "eslint src --ext .ts",
"lint:fix": "eslint src --ext .ts --fix",
"watch": "tsc --watch",
"watch:lib": "rm -rf lib && tsc --watch --project tsconfig.build.json"
},
Expand Down
2 changes: 1 addition & 1 deletion src/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class Cache {
// eslint-disable-next-line no-use-before-define
private static instance: Cache;
readonly cache: Map<string, any>;

Check warning on line 4 in src/cache/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

private constructor() {
this.cache = new Map<string, any>();

Check warning on line 7 in src/cache/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
}

public static getInstance(): Cache {
Expand All @@ -14,11 +14,11 @@
return Cache.instance;
}

public set(key: string, value: any): void {

Check warning on line 17 in src/cache/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
this.cache.set(key, value);
}

public get(key: string): any | undefined {

Check warning on line 21 in src/cache/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
return this.cache.get(key);
}

Expand Down
15 changes: 15 additions & 0 deletions src/constants/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const ALIASES_ETHEREUM = lowerCaseValues({
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
// "leverage_zap": "0x3294514B78Df4Bb90132567fcf8E5e99f390B687", // 1inch
"leverage_zap": "0xC5898606BdB494a994578453B92e7910a90aA873", // odos
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
"leverage_markets_start_id": "9",
"crvUSD": "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
"st_crvUSD": "0x0655977FEb2f289A4aB78af67BAB0d17aAb84367",
Expand All @@ -20,6 +21,7 @@ export const ALIASES_POLYGON = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_FANTOM = lowerCaseValues({
Expand All @@ -28,6 +30,7 @@ export const ALIASES_FANTOM = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_AVALANCHE = lowerCaseValues({
Expand All @@ -36,6 +39,7 @@ export const ALIASES_AVALANCHE = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_ARBITRUM = lowerCaseValues({
Expand All @@ -45,6 +49,7 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
// "leverage_zap": "0x61C404B60ee9c5fB09F70F9A645DD38fE5b3A956", // 1inch
"leverage_zap": "0xb7b240CFa985306563A301bC417Bc9715059a117", // odos
"leverage_zap_v2": "0x5b07Db9a85992c877b9fBeA6DCC4F79292577640",
"leverage_markets_start_id": "9",
});

Expand All @@ -55,6 +60,7 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
"gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
"leverage_zap": "0x273e44B9a1841857d9360e8792bB59f9e1FfE9Da",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
"leverage_markets_start_id": "0",
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
Expand All @@ -66,6 +72,7 @@ export const ALIASES_XDAI = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_MOONBEAM = lowerCaseValues({
Expand All @@ -74,6 +81,7 @@ export const ALIASES_MOONBEAM = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_AURORA = lowerCaseValues({
Expand All @@ -89,6 +97,7 @@ export const ALIASES_KAVA = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_CELO = lowerCaseValues({
Expand All @@ -97,6 +106,7 @@ export const ALIASES_CELO = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_ZKSYNC = lowerCaseValues({
Expand All @@ -105,6 +115,7 @@ export const ALIASES_ZKSYNC = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB", // <--- TODO CHANGE
"gauge_factory": "0x0000000000000000000000000000000000000000",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_BASE = lowerCaseValues({
Expand All @@ -113,6 +124,7 @@ export const ALIASES_BASE = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB", // <--- TODO CHANGE
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_BSC = lowerCaseValues({
Expand All @@ -121,6 +133,7 @@ export const ALIASES_BSC = lowerCaseValues({
"gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
"leverage_zap": "0x0000000000000000000000000000000000000000",
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
});

export const ALIASES_FRAXTAL = lowerCaseValues({
Expand All @@ -130,6 +143,7 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
"gauge_factory_old": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
"gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
"leverage_zap": "0x37c5ab57AF7100Bdc9B668d766e193CCbF6614FD", // odos
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
"leverage_markets_start_id": "0",
});

Expand All @@ -139,5 +153,6 @@ export const ALIASES_SONIC = lowerCaseValues({
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
"gauge_factory": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
"leverage_zap": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7", // odos
"leverage_zap_v2": "0x0000000000000000000000000000000000000000",
"leverage_markets_start_id": "0",
});
8 changes: 4 additions & 4 deletions src/external-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
)

export const _getUserCollateralForce = async (
network: INetworkName,
controller: string,
user: string,
network: INetworkName,
controller: string,
user: string,
newTx: string
): Promise<void> => {
await fetch(`https://prices.curve.finance/v1/lending/collateral_events/${network}/${controller}/${user}?new_tx=${newTx}`);
Expand Down Expand Up @@ -218,7 +218,7 @@
async () => {
const response = await fetch(`https://api.curve.finance/api/getHiddenPools`)

return (await response.json() as any).data

Check warning on line 221 in src/external-api.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
},
{
promise: true,
Expand All @@ -226,7 +226,7 @@
}
)

async function fetchJson(url: string): Promise<any> {

Check warning on line 229 in src/external-api.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
const response = await fetch(url);
return await response.json() ?? {};
}
Expand All @@ -234,4 +234,4 @@
async function fetchData(url: string) {
const {data} = await fetchJson(url);
return data;
}
}
19 changes: 19 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export interface ICurveContract {
contract: Contract,
multicallContract: MulticallContract,
abi: any,

Check warning on line 16 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
address: string
}

Expand All @@ -40,7 +40,7 @@
max_bands: number,
default_bands: number,
A: number,
monetary_policy_abi: any

Check warning on line 43 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
is_deleverage_supported?: boolean
index?: number
}
Expand Down Expand Up @@ -186,7 +186,7 @@
monetaryPolicyAddress: string;
rates: Rates;
gaugeAddress: string;
gaugeRewards: any[];

Check warning on line 189 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
assets: Assets;
vaultShares: VaultShares;
totalSupplied: Total;
Expand Down Expand Up @@ -230,3 +230,22 @@
export interface IResponseApi {
data: any
}

export interface IQuote {
outAmount: string,
priceImpact: number
}

export interface ILeverageMetrics {
priceImpact: number,
bands: [number, number],
prices: string[],
health: string,
}

export type GetExpectedFn = (
fromToken: string,
toToken: string,
amountIn: bigint,
blacklist: string | string[],
) => Promise<IQuote>;
Loading
Loading