@aurigami/sdk 1.23.0 → 1.24.0
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 +48 -65
- package/dist/SDK.js +165 -0
- package/dist/abis/index.d.ts +18 -18
- package/dist/abis/index.js +39 -0
- package/dist/consts/constants.d.ts +139 -139
- package/dist/consts/constants.js +185 -0
- package/dist/consts/decimals.d.ts +1 -1
- package/dist/consts/decimals.js +35 -0
- package/dist/consts/deployments.d.ts +3 -3
- package/dist/consts/deployments.js +9 -0
- package/dist/consts/dummy.d.ts +13 -13
- package/dist/consts/dummy.js +43 -0
- package/dist/consts/index.d.ts +5 -5
- package/dist/consts/index.js +9 -0
- package/dist/consts/symbols.d.ts +1 -1
- package/dist/consts/symbols.js +10 -0
- package/dist/entities/BlockchainEntity.d.ts +13 -13
- package/dist/entities/BlockchainEntity.js +36 -0
- package/dist/entities/auriEnv.d.ts +34 -40
- package/dist/entities/auriEnv.js +166 -0
- package/dist/entities/index.d.ts +4 -4
- package/dist/entities/index.js +8 -0
- package/dist/entities/token.d.ts +7 -7
- package/dist/entities/token.js +27 -0
- package/dist/entities/tokenAmount.d.ts +13 -13
- package/dist/entities/tokenAmount.js +52 -0
- package/dist/helpers/aurigami-api.d.ts +13 -13
- package/dist/helpers/aurigami-api.js +26 -0
- package/dist/helpers/aurora-api-helpers.d.ts +1 -1
- package/dist/helpers/aurora-api-helpers.js +15 -0
- package/dist/helpers/graphql-helpers.d.ts +1 -1
- package/dist/helpers/graphql-helpers.js +13 -0
- package/dist/helpers/helpers.d.ts +23 -40
- package/dist/helpers/helpers.js +148 -0
- package/dist/helpers/historicalPriceFetcher.d.ts +15 -15
- package/dist/helpers/historicalPriceFetcher.js +142 -0
- package/dist/helpers/index.d.ts +7 -7
- package/dist/helpers/index.js +11 -0
- package/dist/helpers/kyber-aggregator-api.d.ts +5 -5
- package/dist/helpers/kyber-aggregator-api.js +27 -0
- package/dist/helpers/multicall.d.ts +40 -0
- package/dist/helpers/multicall.js +203 -0
- package/dist/helpers/notification-api.d.ts +2 -2
- package/dist/helpers/notification-api.js +21 -0
- package/dist/helpers/one-inch-aggregator-api.d.ts +21 -21
- package/dist/helpers/one-inch-aggregator-api.js +19 -0
- package/dist/helpers/priceFetcher.d.ts +36 -36
- package/dist/helpers/priceFetcher.js +296 -0
- package/dist/helpers/subgraphQuery.d.ts +1 -1
- package/dist/helpers/subgraphQuery.js +22 -0
- package/dist/helpers/transfer-event-query.d.ts +17 -26
- package/dist/helpers/transfer-event-query.js +41 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -8
- package/dist/interactors/Airdrop.d.ts +17 -26
- package/dist/interactors/Airdrop.js +48 -0
- package/dist/interactors/MoneyMarket.d.ts +63 -63
- package/dist/interactors/MoneyMarket.js +392 -0
- package/dist/interactors/Multicall.d.ts +15 -18
- package/dist/interactors/Multicall.js +36 -0
- package/dist/interactors/Papermill.d.ts +27 -57
- package/dist/interactors/Papermill.js +125 -0
- package/dist/interactors/PlyGame.d.ts +30 -42
- package/dist/interactors/PlyGame.js +146 -0
- package/dist/interactors/PlyTokenLock.d.ts +16 -16
- package/dist/interactors/PlyTokenLock.js +44 -0
- package/dist/interactors/Pulp.d.ts +17 -17
- package/dist/interactors/Pulp.js +43 -0
- package/dist/interactors/Referral.d.ts +35 -78
- package/dist/interactors/Referral.js +158 -0
- package/dist/interactors/Staking.d.ts +20 -26
- package/dist/interactors/Staking.js +106 -0
- package/dist/interactors/index.d.ts +9 -9
- package/dist/interactors/index.js +13 -0
- package/dist/interactors/misc.d.ts +31 -39
- package/dist/interactors/misc.js +318 -0
- package/dist/types/index.d.ts +175 -197
- package/dist/types/index.js +18 -0
- package/package.json +3 -3
- package/src/SDK.ts +1 -1
- package/src/entities/auriEnv.ts +29 -27
- package/src/helpers/historicalPriceFetcher.ts +9 -12
- package/src/helpers/multicall.ts +251 -0
- package/src/helpers/priceFetcher.ts +19 -21
- package/src/interactors/Airdrop.ts +2 -2
- package/src/interactors/MoneyMarket.ts +31 -27
- package/src/interactors/Multicall.ts +3 -3
- package/src/interactors/Papermill.ts +9 -9
- package/src/interactors/PlyGame.ts +10 -10
- package/src/interactors/PlyTokenLock.ts +2 -3
- package/src/interactors/Pulp.ts +4 -2
- package/src/interactors/Referral.ts +6 -6
- package/src/interactors/Staking.ts +13 -9
- package/src/interactors/misc.ts +7 -5
- package/src/types/index.ts +32 -2
- package/dist/sdk.cjs.development.js +0 -6325
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -6193
- package/dist/sdk.esm.js.map +0 -1
|
@@ -56,14 +56,14 @@ export class PlyGameRead extends BlockchainEntityRead {
|
|
|
56
56
|
* Get 100 most recent bets of the market users
|
|
57
57
|
*/
|
|
58
58
|
public async getUserPlyGameHistory(user: Address): Promise<PlyGameBetResult[]> {
|
|
59
|
-
let block100 = await this.env.plygame.getLastBlock(user, 100);
|
|
59
|
+
let block100 = await this.env.plygame.callStatic.getLastBlock(user, 100);
|
|
60
60
|
|
|
61
61
|
if (block100.eq(0)) {
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
let filter = this.env.plygame.filters.BetMade(user);
|
|
66
|
-
let events = await this.env.plygame.queryFilter(filter, block100.toNumber());
|
|
65
|
+
let filter = this.env.plygame.raw.filters.BetMade(user);
|
|
66
|
+
let events = await this.env.plygame.raw.queryFilter(filter, block100.toNumber());
|
|
67
67
|
// Sort descending by block number
|
|
68
68
|
sortEvents(events).reverse();
|
|
69
69
|
return this.attachTimestamp(events.map((event) => this.parseBetMakeEvent(event)));
|
|
@@ -73,12 +73,12 @@ export class PlyGameRead extends BlockchainEntityRead {
|
|
|
73
73
|
* Get current jackpot amount
|
|
74
74
|
*/
|
|
75
75
|
public async currentJackpotAmount(): Promise<TokenAmount> {
|
|
76
|
-
let jackpot = await this.env.plygame.currentJackpotAmount();
|
|
76
|
+
let jackpot = await this.env.plygame.callStatic.currentJackpotAmount();
|
|
77
77
|
return new TokenAmount(this.plyToken, jackpot.toString());
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
public async earlyUnlockedPulpAmount(user: Address): Promise<TokenAmount> {
|
|
81
|
-
let earlyUnlockedPulpAmount = await this.env.plygame.totalPlyUnlockedEarly(user);
|
|
81
|
+
let earlyUnlockedPulpAmount = await this.env.plygame.callStatic.totalPlyUnlockedEarly(user);
|
|
82
82
|
return new TokenAmount(this.pulpToken, earlyUnlockedPulpAmount.toString());
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -96,11 +96,11 @@ export class PlyGameRead extends BlockchainEntityRead {
|
|
|
96
96
|
throw new Error(`Transaction ${txHash} takes too long to be mined`);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
let filter = this.env.plygame.filters.BetMade();
|
|
99
|
+
let filter = this.env.plygame.raw.filters.BetMade();
|
|
100
100
|
let betMadeEvents: PlyBetMadeEvent[] = tx.logs
|
|
101
101
|
.filter((log) => isSameAddress(log.topics[0], filter.topics![0] as string))
|
|
102
102
|
.map((log) => ({
|
|
103
|
-
...this.env.plygame.interface.parseLog(log),
|
|
103
|
+
...this.env.plygame.raw.interface.parseLog(log),
|
|
104
104
|
blockNumber: tx.blockNumber,
|
|
105
105
|
transactionHash: txHash,
|
|
106
106
|
})) as unknown as PlyBetMadeEvent[];
|
|
@@ -125,7 +125,7 @@ export class PlyGameRead extends BlockchainEntityRead {
|
|
|
125
125
|
let round = BN.from(
|
|
126
126
|
await this._networkConnection.provider.getStorageAt(this.env.plygame.address, 158)
|
|
127
127
|
);
|
|
128
|
-
let result = await this.env.plygame.jackpotHistory(round.sub(1));
|
|
128
|
+
let result = await this.env.plygame.callStatic.jackpotHistory(round.sub(1));
|
|
129
129
|
return {
|
|
130
130
|
winner: result.winner.slice(0, 5) + '...' + result.winner.slice(-3),
|
|
131
131
|
amount: new TokenAmount(this.plyToken, result.amount.toString()),
|
|
@@ -147,13 +147,13 @@ export class PlyGameReadWrite extends PlyGameRead {
|
|
|
147
147
|
* Make a single bet
|
|
148
148
|
*/
|
|
149
149
|
public async makeBetOnce(amount: TokenAmount): Promise<TransactionResponse> {
|
|
150
|
-
return this.env.plygame
|
|
150
|
+
return this.env.plygame.raw
|
|
151
151
|
.connect(this._networkConnection.signer!)
|
|
152
152
|
.makeBetOnce(amount.rawAmount());
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
public async approve(amount: TokenAmount): Promise<TransactionResponse> {
|
|
156
|
-
return this.env.ply
|
|
156
|
+
return this.env.ply.raw
|
|
157
157
|
.connect(this._networkConnection.signer!)
|
|
158
158
|
.approve(this.env.plygame.address, amount.rawAmount());
|
|
159
159
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
|
-
import { BigNumber as BN
|
|
2
|
+
import { BigNumber as BN } from 'ethers';
|
|
3
3
|
import {
|
|
4
4
|
AuriEnv,
|
|
5
5
|
BlockchainEntity,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Token,
|
|
9
9
|
TokenAmount,
|
|
10
10
|
} from '../entities';
|
|
11
|
-
import * as helpers from '../helpers';
|
|
12
11
|
import { Address, NetworkConnection } from '../types';
|
|
13
12
|
|
|
14
13
|
export class PlyTokenLockRead extends BlockchainEntityRead {
|
|
@@ -28,7 +27,7 @@ export class PlyTokenLockRead extends BlockchainEntityRead {
|
|
|
28
27
|
export class PlyTokenLockReadWrite extends PlyTokenLockRead {
|
|
29
28
|
public async claim(recipient: Address, amount: TokenAmount): Promise<TransactionResponse> {
|
|
30
29
|
const amountToClaim = BN.from(amount.rawAmount());
|
|
31
|
-
return await this.env.plyTokenLock
|
|
30
|
+
return await this.env.plyTokenLock.raw
|
|
32
31
|
.connect(this._networkConnection.signer!)
|
|
33
32
|
.claim(recipient, amountToClaim);
|
|
34
33
|
}
|
package/src/interactors/Pulp.ts
CHANGED
|
@@ -12,7 +12,7 @@ export class PulpRead extends BlockchainEntityRead {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
public async remainingEarlyUnlockPulp(user: Address): Promise<BN> {
|
|
15
|
-
return this.env.pulp.earlyRedeems(user);
|
|
15
|
+
return this.env.pulp.callStatic.earlyRedeems(user);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -22,7 +22,9 @@ export class PulpReadWrite extends PulpRead {
|
|
|
22
22
|
amount: TokenAmount
|
|
23
23
|
): Promise<TransactionResponse> {
|
|
24
24
|
const amountToRedeem = BN.from(amount.rawAmount());
|
|
25
|
-
return this.env.pulp.
|
|
25
|
+
return this.env.pulp.raw
|
|
26
|
+
.connect(this._networkConnection.signer!)
|
|
27
|
+
.redeem(recipient, amountToRedeem);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -34,7 +34,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
34
34
|
* Called to check if a user has a referral code.
|
|
35
35
|
*/
|
|
36
36
|
public async getUserReferralCode(userAddr: Address): Promise<string> {
|
|
37
|
-
const result = await this.env.referralDirectoryV2.userReferralCode(userAddr);
|
|
37
|
+
const result = await this.env.referralDirectoryV2.raw.userReferralCode(userAddr);
|
|
38
38
|
return ethers.utils.parseBytes32String(result);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
42
42
|
* Get referral code that a user was referred by, returns empty string if not found.
|
|
43
43
|
*/
|
|
44
44
|
public async getReferralCodeUsed(userAddr: Address): Promise<string> {
|
|
45
|
-
const result = await this.env.referralDirectoryV2.referralCodeUsed(userAddr);
|
|
45
|
+
const result = await this.env.referralDirectoryV2.raw.referralCodeUsed(userAddr);
|
|
46
46
|
return ethers.utils.parseBytes32String(result);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
51
51
|
*/
|
|
52
52
|
public async getReferralCodeOwner(code: string): Promise<Address> {
|
|
53
53
|
const referralCode = ethers.utils.formatBytes32String(code);
|
|
54
|
-
return this.env.referralDirectoryV2.referralCodeOwner(referralCode);
|
|
54
|
+
return this.env.referralDirectoryV2.raw.referralCodeOwner(referralCode);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -143,7 +143,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
public async isWhitelistedAddress(address: Address): Promise<boolean> {
|
|
146
|
-
let result = await this.env.referralDirectoryV2.isUserWhitelisted(address);
|
|
146
|
+
let result = await this.env.referralDirectoryV2.raw.isUserWhitelisted(address);
|
|
147
147
|
return result.eq(1);
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -172,7 +172,7 @@ export class ReferralReadWrite extends ReferralRead {
|
|
|
172
172
|
*/
|
|
173
173
|
public async registerNewReferralCode(): Promise<TransactionResponse> {
|
|
174
174
|
const referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
175
|
-
return this.env.referralDirectoryV2
|
|
175
|
+
return this.env.referralDirectoryV2.raw
|
|
176
176
|
.connect(this._networkConnection.signer!)
|
|
177
177
|
.registerNewUserReferralCode(referralCode);
|
|
178
178
|
}
|
|
@@ -182,7 +182,7 @@ export class ReferralReadWrite extends ReferralRead {
|
|
|
182
182
|
*/
|
|
183
183
|
public async useReferralCode(code: string): Promise<TransactionResponse> {
|
|
184
184
|
const referralCode = ethers.utils.formatBytes32String(code);
|
|
185
|
-
return this.env.referralDirectoryV2
|
|
185
|
+
return this.env.referralDirectoryV2.raw
|
|
186
186
|
.connect(this._networkConnection.signer!)
|
|
187
187
|
.registerReferralCodeUsed(referralCode);
|
|
188
188
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IERC20 } from '@aurigami/contracts/typechain';
|
|
2
2
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { BigNumber as BN
|
|
4
|
+
import { BigNumber as BN } from 'ethers';
|
|
5
5
|
import { EIP20InterfaceABI } from '../abis';
|
|
6
6
|
import * as consts from '../consts';
|
|
7
7
|
import {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
TokenAmount,
|
|
14
14
|
} from '../entities';
|
|
15
15
|
import { calcLMRewardApr, getDecimal } from '../helpers';
|
|
16
|
+
import { createContract } from '../helpers/multicall';
|
|
16
17
|
import { fetchValuation } from '../helpers/priceFetcher';
|
|
17
18
|
import { NetworkConnection, PLYWNEARPoolDetails, TokenAPY } from '../types';
|
|
18
19
|
|
|
@@ -24,7 +25,7 @@ export class StakingRead extends BlockchainEntityRead {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
public async getPLYWNEARPoolDetails(): Promise<PLYWNEARPoolDetails> {
|
|
27
|
-
const { stakedLiquidity, rewardPerSeconds } = await this.env.auriFairLaunch
|
|
28
|
+
const { stakedLiquidity, rewardPerSeconds } = await this.env.auriFairLaunch.callStatic
|
|
28
29
|
.getPoolInfo(consts.PLYWNEAR_POOL_ID)
|
|
29
30
|
.then((res) => {
|
|
30
31
|
const endedTime = res.endTime;
|
|
@@ -87,7 +88,10 @@ export class StakingRead extends BlockchainEntityRead {
|
|
|
87
88
|
* Get amount of staked LP tokens
|
|
88
89
|
*/
|
|
89
90
|
public async stakeBalanceOf(user: string): Promise<TokenAmount> {
|
|
90
|
-
const userInfo = await this.env.auriFairLaunch.getUserInfo(
|
|
91
|
+
const userInfo = await this.env.auriFairLaunch.callStatic.getUserInfo(
|
|
92
|
+
consts.PLYWNEAR_POOL_ID,
|
|
93
|
+
user
|
|
94
|
+
);
|
|
91
95
|
return new TokenAmount(PLYWNEARToken, userInfo.amount.toString());
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -95,18 +99,18 @@ export class StakingRead extends BlockchainEntityRead {
|
|
|
95
99
|
* Get amount of LP token in user wallet
|
|
96
100
|
*/
|
|
97
101
|
public async LpBalanceOf(user: string): Promise<TokenAmount> {
|
|
98
|
-
let lpContract =
|
|
102
|
+
let lpContract = createContract<IERC20>(
|
|
99
103
|
consts.networkAddresses.tokens.PLYWNEAR,
|
|
100
104
|
EIP20InterfaceABI.abi,
|
|
101
105
|
this._networkConnection.provider
|
|
102
|
-
)
|
|
103
|
-
let balance = await lpContract.balanceOf(user);
|
|
106
|
+
);
|
|
107
|
+
let balance = await lpContract.callStatic.balanceOf(user);
|
|
104
108
|
|
|
105
109
|
return new TokenAmount(PLYWNEARToken, balance.toString());
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
public async unclaimedRewardsOf(user: string): Promise<TokenAmount[]> {
|
|
109
|
-
let userInfo = await this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(
|
|
113
|
+
let userInfo = await this.env.auriFairLaunch.raw.callStatic.updateAndGetUserInfo(
|
|
110
114
|
consts.PLYWNEAR_POOL_ID,
|
|
111
115
|
user,
|
|
112
116
|
{ from: user }
|
|
@@ -121,7 +125,7 @@ export class StakingRead extends BlockchainEntityRead {
|
|
|
121
125
|
|
|
122
126
|
export class StakingReadWrite extends StakingRead {
|
|
123
127
|
public async stake(amount: TokenAmount): Promise<TransactionResponse> {
|
|
124
|
-
return this.env.auriFairLaunch
|
|
128
|
+
return this.env.auriFairLaunch.raw
|
|
125
129
|
.connect(this._networkConnection.signer!)
|
|
126
130
|
.deposit(consts.PLYWNEAR_POOL_ID, amount.rawAmount());
|
|
127
131
|
}
|
|
@@ -132,7 +136,7 @@ export class StakingReadWrite extends StakingRead {
|
|
|
132
136
|
const stakedAmount = BN.from((await this.stakeBalanceOf(msgSender)).rawAmount());
|
|
133
137
|
// unstakeAmount = min(amountInput, stakedAmount - 1)
|
|
134
138
|
const unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
135
|
-
return this.env.auriFairLaunch
|
|
139
|
+
return this.env.auriFairLaunch.raw
|
|
136
140
|
.connect(this._networkConnection.signer!)
|
|
137
141
|
.withdraw(consts.PLYWNEAR_POOL_ID, unstakeAmount);
|
|
138
142
|
}
|
package/src/interactors/misc.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
47
47
|
userMarketDetail.underlyingPrice = underlyingPrice.toString();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
assetsIn = await this.env.comptroller.getAssetsIn(userAddress);
|
|
50
|
+
assetsIn = await this.env.comptroller.raw.getAssetsIn(userAddress);
|
|
51
51
|
|
|
52
52
|
var depositValues = [];
|
|
53
53
|
for (var i = 0; i < marketCount; i++) {
|
|
@@ -74,7 +74,9 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
74
74
|
return p;
|
|
75
75
|
}, new BigNumber(0));
|
|
76
76
|
|
|
77
|
-
var accountLiquidity: [BN, BN] = await this.env.comptroller.getAccountLiquidity(
|
|
77
|
+
var accountLiquidity: [BN, BN] = await this.env.comptroller.raw.getAccountLiquidity(
|
|
78
|
+
userAddress
|
|
79
|
+
);
|
|
78
80
|
|
|
79
81
|
var borrowedvaluation: BigNumber = totalBorrowLimit.minus(
|
|
80
82
|
new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18))
|
|
@@ -294,7 +296,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
294
296
|
const tokens = tokenAddresses.map((addr) =>
|
|
295
297
|
this.env.getContract<AuToken>(addr, abis.AuTokenABI.abi)
|
|
296
298
|
);
|
|
297
|
-
const prices = await oracle.getUnderlyingPrices(tokenAddresses);
|
|
299
|
+
const prices = await oracle.callStatic.getUnderlyingPrices(tokenAddresses);
|
|
298
300
|
const exrate = await this.env.auriInternalLens.callStatic.getExchangeRates(tokenAddresses);
|
|
299
301
|
|
|
300
302
|
const res: types.AccountAuTokensInfo[] = [];
|
|
@@ -302,7 +304,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
302
304
|
for (let addr of accounts) {
|
|
303
305
|
const infos: types.AccountAuTokenInfo[] = [];
|
|
304
306
|
for (let i = 0; i < tokens.length; ++i) {
|
|
305
|
-
const snapshot = await tokens[i].getAccountSnapshot(addr);
|
|
307
|
+
const snapshot = await tokens[i].callStatic.getAccountSnapshot(addr);
|
|
306
308
|
const bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
|
|
307
309
|
const bor = snapshot[1].mul(prices[i]).div(_1E18);
|
|
308
310
|
|
|
@@ -329,7 +331,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
329
331
|
let totalSuppliedValue = new BigNumber(0);
|
|
330
332
|
let totalBorrowedValue = new BigNumber(0);
|
|
331
333
|
let collateralValue = new BigNumber(0);
|
|
332
|
-
const assetsIn = await this.env.comptroller.getAssetsIn(userAddr);
|
|
334
|
+
const assetsIn = await this.env.comptroller.callStatic.getAssetsIn(userAddr);
|
|
333
335
|
const marketValues = await Promise.all(
|
|
334
336
|
consts.networkAddresses.auTokens.map(async (auToken) => {
|
|
335
337
|
const moneyMarket: MoneyMarketRead = new MoneyMarketRead(
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AuToken } from '@aurigami/contracts/typechain';
|
|
2
2
|
import { TypedEvent } from '@aurigami/contracts/typechain/common';
|
|
3
|
+
import type { BlockTag } from '@ethersproject/abstract-provider';
|
|
3
4
|
import BigNumber from 'bignumber.js';
|
|
4
|
-
import type { providers, Signer } from 'ethers';
|
|
5
|
+
import type { Contract, providers, Signer } from 'ethers';
|
|
5
6
|
import { BigNumber as BN } from 'ethers';
|
|
6
7
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
7
8
|
|
|
@@ -95,6 +96,35 @@ export type PLYWNEARPoolDetails = {
|
|
|
95
96
|
APYs: TokenAPY[];
|
|
96
97
|
};
|
|
97
98
|
|
|
99
|
+
export type MulticallOverrides = {
|
|
100
|
+
blockTag?: BlockTag | Promise<BlockTag>;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
type ConcatTuple<A extends any[], B extends any[]> = [...A, ...B];
|
|
104
|
+
|
|
105
|
+
type RemoveLastOptionalParam<Fn extends (...params: any[]) => any> = Fn extends (
|
|
106
|
+
...params: [...infer Head, any?]
|
|
107
|
+
) => infer R
|
|
108
|
+
? (...params: Head) => R
|
|
109
|
+
: Fn;
|
|
110
|
+
|
|
111
|
+
type AddParams<Fn extends (...params: any[]) => any, P extends any[]> = Fn extends (
|
|
112
|
+
...params: infer Params
|
|
113
|
+
) => infer R
|
|
114
|
+
? (...params: ConcatTuple<Params, P>) => R
|
|
115
|
+
: Fn;
|
|
116
|
+
|
|
117
|
+
export type MulticallStatic<T extends Contract> = {
|
|
118
|
+
callStatic: {
|
|
119
|
+
[P in keyof T['callStatic']]: AddParams<
|
|
120
|
+
RemoveLastOptionalParam<T['callStatic'][P]>,
|
|
121
|
+
[multicallOverrides?: MulticallOverrides]
|
|
122
|
+
>;
|
|
123
|
+
};
|
|
124
|
+
address: string;
|
|
125
|
+
raw: T;
|
|
126
|
+
};
|
|
127
|
+
|
|
98
128
|
export enum MarketAction {
|
|
99
129
|
Deposit = 0,
|
|
100
130
|
Borrow,
|
|
@@ -120,7 +150,7 @@ export type AccountAuTokensInfo = {
|
|
|
120
150
|
tokens: AccountAuTokenInfo[];
|
|
121
151
|
};
|
|
122
152
|
|
|
123
|
-
export type AuTokenWithUnderlying = AuToken & {
|
|
153
|
+
export type AuTokenWithUnderlying = MulticallStatic<AuToken> & {
|
|
124
154
|
underlying: string;
|
|
125
155
|
};
|
|
126
156
|
|