@aurigami/sdk 1.21.0 → 1.22.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/consts/constants.d.ts +1 -1
- package/dist/helpers/aurigami-api.d.ts +1 -1
- package/dist/sdk.cjs.development.js +21 -21
- 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 +21 -21
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +11 -13
- package/package.json +1 -1
- package/src/SDK.ts +18 -24
- package/src/consts/constants.ts +1 -1
- package/src/helpers/aurigami-api.ts +2 -2
- package/src/helpers/helpers.ts +2 -2
- package/src/types/index.ts +11 -14
- package/src/a.ts.log +0 -29
package/dist/types/index.d.ts
CHANGED
|
@@ -177,23 +177,21 @@ export declare type UserNotification = {
|
|
|
177
177
|
liquidation: boolean;
|
|
178
178
|
}[];
|
|
179
179
|
};
|
|
180
|
-
export declare type
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
underlyingSymbol: string;
|
|
180
|
+
export declare type LiquidationEventEntity = {
|
|
181
|
+
liquidator: string;
|
|
182
|
+
borrower: string;
|
|
183
|
+
/** bigint string */
|
|
184
|
+
repayAmount: string;
|
|
185
|
+
marketRepayToken: string;
|
|
186
|
+
/** bigint string */
|
|
187
|
+
seizeTokens: string;
|
|
188
|
+
auTokenCollateral: string;
|
|
189
|
+
txnHash: string;
|
|
190
|
+
blockNumber: number;
|
|
192
191
|
};
|
|
193
192
|
export declare type LiquidationDetail = {
|
|
194
193
|
liquidationTime: Timestamp;
|
|
195
194
|
tokenAmount: TokenAmount;
|
|
196
|
-
value: CurrencyAmount;
|
|
197
195
|
transactionId: string;
|
|
198
196
|
};
|
|
199
197
|
export declare type Timestamp = number;
|
package/package.json
CHANGED
package/src/SDK.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import {
|
|
4
|
-
ALL_STAKING_POOLS,
|
|
5
|
-
AURIGAMI_SUBGRAPH_URL,
|
|
6
|
-
SD_INCENTIVE_IN_SD,
|
|
7
|
-
networkAddresses,
|
|
8
|
-
} from './consts';
|
|
3
|
+
import { ALL_STAKING_POOLS, networkAddresses } from './consts';
|
|
9
4
|
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from './entities';
|
|
5
|
+
import { getBlocksTimestamp, getDecimal } from './helpers';
|
|
6
|
+
import * as AuriAPI from './helpers/aurigami-api';
|
|
7
|
+
import * as NotificationApi from './helpers/notification-api';
|
|
10
8
|
import { MiscRead, StakingRead, StakingReadWrite } from './interactors';
|
|
11
9
|
import * as types from './types';
|
|
12
|
-
import * as NotificationApi from './helpers/notification-api';
|
|
13
|
-
import { BigNumber as BN } from 'ethers';
|
|
14
|
-
import { getDecimal, queryGraphQL } from './helpers';
|
|
15
|
-
import { getLiquidationEventsQuery } from './helpers/subgraphQuery';
|
|
16
10
|
|
|
17
11
|
export class SdkRead extends BlockchainEntityRead {
|
|
18
12
|
protected env: AuriEnv;
|
|
@@ -158,26 +152,26 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
158
152
|
}
|
|
159
153
|
|
|
160
154
|
public async getLiquidationHistory(address: string): Promise<types.LiquidationDetail[]> {
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
155
|
+
const liquidationHistoryResp = await AuriAPI.getPaginatedApi<types.LiquidationEventEntity>(
|
|
156
|
+
'/liquidate/history',
|
|
157
|
+
{
|
|
158
|
+
user: address,
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
const blocks = liquidationHistoryResp.items.map((event) => event.blockNumber);
|
|
162
|
+
const blocksTimestamp = await getBlocksTimestamp(this._networkConnection.provider, blocks);
|
|
163
|
+
|
|
164
|
+
const liquidationEvents = liquidationHistoryResp.items.map((event, idx) => {
|
|
170
165
|
const underlyingAddress = networkAddresses.auTokens.find(
|
|
171
|
-
(auToken) => auToken.
|
|
166
|
+
(auToken) => auToken.address.toLowerCase() === event.marketRepayToken.toLowerCase()
|
|
172
167
|
)!.underlying;
|
|
173
168
|
const decimal = getDecimal(underlyingAddress);
|
|
174
169
|
const token = new Token(underlyingAddress, decimal);
|
|
175
|
-
const tokenAmount = new TokenAmount(token, event.
|
|
170
|
+
const tokenAmount = new TokenAmount(token, event.repayAmount.toString(), true);
|
|
176
171
|
return {
|
|
177
|
-
liquidationTime:
|
|
172
|
+
liquidationTime: blocksTimestamp[idx],
|
|
178
173
|
tokenAmount,
|
|
179
|
-
|
|
180
|
-
transactionId: event.id.split('-')[0],
|
|
174
|
+
transactionId: event.txnHash,
|
|
181
175
|
};
|
|
182
176
|
}) as types.LiquidationDetail[];
|
|
183
177
|
return liquidationEvents;
|
package/src/consts/constants.ts
CHANGED
|
@@ -195,4 +195,4 @@ export const USDT_ETH = '0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase
|
|
|
195
195
|
export const AURIGAMI_SUBGRAPH_URL =
|
|
196
196
|
'https://api.thegraph.com/subgraphs/name/takao-aurigami/aurigami-feb-27';
|
|
197
197
|
|
|
198
|
-
export const GRAPHQL_URL = 'https://explorer.
|
|
198
|
+
export const GRAPHQL_URL = 'https://old.explorer.aurora.dev/api/v1/graphql';
|
|
@@ -23,12 +23,12 @@ export type PaginagedApiResponse<T> = {
|
|
|
23
23
|
meta: MetaApiResponse;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export async function getPaginatedApi(
|
|
26
|
+
export async function getPaginatedApi<T = any>(
|
|
27
27
|
url: string,
|
|
28
28
|
params: Record<string, any> = {},
|
|
29
29
|
page: number = 1,
|
|
30
30
|
pageSize: number = 50
|
|
31
|
-
): Promise<PaginagedApiResponse<
|
|
31
|
+
): Promise<PaginagedApiResponse<T>> {
|
|
32
32
|
params = {
|
|
33
33
|
...params,
|
|
34
34
|
page,
|
package/src/helpers/helpers.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Provider } from '@ethersproject/abstract-provider';
|
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
4
|
import { BigNumber as BN, utils } from 'ethers';
|
|
5
5
|
import { Result } from 'ethers/lib/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { GRAPHQL_URL, networkAddresses } from '../consts/constants';
|
|
7
7
|
import { decimalRecords } from '../consts/decimals';
|
|
8
8
|
import { symbolRecords } from '../consts/symbols';
|
|
9
9
|
import { Address } from '../types';
|
|
@@ -135,7 +135,7 @@ export async function getBlocksTimestamp(
|
|
|
135
135
|
// merge all the json objects
|
|
136
136
|
let results = (await Promise.all(promises)).reduce((acc, cur) => {
|
|
137
137
|
return { ...acc, ...cur };
|
|
138
|
-
});
|
|
138
|
+
}, {});
|
|
139
139
|
|
|
140
140
|
let missingBlocks = blockNumbers.filter((blockNumber) => !results[`b${blockNumber}`]);
|
|
141
141
|
if (missingBlocks.length > 0) {
|
package/src/types/index.ts
CHANGED
|
@@ -200,25 +200,22 @@ export type UserNotification = {
|
|
|
200
200
|
}[];
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
export type
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
underlyingRepayAmountUSD: number;
|
|
215
|
-
underlyingSymbol: string;
|
|
203
|
+
export type LiquidationEventEntity = {
|
|
204
|
+
liquidator: string;
|
|
205
|
+
borrower: string;
|
|
206
|
+
/** bigint string */
|
|
207
|
+
repayAmount: string;
|
|
208
|
+
marketRepayToken: string;
|
|
209
|
+
/** bigint string */
|
|
210
|
+
seizeTokens: string;
|
|
211
|
+
auTokenCollateral: string;
|
|
212
|
+
txnHash: string;
|
|
213
|
+
blockNumber: number;
|
|
216
214
|
};
|
|
217
215
|
|
|
218
216
|
export type LiquidationDetail = {
|
|
219
217
|
liquidationTime: Timestamp;
|
|
220
218
|
tokenAmount: TokenAmount;
|
|
221
|
-
value: CurrencyAmount;
|
|
222
219
|
transactionId: string;
|
|
223
220
|
};
|
|
224
221
|
|
package/src/a.ts.log
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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();
|