Skip to content

Commit

Permalink
refactor: sdk cleaning old useless stuff (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec authored Dec 7, 2023
1 parent 08688bd commit 038a3d0
Show file tree
Hide file tree
Showing 18 changed files with 5 additions and 408 deletions.
2 changes: 0 additions & 2 deletions .env.sample

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

First of all thank you for your interest in this repository!

This is only the beginning of the Angle protocol and codebase, and anyone is welcome to improve it.
This is only the beginning of the Angle protocol and Merkl codebases, and anyone is welcome to improve them.

To submit some code, please work in a fork, reach out to explain what you've done and open a Pull Request from your fork.

Expand Down
65 changes: 1 addition & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,9 @@
# <img src="logo.svg" alt="Angle SDK" height="40px"> Angle SDK

- [Angle SDK](#angle-sdk)
- [Warning:](#warning)
- [Estimators](#estimators)
- [Example:](#example)
- [Ethereum Read & Write](#ethereum-read--write)
- [Example:](#example-1)
- [Keeper functions](#keeper-functions)
- [Constants](#constants)
- [Lib](#lib)
- [Build and use in development environment](#build-and-use-in-development-enviroment)

SDK to build applications on top of [Angle Protocol](https://angle.money).
This is a SDK maintained by Angle Labs to build applications on top of [Angle Protocol](https://angle.money) and [Merkl](https://merkl.angle.money).

## Warning

This SDK is in open beta, and is constantly under development. USE AT YOUR OWN RISK.

Please make sure you're using the last SDK version, otherwise the results / addresses may be incorrect.

## Estimators

Estimators are utility functions to preview the result of Angle's operations.

```js
import { estimateMint, parseAmount } from '@angleprotocol/sdk';
// To compute the amount of stablecoin you'd get from a mint

const stablecoinsObtained = await estimateMint(parseAmount.usdc(1), 'USDC', 'agEUR');
console.log(stablecoinsObtained);
```

## Ethereum Read & Write

Located in the `calls` folder, these functions are example of scripted interactions with Angle Protocol's contracts.

```js
import { ethers } from 'ethers';

import { ChainId, harvest } from '@angleprotocol/sdk';
// To harvest a collateral strategy

const signer = // initialize an ethers signer

const receipt = await harvest(ChainId.MAINNET, 'agEUR', 'USDC', signer);
await receipt.wait();
```

## Keeper functions

Located in the `calls` folder, a set of functions that can be used to build keeper bots

## Constants

Located in the `constants` folder, all the contract addresses, parameters and abis

## Lib

Located in the `lib` folder, a set of classes and utilities that can be used to work with big numbers

### Build and use in development environment

1. To properly generate the ABI types run `yarn generate-types-from-abis`.

2. To build the SDK run `yarn build`.

3. Once built, run `yarn link`. This will create a symbolic link to this package in your local yarn repositories.

4. To add the local package to your project, go in the root directory of your project (where you would typically run `yarn add ...`) and run `yarn link @angleprotocol/sdk`. _Notice that `@angleprotocol/sdk` is the name of the SDK project in its `package.json` file._

If you update the SDK you will have to rerun Step 1 but the linking to the newest version will be done automatically in the other projects (you do not need to rerun Steps 2 and 3)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@angleprotocol/sdk",
"version": "3.0.126",
"description": "SDK for Angle Protocol DApps",
"description": "SDK for Angle DApps",
"keywords": [
"angle",
"angle money",
Expand All @@ -26,7 +26,7 @@
},
"license": "GPL-3.0-or-later",
"author": {
"name": "Angle Core Team",
"name": "Angle Labs",
"email": "[email protected]",
"url": "https://angle.money"
},
Expand Down
77 changes: 1 addition & 76 deletions src/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ import LINEA_ADDRESSES from './contracts_addresses/linea';
import ZKSYNC_ADDRESSES from './contracts_addresses/zksync';
import MANTLE_ADDRESSES from './contracts_addresses/mantle';

export enum AMO {
'agEURvEUROC' = 'agEURvEUROC',
}

type AMOType = Readonly<{
AMO: string;
KeeperJob: string;
}>;

export enum BorrowCollateral {
'LUSD' = 'LUSD',
'bIB01' = 'bIB01',
Expand Down Expand Up @@ -60,23 +51,6 @@ type BorrowCollateralType = {
};
};

export enum LenderStrategy {
'GenericOptimisedLender' = 'GenericOptimisedLender',
'AaveFlashloan' = 'AaveFlashloan',
}

type LenderStrategyType = {
AaveConvexStaker?: string;
Contract: string;
GenericAave?: string;
GenericCompound?: string;
GenericEuler?: string;
};

export enum SimpleStrategy {
'StETH' = 'StETH',
}

export enum Collateral {
'DAI' = 'DAI',
'FEI' = 'FEI',
Expand All @@ -97,12 +71,6 @@ type CollateralType = Readonly<
PoolManager: string;
SanToken: string;
Staking?: string;
Strategies?: {
[strategy in SimpleStrategy]?: string;
} &
{
[strategy in LenderStrategy]?: LenderStrategyType;
};
}>
>;

Expand Down Expand Up @@ -132,7 +100,6 @@ type StablecoinType = Readonly<
Anyswap?: string;
LayerZero?: string;
RainbowBridge?: string;
Synapse?: string;
};
}>
>;
Expand Down Expand Up @@ -174,24 +141,10 @@ export type ContractsRegistryType = Readonly<
Timelock: string;
veANGLE: string;
veBoostProxy: string;
ExternalStakings: {
tokenName: string;
stakingContractAddress: string;
poolContractAddress: string;
liquidityGaugeAddress?: string;
}[];
Gauges: { gaugeName: string; gaugeAddress: string; type: number }[];
AMO: {
AMOMinter: string;
BPAMOs?: {
[key in AMO]?: AMOType;
};
};
bridges?: {
Anyswap?: string;
LayerZero?: string;
RainbowBridge?: string;
Synapse?: string;
};
} & {
[key in Stablecoin]?: StablecoinType;
Expand Down Expand Up @@ -225,9 +178,6 @@ type RegistryArgs =
| {
stablecoin: Stablecoin | string;
}
| {
amo: AMO | string;
}
| {
stablecoin: Stablecoin | string;
collateral: Collateral | string;
Expand All @@ -239,21 +189,13 @@ type RegistryArgs =
| {
stablecoin: Stablecoin | string;
collateral: Collateral | string;
strategy: SimpleStrategy | string;
}
| {
stablecoin: Stablecoin | string;
collateral: Collateral | string;
lenderStrategy: LenderStrategy | string;
};

export function registry(chainId: number | ChainId): ContractsRegistryType['1'] | undefined;
export function registry(
chainId: number | ChainId,
args: {
amo: AMO | string;
}
): AMOType | undefined;
export function registry(chainId: number | ChainId, stablecoin: Stablecoin | string): StablecoinType | undefined;
export function registry(
chainId: number | ChainId,
Expand Down Expand Up @@ -285,40 +227,23 @@ export function registry(
args: {
stablecoin: Stablecoin | string;
collateral: Collateral | string;
strategy: SimpleStrategy | string;
}
): string | undefined;
export function registry(
chainId: number | ChainId,
args: {
stablecoin: Stablecoin | string;
collateral: Collateral | string;
lenderStrategy: LenderStrategy | string;
}
): LenderStrategyType | undefined;
export function registry(chainId: number | ChainId, args: RegistryArgs = null, collateral: Collateral | string | null = null): any {
if (!!args && typeof args === 'string' && !!collateral) {
return registry(chainId, { stablecoin: args, collateral: collateral });
}
if (!!args && typeof args === 'string') {
return registry(chainId, { stablecoin: args });
}
if (!!args && typeof args !== 'string' && 'strategy' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.[args.stablecoin as Stablecoin]?.collaterals?.[args.collateral as Collateral]
?.Strategies?.[args.strategy as SimpleStrategy];
} else if (!!args && typeof args !== 'string' && 'lenderStrategy' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.[args.stablecoin as Stablecoin]?.collaterals?.[args.collateral as Collateral]
?.Strategies?.[args.lenderStrategy as LenderStrategy];
} else if (!!args && typeof args !== 'string' && 'borrowCollateral' in args) {
if (!!args && typeof args !== 'string' && 'borrowCollateral' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.[args.stablecoin as Stablecoin]?.borrowCollaterals?.[
args.borrowCollateral as BorrowCollateral
];
} else if (!!args && typeof args !== 'string' && 'collateral' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.[args.stablecoin as Stablecoin]?.collaterals?.[args.collateral as Collateral];
} else if (!!args && typeof args !== 'string' && 'stablecoin' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.[args.stablecoin as Stablecoin];
} else if (!!args && typeof args !== 'string' && 'amo' in args) {
return CONTRACTS_ADDRESSES[chainId as ChainId]?.AMO?.BPAMOs?.[args.amo as AMO];
} else {
return CONTRACTS_ADDRESSES[chainId as ChainId];
}
Expand Down
1 change: 0 additions & 1 deletion src/constants/contracts_addresses/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const addresses: ContractsRegistryType['1'] = {
},
},
bridges: {
Synapse: '0x16BFc5fe024980124bEf51d1D792dC539d1B5Bf0',
LayerZero: '0x16cd38b1B54E7abf307Cb2697E2D9321e843d5AA',
},
OracleTokenUSD: '0xA14d53bC1F1c0F31B4aA3BD109344E5009051a84',
Expand Down
1 change: 0 additions & 1 deletion src/constants/contracts_addresses/aurora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const addresses: ContractsRegistryType['1'] = {
RainbowBridge: '0xdc7AcDE9ff18B4D189010a21a44cE51ec874eA7C',
},
},
ExternalStakings: [],
Governor: '0xb87a5C4f023e6b9F0B78905dB0B00f82e47952bE',
Guardian: '0x9864AeBFF39e1ED02545856aE0e595E97fC6fCb4',
};
Expand Down
7 changes: 0 additions & 7 deletions src/constants/contracts_addresses/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ const addresses: ContractsRegistryType['1'] = {
SwapperV2: '0x5e6955627e30660ecA4bCA2fB8Ac09e0DBEb63C1',
Treasury: '0xa014A485D64efb236423004AB1a99C0aaa97a549',
},
ExternalStakings: [
{
tokenName: 'Pangolin agEUR/AVAX',
stakingContractAddress: '',
poolContractAddress: '0x4A045a80967B5ecc440c88dF9a15a3339d43D029',
},
],
CoreBorrow: '0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD',
FlashAngle: '0x9C215206Da4bf108aE5aEEf9dA7caD3352A36Dad',
Governor: '0x43a7947A1288e65fAF30D8dDb3ca61Eaabd41613',
Expand Down
1 change: 0 additions & 1 deletion src/constants/contracts_addresses/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const addresses: ContractsRegistryType['1'] = {
Anyswap: '0x02a2b736F9150d36C0919F3aCEE8BA2A92FBBb40',
},
},
ExternalStakings: [],
};

export default addresses;
Loading

0 comments on commit 038a3d0

Please sign in to comment.