@aurigami/sdk 0.3.0 → 0.3.4
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/constants.d.ts +1 -1
- package/dist/sdk.cjs.development.js +69 -82
- 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 +69 -82
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/MoneyMarket.ts +1 -7
- package/src/SDK.ts +6 -9
- package/src/constants.ts +24 -24
- package/src/decimals.ts +17 -16
- package/src/types.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^4.5.4"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@aurigami/contracts": "^1.
|
|
60
|
+
"@aurigami/contracts": "^1.1.1",
|
|
61
61
|
"axios": "^0.24.0",
|
|
62
62
|
"bignumber.js": "^9.0.2",
|
|
63
63
|
"ethers": "^5.0.0"
|
package/src/MoneyMarket.ts
CHANGED
|
@@ -45,13 +45,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
protected async getRewardSpeeds(): Promise<RewardSpeeds> {
|
|
48
|
-
var
|
|
49
|
-
var speeds = {} as RewardSpeeds;
|
|
50
|
-
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address, true).then((res: BN) => {speeds.plyRewardSupplySpeed = res}));
|
|
51
|
-
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.PLY, this.auToken.address, false).then((res: BN) => {speeds.plyRewardBorrowSpeed = res}));
|
|
52
|
-
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.AURORA, this.auToken.address, true).then((res: BN) => {speeds.auroraRewardSupplySpeed = res}));
|
|
53
|
-
promises.push(this._comptroller.rewardSpeeds(ComptrollerRewardType.AURORA, this.auToken.address, false).then((res: BN) => {speeds.auroraRewardBorrowSpeed = res}));
|
|
54
|
-
await Promise.all(promises);
|
|
48
|
+
var speeds = await this._auriLens.getRewardSpeeds(this._comptroller.address, this.auToken.address);
|
|
55
49
|
return speeds;
|
|
56
50
|
}
|
|
57
51
|
public async getTotalTokenBorrowed(): Promise<TokenAmount> {
|
package/src/SDK.ts
CHANGED
|
@@ -39,7 +39,6 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public async getLockingDetails(): Promise<LockingDetails> {
|
|
42
|
-
console.log(this._networkConnection.provider)
|
|
43
42
|
const currentTime = await getCurrentTimestamp(this._networkConnection.provider);
|
|
44
43
|
const currentWeek = BN.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
|
|
45
44
|
const denominator = 10000;
|
|
@@ -59,7 +58,6 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
59
58
|
public async getUserDetails(userAddress: string): Promise<UserDetails> {
|
|
60
59
|
const marketCount = networkAddresses.auTokens.length;
|
|
61
60
|
var userMarketDetails: UserMarketDetails[] = [], assetsIn: string[];
|
|
62
|
-
var collateralRatio: BigNumber[] = new Array(marketCount);
|
|
63
61
|
var promises = [];
|
|
64
62
|
var totalBorrowLimit = new BigNumber(0);
|
|
65
63
|
var pricePromises = [];
|
|
@@ -70,7 +68,7 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
70
68
|
const moneyMarket: MoneyMarketRead = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
|
|
71
69
|
promises.push(moneyMarket.getUserDepositBalance(userAddress).then((res: TokenAmount) => {userMarketDetail.depositBalance = res}));
|
|
72
70
|
promises.push(moneyMarket.getUserBorrowBalance(userAddress).then((res: TokenAmount) => {userMarketDetail.borrowBalance = res}));
|
|
73
|
-
promises.push(moneyMarket.getCollateralRatio().then((res: BigNumber) => {collateralRatio
|
|
71
|
+
promises.push(moneyMarket.getCollateralRatio().then((res: BigNumber) => {userMarketDetail.collateralRatio = res.toNumber()}));
|
|
74
72
|
pricePromises.push(fetchPrice(moneyMarket.underlying.address, this._networkConnection.provider));
|
|
75
73
|
}
|
|
76
74
|
|
|
@@ -82,19 +80,19 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
82
80
|
|
|
83
81
|
for (var i = 0; i < marketCount; i ++) {
|
|
84
82
|
const auToken = networkAddresses.auTokens[i];
|
|
85
|
-
if (assetsIn!.
|
|
86
|
-
isSameAddress(auToken.address, auAddress)
|
|
87
|
-
}).length > 0) {
|
|
83
|
+
if (assetsIn!.find((auAddress: Address) => isSameAddress(auToken.address, auAddress)) !== undefined) {
|
|
88
84
|
userMarketDetails[i].isCollateral = true;
|
|
85
|
+
} else {
|
|
86
|
+
userMarketDetails[i].isCollateral = false;
|
|
89
87
|
}
|
|
90
88
|
depositValuationPromises.push(fetchValuation(userMarketDetails[i].depositBalance, this._networkConnection.provider, underlyingPrices[i]));
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
var depositValues = await Promise.all(depositValuationPromises);
|
|
94
92
|
totalBorrowLimit = depositValues.reduce((p: BigNumber, v: BigNumber, index: number)=> {
|
|
95
|
-
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(
|
|
93
|
+
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
96
94
|
return p;
|
|
97
|
-
})
|
|
95
|
+
}, new BigNumber(0))
|
|
98
96
|
|
|
99
97
|
promises = [];
|
|
100
98
|
var accountLiquidity: [BN, BN, BN], rewardBalancesMetadata, lockedAmount: BN;
|
|
@@ -141,7 +139,6 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
141
139
|
var stakedLiquidity: BN, rewardPerSecond: BN;
|
|
142
140
|
var promises = [];
|
|
143
141
|
promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then((res) => {
|
|
144
|
-
console.log(res)
|
|
145
142
|
stakedLiquidity = res.totalStake;
|
|
146
143
|
rewardPerSecond = res.rewardPerSecond;
|
|
147
144
|
}));
|
package/src/constants.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const AVAX_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
|
|
|
9
9
|
AVAX_DEFAULT_PROVIDER_URL
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
export const AURORA_DEFAULT_PROVIDER_URL = "https://
|
|
12
|
+
export const AURORA_DEFAULT_PROVIDER_URL = "https://mainnet.aurora.dev";
|
|
13
13
|
|
|
14
14
|
export const AURORA_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
|
|
15
15
|
AURORA_DEFAULT_PROVIDER_URL
|
|
@@ -36,49 +36,49 @@ export type NetworkAddresses = {
|
|
|
36
36
|
export const networkAddresses: NetworkAddresses = {
|
|
37
37
|
auTokens: [
|
|
38
38
|
{
|
|
39
|
-
address: '
|
|
40
|
-
underlying: '
|
|
39
|
+
address: '0x2dEf6eb801757655AD227110d65C80DB595bBc60'.toLowerCase(),
|
|
40
|
+
underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
address: '
|
|
43
|
+
address: '0x7b47690b04494A628151Dbb86B4cC95CF2629B14'.toLowerCase(),
|
|
44
44
|
underlying: ETHAddress.toLowerCase()
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
address: '
|
|
48
|
-
underlying: '
|
|
47
|
+
address: '0xFB0e4680B8b1c7B69fb6a3988029c74fea871DD9'.toLowerCase(),
|
|
48
|
+
underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
|
-
address: '
|
|
52
|
-
underlying: '
|
|
51
|
+
address: '0x6bB82009b316A9098C23E3962b4371E879c8D23D'.toLowerCase(),
|
|
52
|
+
underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
address: '
|
|
56
|
-
underlying: '
|
|
55
|
+
address: '0xBf43057c634868251e65e39b4f27662f644454b4'.toLowerCase(),
|
|
56
|
+
underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
address: '
|
|
60
|
-
underlying: '
|
|
59
|
+
address: '0x83Ae17f197C1F1260543d4D5A710772761535066'.toLowerCase(),
|
|
60
|
+
underlying: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
address: '
|
|
64
|
-
underlying: '
|
|
63
|
+
address: '0xcC5CA0156317C1FF2A96E0f45659625081352071'.toLowerCase(),
|
|
64
|
+
underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
address: '
|
|
68
|
-
underlying: '
|
|
67
|
+
address: '0x173Bf18675D52B4887C5d40E935C3ab1192aFb4C'.toLowerCase(),
|
|
68
|
+
underlying: '0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be'.toLowerCase()
|
|
69
69
|
}
|
|
70
70
|
],
|
|
71
71
|
misc: {
|
|
72
|
-
COMPTROLLER: "
|
|
73
|
-
oracle: "
|
|
74
|
-
AURIFAIRLAUNCH: "
|
|
75
|
-
AURILENS: '
|
|
76
|
-
TOKENLOCK: '
|
|
72
|
+
COMPTROLLER: "0x3b416D37A85F7aD941e36258d4Da660A1898E181".toLowerCase(),
|
|
73
|
+
oracle: "0x08A74ca75BAE803e92752f8d7A5cD718b1cA6509".toLowerCase(),
|
|
74
|
+
AURIFAIRLAUNCH: "0xeed0433Cbc81F25061bb739Ff8f1D5736b16d038".toLowerCase(),
|
|
75
|
+
AURILENS: '0xb11820C3d8ae1f6C31047644C59190280651C9da'.toLowerCase(),
|
|
76
|
+
TOKENLOCK: '0x537754515509A83Ce2D076c0982292AC5289b408'.toLowerCase()
|
|
77
77
|
},
|
|
78
78
|
tokens: {
|
|
79
|
-
AURORA: "
|
|
80
|
-
PLY: "
|
|
81
|
-
AURPLY:
|
|
79
|
+
AURORA: "0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
|
|
80
|
+
PLY: "0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be".toLowerCase(),
|
|
81
|
+
AURPLY: "0x822E871518C22E8570cFbEa43FddbBFF963d4bdE".toLowerCase()
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
package/src/decimals.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
export const decimalRecords: Record<string, number> = {
|
|
2
2
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
|
|
3
|
+
'0xb9b8d9e5557381bf025f1a59b602ad3f19a4e4be': 18,
|
|
4
|
+
'0x83ae17f197c1f1260543d4d5a710772761535066': 8,
|
|
5
|
+
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
|
|
6
|
+
'0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
|
|
7
|
+
'0xfb0e4680b8b1c7b69fb6a3988029c74fea871dd9': 8,
|
|
8
|
+
'0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
|
|
9
|
+
'0xbf43057c634868251e65e39b4f27662f644454b4': 8,
|
|
10
|
+
'0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
|
|
11
|
+
'0x7b47690b04494a628151dbb86b4cc95cf2629b14': 8,
|
|
12
|
+
'0x822e871518c22e8570cfbea43fddbbff963d4bde': 18,
|
|
13
|
+
'0x2def6eb801757655ad227110d65c80db595bbc60': 8,
|
|
14
|
+
'0x6bb82009b316a9098c23e3962b4371e879c8d23d': 8,
|
|
15
|
+
'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
|
|
16
|
+
'0xcc5ca0156317c1ff2a96e0f45659625081352071': 8,
|
|
17
|
+
'0xe3520349f477a5f6eb06107066048508498a291b': 18,
|
|
18
|
+
'0x173bf18675d52b4887c5d40e935c3ab1192afb4c': 8
|
|
19
|
+
}
|