@aurigami/sdk 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SDK.d.ts +2 -0
- package/dist/abis/index.d.ts +2 -1
- package/dist/contracts/misc.d.ts +1 -1
- package/dist/sdk.cjs.development.js +1404 -1371
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +789 -756
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/SDK.ts +16 -0
- package/src/abis/index.ts +2 -0
- package/src/contracts/misc.ts +4 -2
- package/ChangeLog.md +0 -163
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.7",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"typescript": "^4.5.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aurigami/contracts": "3.
|
|
65
|
+
"@aurigami/contracts": "3.8.0",
|
|
66
66
|
"axios": "^0.26.1",
|
|
67
67
|
"bignumber.js": "^9.0.2",
|
|
68
68
|
"ethers": "^5.6.4"
|
package/src/SDK.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { UltilizationHelper } from '@aurigami/contracts/typechain';
|
|
1
2
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { Contract } from 'ethers';
|
|
5
|
+
import * as abis from './abis';
|
|
2
6
|
import * as consts from './consts';
|
|
3
7
|
import { MiscRead, StakingRead, StakingReadWrite } from './contracts';
|
|
4
8
|
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from './entities';
|
|
@@ -78,6 +82,18 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
78
82
|
public async getPlyCirculatingSupply(): Promise<TokenAmount> {
|
|
79
83
|
return this._misc.getPlyCirculatingSupply();
|
|
80
84
|
}
|
|
85
|
+
|
|
86
|
+
public async getUltilizations(userAddr: types.Address): Promise<BigNumber> {
|
|
87
|
+
let helper: UltilizationHelper = new Contract(
|
|
88
|
+
consts.networkAddresses.misc.ultilizationHelper,
|
|
89
|
+
abis.UltilizationHelperABI.abi,
|
|
90
|
+
this._networkConnection.provider
|
|
91
|
+
) as UltilizationHelper;
|
|
92
|
+
let accountDetail = await helper.getAccountLiquidity(userAddr);
|
|
93
|
+
let sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
|
|
94
|
+
let sumCol = new BigNumber(accountDetail.sumCollateral.toString());
|
|
95
|
+
return sumBorrow.dividedBy(sumCol);
|
|
96
|
+
}
|
|
81
97
|
}
|
|
82
98
|
|
|
83
99
|
export class SdkReadWrite extends SdkRead {
|
package/src/abis/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interface
|
|
|
10
10
|
// import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
|
|
11
11
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
12
12
|
import Multicall2ABI from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
13
|
+
import UltilizationHelperABI from '@aurigami/contracts/artifacts/contracts/mock/UltilizationHelper.sol/UltilizationHelper.json';
|
|
13
14
|
import PulpABI from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
14
15
|
import ReferralDirectoryABI from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
|
|
15
16
|
export {
|
|
@@ -27,4 +28,5 @@ export {
|
|
|
27
28
|
EthRepayHelperABI,
|
|
28
29
|
Multicall2ABI,
|
|
29
30
|
PulpABI,
|
|
31
|
+
UltilizationHelperABI
|
|
30
32
|
};
|
package/src/contracts/misc.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { BigNumber as BN } from 'ethers';
|
|
3
3
|
import * as consts from '../consts';
|
|
4
|
-
import { MoneyMarketRead, PapermillRead, StakingRead } from '../contracts';
|
|
5
|
-
import { MulticallRead } from '../contracts/Multicall';
|
|
6
4
|
import { AuriEnv, BlockchainEntityRead, PLYToken, Token, TokenAmount } from '../entities';
|
|
7
5
|
import { decimalFactor, isSameAddress } from '../helpers/helpers';
|
|
8
6
|
import { calcValuation, fetchPrice } from '../helpers/priceFetcher';
|
|
9
7
|
import * as types from '../types';
|
|
8
|
+
import { MoneyMarketRead } from './MoneyMarket';
|
|
9
|
+
import { MulticallRead } from './Multicall';
|
|
10
|
+
import { PapermillRead } from './Papermill';
|
|
11
|
+
import { StakingRead } from './Staking';
|
|
10
12
|
|
|
11
13
|
export class MiscRead extends BlockchainEntityRead {
|
|
12
14
|
public readonly env: AuriEnv;
|
package/ChangeLog.md
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
# Change Logs
|
|
2
|
-
|
|
3
|
-
## 1.6.6
|
|
4
|
-
|
|
5
|
-
Use `public readonly` modifier instead of `private/protected` in SDK.
|
|
6
|
-
|
|
7
|
-
## 1.6.5
|
|
8
|
-
|
|
9
|
-
SDK refactor #2, remove support for loterry campaign. Package size reduced from 3MB -> 200KB
|
|
10
|
-
|
|
11
|
-
## 1.6.4
|
|
12
|
-
|
|
13
|
-
Return meaningful result instead of INF in `calcLMRewardApr`
|
|
14
|
-
|
|
15
|
-
## 1.6.3
|
|
16
|
-
|
|
17
|
-
Add USN supports. Hardcoded USN price to $1.
|
|
18
|
-
|
|
19
|
-
## 1.6.2
|
|
20
|
-
|
|
21
|
-
- Add `ReferralRead(...).getUserReferralCode(userAddr: Address): Promise<string>`: Get the referral code for a given address, returns empty string if not found. Called to check if a user has a referral code.
|
|
22
|
-
- Add `ReferralRead(...).getReferralCodeOwner(code: string): Promise<Address>`: Get owner of a referral code, returns zero address if not found.
|
|
23
|
-
- Add `ReferralRead(...).getReferralCodeUsed(userAddr: Address): Promise<string>`: Get referral code that a user was referred by, returns empty string if not found.
|
|
24
|
-
- Add `ReferralReadWrite(...).registerNewReferralCode(): Promise<TransactionResponse>`: Generate a referral code for a given address. Called when an user want to creates his own referral code
|
|
25
|
-
- Add `ReferralReadWrite(...).useReferralCode(code: string): Promise<TransactionResponse>`: Called when an user confirms he is referred by a specified code
|
|
26
|
-
|
|
27
|
-
## 1.6.1
|
|
28
|
-
|
|
29
|
-
Add `PapermillRead(...).getNextWeekTimestamp(): number`: get the start timestamp of next week of the papermill contract.
|
|
30
|
-
|
|
31
|
-
Add `SdkRead(...).getPlyCirculatingSupply(): Promise<TokenAmount>`: get the ply's circulating supply
|
|
32
|
-
|
|
33
|
-
## 1.6.0
|
|
34
|
-
|
|
35
|
-
SDK refactor - Why?:
|
|
36
|
-
|
|
37
|
-
- more modular and less coupled.
|
|
38
|
-
- more testable.
|
|
39
|
-
- more maintainable.
|
|
40
|
-
|
|
41
|
-
Things to do:
|
|
42
|
-
|
|
43
|
-
- [x] Restructure the folder structure.
|
|
44
|
-
- Refactor the code - Use composition pattern to SDK class
|
|
45
|
-
- [x] Use address from contract package instead of hardcoded address.
|
|
46
|
-
|
|
47
|
-
## 1.5.8 + 1.5.9
|
|
48
|
-
|
|
49
|
-
Fix gas error on claim rewards: Instead of claim all the rewards in all market in 1 txns, we will claim rewards in 2 txns.
|
|
50
|
-
|
|
51
|
-
## 1.5.7
|
|
52
|
-
|
|
53
|
-
- Change return type of `SdkRead(...).LpBalanceOf` and `stakeBalanceOf` from `TokenValuation` to `TokenAmount` to match other functions in the SDK.
|
|
54
|
-
- `totalStakedLiquidity` field in `PLYWNEARPoolDetails` is now `TokenAmount` instead of `TokenValuation`.
|
|
55
|
-
|
|
56
|
-
```ts
|
|
57
|
-
export type PLYWNEARPoolDetails = {
|
|
58
|
-
totalStakedLiquidity: TokenAmount;
|
|
59
|
-
APYs: TokenAPY[];
|
|
60
|
-
};
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## 1.5.6
|
|
64
|
-
|
|
65
|
-
Add PLYWNEAR pool to ALL_STAKING_POOLS
|
|
66
|
-
|
|
67
|
-
## 1.5.5
|
|
68
|
-
|
|
69
|
-
Add auPLY market, integrate new fair launch contract
|
|
70
|
-
|
|
71
|
-
Hard code PULP price to 0
|
|
72
|
-
|
|
73
|
-
## 1.5.4
|
|
74
|
-
|
|
75
|
-
Use browser-friendly assert
|
|
76
|
-
|
|
77
|
-
## 1.5.2
|
|
78
|
-
|
|
79
|
-
Added `SdkRead(...).unclaimedRewardsOf(userAddress: Address): Promise<TokenAmount[]>` to get unclaimed rewards of a user in LP staking.
|
|
80
|
-
|
|
81
|
-
## 1.5.1
|
|
82
|
-
|
|
83
|
-
Added `PapermillRead(...).getUnlockPortionAt(userAddress: Address, timestamp: number)`
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
export type TokenAPY = {
|
|
87
|
-
address: string;
|
|
88
|
-
apy: string;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type PLYWNEARPoolDetails = {
|
|
92
|
-
totalStakedLiquidity: TokenValuation;
|
|
93
|
-
APYs: TokenAPY[];
|
|
94
|
-
//apy: string; removed
|
|
95
|
-
};
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## 1.5.0 For staking PLYWNEAR
|
|
99
|
-
|
|
100
|
-
### Unchanged:
|
|
101
|
-
|
|
102
|
-
- Stake/unstake: Use `SdkReadWrite(...).stake(amount: TokenAmount)` (or `unstake`)
|
|
103
|
-
|
|
104
|
-
### Rename:
|
|
105
|
-
|
|
106
|
-
- `SdkRead(...).getPlyAuroraPoolDetails` -> `SdkRead(...).getPLYWNEARPoolDetails`
|
|
107
|
-
|
|
108
|
-
### Add
|
|
109
|
-
|
|
110
|
-
- Read:
|
|
111
|
-
- `SdkRead(...).LpBalanceOf(user: Address):TokenValuation` => amount and $ value of LP token in wallet. To get amount staked, use the old `stakeBalanceOf()` above
|
|
112
|
-
- Type:
|
|
113
|
-
- `TokenValuation` is a type that contains amount and $ value of token.
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
export type TokenValuation = {
|
|
117
|
-
tokenAmount: TokenAmount;
|
|
118
|
-
currencyAmount: CurrencyAmount;
|
|
119
|
-
};
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
```ts
|
|
123
|
-
export type PLYWNEARPoolDetails = {
|
|
124
|
-
totalStakedLiquidity: TokenValuation;
|
|
125
|
-
apy: string;
|
|
126
|
-
};
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Return type changed:
|
|
130
|
-
|
|
131
|
-
- `SdkRead(...).stakeBalanceOf()` will return `TokenValuation` instead of `TokenAmount`
|
|
132
|
-
|
|
133
|
-
### Remove:
|
|
134
|
-
|
|
135
|
-
- Type `PlyAuroraPoolDetails` removed.
|
|
136
|
-
|
|
137
|
-
## 1.5.0 For Papermill
|
|
138
|
-
|
|
139
|
-
### Add
|
|
140
|
-
|
|
141
|
-
- Read functions:
|
|
142
|
-
|
|
143
|
-
- `new PapermillRead(...).getPlyBalance(address: Address): TokenAmount` => PLY balance in user wallet
|
|
144
|
-
- `new PapermillRead(...).getPulpBalance(address: Address): TokenAmount` => PULP balance in user wallet
|
|
145
|
-
- `new PapermillRead(...).getLockingDetails(address: Address): UserLockingDetails`: Get locking details. This function is for convenience only, because the locking details are already available in the `UserLockingDetails` result (which you can get by calling the old `SdkRead(...).getUserDetails()`)
|
|
146
|
-
|
|
147
|
-
- Write functions:
|
|
148
|
-
|
|
149
|
-
- `new PapermillReadWrite(...).redeem(recipient: Address, amount: TokenAmount)` => Redeem Ply from PULP. Set `amount` to `ethers.constants.MaxUint256` for max redeem.
|
|
150
|
-
- `new PapermillReadWrite(...).selfRedeem(amount: TokenAmount)` => Redeem Ply from PULP to msg.sender. This is just a shortcut for the redeem function above.
|
|
151
|
-
- Collect all PLY reward from all markets + staking pool: No added functions, using the old `SdkReadWrite(...).claim()`
|
|
152
|
-
|
|
153
|
-
- Type:
|
|
154
|
-
- `UserLockingDetails` to store all user locking details
|
|
155
|
-
|
|
156
|
-
### Update
|
|
157
|
-
|
|
158
|
-
- `SdkRead(...).getUserDetails()`: this will include the result from `getLockingDetails`.
|
|
159
|
-
|
|
160
|
-
### Remove
|
|
161
|
-
|
|
162
|
-
- `SdkRead(...).getLockingDetails()`: Use the `getLockingDetails` in papermill instead if needed.
|
|
163
|
-
- Remove `LockingDetails` type
|