@aurigami/sdk 1.12.0-beta5 → 1.12.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/abis/index.d.ts +2 -2
- package/dist/entities/auriEnv.d.ts +3 -3
- package/dist/sdk.cjs.development.js +18 -18
- 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 +18 -18
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/a.ts.log +29 -0
- package/src/abis/index.ts +2 -2
- package/src/consts/constants.ts +0 -1
- package/src/entities/auriEnv.ts +8 -8
- package/src/interactors/Referral.ts +8 -14
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.12.0
|
|
2
|
+
"version": "1.12.0",
|
|
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.12.0-beta-4",
|
|
66
66
|
"axios": "^0.26.1",
|
|
67
67
|
"bignumber.js": "^9.0.2",
|
|
68
68
|
"ethers": "^5.6.4"
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
"jest": {
|
|
71
71
|
"testURL": "https://app.aurigami.finance"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
package/src/a.ts.log
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuToken } from '@aurigami/contracts/typechain';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { AuriEnv, formatObject, getDecimal, MAINNET_ADDRESSES, networkAddresses, SDK, Token } from '../src';
|
|
4
|
+
import { ask } from 'stdio';
|
|
5
|
+
const AURORA_DEFAULT_PROVIDER_URL = `https://mainnet.aurora.dev/`;
|
|
6
|
+
|
|
7
|
+
const AURORA_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
|
|
8
|
+
AURORA_DEFAULT_PROVIDER_URL
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
async function foo(contract: AuToken, block: number) {
|
|
12
|
+
let data = await contract.callStatic.borrowBalanceCurrent('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
|
|
13
|
+
console.log("c", data.toString());
|
|
14
|
+
data = await contract.callStatic.borrowBalanceStored('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
|
|
15
|
+
console.log("s", data.toString());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
let env = new AuriEnv({ provider: AURORA_DEFAULT_PROVIDER });
|
|
20
|
+
let contract = env.getAuErc20Contract({address: MAINNET_ADDRESSES.auTokens.USDC});
|
|
21
|
+
// let block = 60596417;
|
|
22
|
+
// while (true) {
|
|
23
|
+
// block = parseInt(eval(await ask('block')));
|
|
24
|
+
// if (block == 0) break;
|
|
25
|
+
// await foo(contract, block);
|
|
26
|
+
// }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main();
|
package/src/abis/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import AuriInternalLensABI from '@aurigami/contracts/artifacts/contracts/mock/Au
|
|
|
13
13
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
14
14
|
import Multicall2ABI from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
15
15
|
import PulpABI from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
16
|
-
import
|
|
16
|
+
import ReferralDirectoryABI from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
|
|
17
17
|
import PlyGameABI from '@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json';
|
|
18
18
|
export {
|
|
19
19
|
AuriOracleABI,
|
|
@@ -25,7 +25,7 @@ export {
|
|
|
25
25
|
ComptrollerABI,
|
|
26
26
|
// FaucetABI,
|
|
27
27
|
EIP20InterfaceABI,
|
|
28
|
-
|
|
28
|
+
ReferralDirectoryABI,
|
|
29
29
|
AuErc20ABI,
|
|
30
30
|
AuETHABI,
|
|
31
31
|
EthRepayHelperABI,
|
package/src/consts/constants.ts
CHANGED
|
@@ -91,7 +91,6 @@ export const networkAddresses: NetworkAddresses = {
|
|
|
91
91
|
PULP_CONTRACT: '0x04ac48711bcdc45b4d223fb021e09da73c71095e'.toLowerCase(),
|
|
92
92
|
PLY_TOKEN_LOCK: MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
|
|
93
93
|
REFERRAL: MAINNET_ADDRESSES.referralDirectory.toLowerCase(),
|
|
94
|
-
REFERRAL_V2: '0xCECd147409B2d64A9A2E5418e3E471E8af19E0bd'.toLowerCase(),
|
|
95
94
|
AURI_INTERNAL_LENS: MAINNET_ADDRESSES.auriInternalLens.toLowerCase(),
|
|
96
95
|
PLYGAME: MAINNET_ADDRESSES.plyGame.toLowerCase(),
|
|
97
96
|
},
|
package/src/entities/auriEnv.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
IERC20,
|
|
10
10
|
PlyGame,
|
|
11
11
|
PULP,
|
|
12
|
-
|
|
12
|
+
ReferralDirectory,
|
|
13
13
|
} from '@aurigami/contracts/typechain';
|
|
14
14
|
import { Contract } from 'ethers';
|
|
15
15
|
import { assert } from '../helpers/helpers';
|
|
@@ -26,7 +26,7 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
26
26
|
private _pulp: PULP | null = null;
|
|
27
27
|
private _auriInternalLens: AuriInternalLens | null = null;
|
|
28
28
|
private _auriAirdrop: AuriAirdrop | null = null;
|
|
29
|
-
private
|
|
29
|
+
private _referralDirectory: ReferralDirectory | null = null;
|
|
30
30
|
private _oracle: AuriOracle | null = null;
|
|
31
31
|
private _plygame: PlyGame | null = null;
|
|
32
32
|
|
|
@@ -137,14 +137,14 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
137
137
|
return this._auriAirdrop;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
get
|
|
141
|
-
if (!this.
|
|
142
|
-
this.
|
|
143
|
-
networkAddresses.misc.
|
|
144
|
-
abis.
|
|
140
|
+
get referralDirectory(): ReferralDirectory {
|
|
141
|
+
if (!this._referralDirectory) {
|
|
142
|
+
this._referralDirectory = this.getContract<ReferralDirectory>(
|
|
143
|
+
networkAddresses.misc.REFERRAL,
|
|
144
|
+
abis.ReferralDirectoryABI.abi
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
|
-
return this.
|
|
147
|
+
return this._referralDirectory;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
get oracle(): AuriOracle {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
-
import {
|
|
5
|
-
AURORA_PLUS_API_PREFIX,
|
|
6
|
-
referralRewardDummy1,
|
|
7
|
-
referralRewardDummy2,
|
|
8
|
-
REFERRAL_CAMPAIGNS,
|
|
9
|
-
} from '../consts';
|
|
4
|
+
import { AURORA_PLUS_API_PREFIX, REFERRAL_CAMPAIGNS } from '../consts';
|
|
10
5
|
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, TokenAmount } from '../entities';
|
|
11
6
|
import { getBlocksTimestamp } from '../helpers';
|
|
12
7
|
import * as AuriAPI from '../helpers/aurigami-api';
|
|
@@ -39,7 +34,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
39
34
|
* Called to check if a user has a referral code.
|
|
40
35
|
*/
|
|
41
36
|
public async getUserReferralCode(userAddr: Address): Promise<string> {
|
|
42
|
-
const result = await this.env.
|
|
37
|
+
const result = await this.env.referralDirectory.userReferralCode(userAddr);
|
|
43
38
|
return ethers.utils.parseBytes32String(result);
|
|
44
39
|
}
|
|
45
40
|
|
|
@@ -47,7 +42,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
47
42
|
* Get referral code that a user was referred by, returns empty string if not found.
|
|
48
43
|
*/
|
|
49
44
|
public async getReferralCodeUsed(userAddr: Address): Promise<string> {
|
|
50
|
-
const result = await this.env.
|
|
45
|
+
const result = await this.env.referralDirectory.referralCodeUsed(userAddr);
|
|
51
46
|
return ethers.utils.parseBytes32String(result);
|
|
52
47
|
}
|
|
53
48
|
|
|
@@ -56,7 +51,7 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
56
51
|
*/
|
|
57
52
|
public async getReferralCodeOwner(code: string): Promise<Address> {
|
|
58
53
|
const referralCode = ethers.utils.formatBytes32String(code);
|
|
59
|
-
return this.env.
|
|
54
|
+
return this.env.referralDirectory.referralCodeOwner(referralCode);
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
/**
|
|
@@ -89,7 +84,6 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
89
84
|
refereeAddress: null,
|
|
90
85
|
}));
|
|
91
86
|
|
|
92
|
-
items = [referralRewardDummy1, referralRewardDummy2, ...items];
|
|
93
87
|
return items;
|
|
94
88
|
}
|
|
95
89
|
|
|
@@ -144,8 +138,8 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
144
138
|
}
|
|
145
139
|
|
|
146
140
|
public async isWhitelistedAddress(address: Address): Promise<boolean> {
|
|
147
|
-
let result = await
|
|
148
|
-
return result.
|
|
141
|
+
let result = await AuriAPI.getApi('/referral/whitelisted', { address: address });
|
|
142
|
+
return result.isWhitelisted;
|
|
149
143
|
}
|
|
150
144
|
|
|
151
145
|
public async isOnAuroraPlus(address: Address): Promise<boolean> {
|
|
@@ -173,7 +167,7 @@ export class ReferralReadWrite extends ReferralRead {
|
|
|
173
167
|
*/
|
|
174
168
|
public async registerNewReferralCode(): Promise<TransactionResponse> {
|
|
175
169
|
const referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
176
|
-
return this.env.
|
|
170
|
+
return this.env.referralDirectory
|
|
177
171
|
.connect(this._networkConnection.signer!)
|
|
178
172
|
.registerNewUserReferralCode(referralCode);
|
|
179
173
|
}
|
|
@@ -183,7 +177,7 @@ export class ReferralReadWrite extends ReferralRead {
|
|
|
183
177
|
*/
|
|
184
178
|
public async useReferralCode(code: string): Promise<TransactionResponse> {
|
|
185
179
|
const referralCode = ethers.utils.formatBytes32String(code);
|
|
186
|
-
return this.env.
|
|
180
|
+
return this.env.referralDirectory
|
|
187
181
|
.connect(this._networkConnection.signer!)
|
|
188
182
|
.registerReferralCodeUsed(referralCode);
|
|
189
183
|
}
|