@aurigami/sdk 0.1.3 → 0.1.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.
@@ -1,24 +1,24 @@
1
1
  import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
2
2
  import { ProviderOrSigner, MoneyMarketDetails } from './types';
3
- import { Address, CurrencyAmount } from '@pendle/sdk-core';
4
3
  import { Contract } from 'ethers';
5
4
  import { TransactionResponse } from '@ethersproject/abstract-provider';
5
+ import { TokenAmount } from './tokenAmount';
6
6
  export declare class MoneyMarketRead extends BlockchainEntityRead {
7
7
  protected _auToken: Contract;
8
- constructor(providerOrSigner: ProviderOrSigner, auToken: Address);
8
+ constructor(providerOrSigner: ProviderOrSigner, auToken: string);
9
9
  getDetails(): Promise<MoneyMarketDetails>;
10
10
  }
11
11
  export declare class MoneyMarketReadWrite extends MoneyMarketRead {
12
12
  dummyTransaction: () => Promise<TransactionResponse>;
13
- deposit(amount: CurrencyAmount): Promise<TransactionResponse>;
14
- borrow(amount: CurrencyAmount): Promise<TransactionResponse>;
15
- withdraw(amount: CurrencyAmount): Promise<TransactionResponse>;
16
- repay(amount: CurrencyAmount): Promise<TransactionResponse>;
13
+ deposit(amount: TokenAmount): Promise<TransactionResponse>;
14
+ borrow(amount: TokenAmount): Promise<TransactionResponse>;
15
+ withdraw(amount: TokenAmount): Promise<TransactionResponse>;
16
+ repay(amount: TokenAmount): Promise<TransactionResponse>;
17
17
  enableCollateral(): Promise<TransactionResponse>;
18
18
  disableCollateral(): Promise<TransactionResponse>;
19
19
  }
20
20
  export declare class MoneyMarket extends BlockchainEntity {
21
- protected address: Address;
21
+ protected address: string;
22
22
  constructor(address: string);
23
23
  read(provider: ProviderOrSigner): MoneyMarketRead;
24
24
  }
package/dist/SDK.d.ts CHANGED
@@ -1,20 +1,21 @@
1
1
  import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
2
2
  import { LockingDetails, PlyAuroraPoolDetails, ProviderOrSigner, UserDetails } from './types';
3
- import { Token, CurrencyAmount } from '@pendle/sdk-core';
4
3
  import { TransactionResponse } from '@ethersproject/abstract-provider';
4
+ import { TokenAmount } from './tokenAmount';
5
+ import { Token } from './token';
5
6
  export declare class SdkRead extends BlockchainEntityRead {
6
7
  constructor(providerOrSigner: ProviderOrSigner);
7
8
  getLockingDetails(): Promise<LockingDetails>;
8
9
  getUserDetails(userAddress: string): Promise<UserDetails>;
9
10
  getPlyAuroraPoolDetails(): Promise<PlyAuroraPoolDetails>;
10
- getTokenPrice(token: Token): Promise<CurrencyAmount>;
11
- stakeBalanceOf(user: string): Promise<CurrencyAmount>;
11
+ getTokenPrice(token: Token): Promise<TokenAmount>;
12
+ stakeBalanceOf(user: string): Promise<TokenAmount>;
12
13
  }
13
14
  export declare class SdkReadWrite extends SdkRead {
14
15
  dummyTransaction: () => Promise<TransactionResponse>;
15
16
  claim(): Promise<TransactionResponse>;
16
- stake(amount: CurrencyAmount): Promise<TransactionResponse>;
17
- unstake(amount: CurrencyAmount): Promise<TransactionResponse>;
17
+ stake(amount: TokenAmount): Promise<TransactionResponse>;
18
+ unstake(amount: TokenAmount): Promise<TransactionResponse>;
18
19
  }
19
20
  export declare class SDK extends BlockchainEntity {
20
21
  constructor();
@@ -1,4 +1,4 @@
1
- import { Token } from '@pendle/sdk-core';
1
+ import { Token } from './token';
2
2
  import { Signer } from 'ethers';
3
3
  export declare const DOLLAR: Token;
4
4
  export declare const AVAX_DEFAULT_PROVIDER_URL = "https://api.avax.network/ext/bc/C/rpc";
package/dist/dummy.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { Token, CurrencyAmount } from '@pendle/sdk-core';
1
+ import { Token } from './token';
2
+ import { TokenAmount } from './tokenAmount';
2
3
  import { UserMarketDetails } from './types';
3
4
  export declare const dummyToken: Token;
4
5
  export declare const dummyPly: Token;
5
6
  export declare const dummyPlyAurora: Token;
6
- export declare const dummyTokenAmount: CurrencyAmount;
7
- export declare const dummyZeroTokenAmount: CurrencyAmount;
8
- export declare const dummyTokenAmount2: CurrencyAmount;
9
- export declare const dummyTokenAmount3: CurrencyAmount;
7
+ export declare const dummyTokenAmount: TokenAmount;
8
+ export declare const dummyZeroTokenAmount: TokenAmount;
9
+ export declare const dummyTokenAmount2: TokenAmount;
10
+ export declare const dummyTokenAmount3: TokenAmount;
10
11
  export declare const dummyMarketAddress = "0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f";
11
12
  export declare const dummyUserMarketDetails: UserMarketDetails;
package/dist/helpers.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export declare function formatObject(object: Object): string;
2
+ export declare const decimalFactor: (decimal: number) => string;
3
+ export declare function validateAndParseAddress(address: string): string;
@@ -2,7 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var sdkCore = require('@pendle/sdk-core');
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var BigNumber = _interopDefault(require('bignumber.js'));
6
8
  var ethers$2 = require('ethers');
7
9
 
8
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -845,43 +847,47 @@ var BlockchainEntity = /*#__PURE__*/function () {
845
847
  return BlockchainEntity;
846
848
  }();
847
849
 
848
- var dummyToken = /*#__PURE__*/new sdkCore.Token({
849
- chainId: 43114,
850
- decimal: 6,
851
- symbol: 'USDC',
852
- address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e'
853
- });
854
- var dummyPly = /*#__PURE__*/new sdkCore.Token({
855
- chainId: 43114,
856
- decimal: 18,
857
- symbol: 'QI',
858
- address: '0x8729438eb15e2c8b576fcc6aecda6a148776c0f5'
859
- });
860
- var dummyPlyAurora = /*#__PURE__*/new sdkCore.Token({
861
- chainId: 43114,
862
- decimal: 18,
863
- symbol: 'QIWAVAX',
864
- address: '0xE530dC2095Ef5653205CF5ea79F8979a7028065c'
865
- });
866
- var dummyTokenAmount = /*#__PURE__*/new sdkCore.CurrencyAmount({
867
- currency: dummyToken,
868
- amount: '123.456',
869
- isRaw: false
870
- });
871
- var dummyZeroTokenAmount = /*#__PURE__*/new sdkCore.CurrencyAmount({
872
- currency: dummyToken,
873
- amount: '0'
874
- });
875
- var dummyTokenAmount2 = /*#__PURE__*/new sdkCore.CurrencyAmount({
876
- currency: dummyToken,
877
- amount: '456.123',
878
- isRaw: false
879
- });
880
- var dummyTokenAmount3 = /*#__PURE__*/new sdkCore.CurrencyAmount({
881
- currency: dummyToken,
882
- amount: '1000.123',
883
- isRaw: false
884
- });
850
+ var Token = function Token(address, decimals, expiry) {
851
+ this.address = address.toLowerCase();
852
+ this.decimals = decimals;
853
+ this.expiry = expiry;
854
+ };
855
+
856
+ var TokenAmount = /*#__PURE__*/function () {
857
+ function TokenAmount(token, amount, isRaw) {
858
+ if (isRaw === void 0) {
859
+ isRaw = true;
860
+ }
861
+
862
+ if (isRaw) {
863
+ this.rawAmnt = amount;
864
+ } else {
865
+ this.rawAmnt = new BigNumber(amount).times(decimalFactor(token.decimals)).toFixed(0);
866
+ }
867
+
868
+ this.token = token;
869
+ }
870
+
871
+ var _proto = TokenAmount.prototype;
872
+
873
+ _proto.formattedAmount = function formattedAmount() {
874
+ return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
875
+ };
876
+
877
+ _proto.rawAmount = function rawAmount() {
878
+ return this.rawAmnt;
879
+ };
880
+
881
+ return TokenAmount;
882
+ }();
883
+
884
+ var dummyToken = /*#__PURE__*/new Token('0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e', 6);
885
+ var dummyPly = /*#__PURE__*/new Token('0x8729438eb15e2c8b576fcc6aecda6a148776c0f5', 18);
886
+ var dummyPlyAurora = /*#__PURE__*/new Token('0xE530dC2095Ef5653205CF5ea79F8979a7028065c', 18);
887
+ var dummyTokenAmount = /*#__PURE__*/new TokenAmount(dummyToken, '123.456', false);
888
+ var dummyZeroTokenAmount = /*#__PURE__*/new TokenAmount(dummyToken, '0');
889
+ var dummyTokenAmount2 = /*#__PURE__*/new TokenAmount(dummyToken, '456.123', false);
890
+ var dummyTokenAmount3 = /*#__PURE__*/new TokenAmount(dummyToken, '1000.123', false);
885
891
  var dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f';
886
892
  var dummyUserMarketDetails = {
887
893
  market: dummyMarketAddress,
@@ -893,12 +899,7 @@ var dummyUserMarketDetails = {
893
899
 
894
900
  var ethers = /*#__PURE__*/require('ethers');
895
901
 
896
- var DOLLAR = /*#__PURE__*/new sdkCore.Token({
897
- chainId: 43114,
898
- decimal: 2,
899
- symbol: 'USDC',
900
- address: '0x0000000000000000000000000000000000000001'
901
- });
902
+ var DOLLAR = /*#__PURE__*/new Token('0x0000000000000000000000000000000000000001', 2);
902
903
  var AVAX_DEFAULT_PROVIDER_URL = 'https://api.avax.network/ext/bc/C/rpc';
903
904
  var AVAX_DEFAULT_PROVIDER = /*#__PURE__*/new ethers.providers.JsonRpcProvider(AVAX_DEFAULT_PROVIDER_URL);
904
905
  var dummyPrivateKey = '1111111111111111111111111111111111111111111111111111111111111111';
@@ -2243,16 +2244,8 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2243
2244
  return _context2.abrupt("return", {
2244
2245
  markets: [dummyUserMarketDetails],
2245
2246
  borrowLimit: dummyTokenAmount3,
2246
- accruedPly: new sdkCore.CurrencyAmount({
2247
- currency: dummyPly,
2248
- amount: '100.12',
2249
- isRaw: false
2250
- }),
2251
- lockedPly: new sdkCore.CurrencyAmount({
2252
- currency: dummyPly,
2253
- amount: '200.12',
2254
- isRaw: false
2255
- }),
2247
+ accruedPly: new TokenAmount(dummyPly, '100.12', false),
2248
+ lockedPly: new TokenAmount(dummyPly, '200.12', false),
2256
2249
  borrowableAmount: dummyTokenAmount2
2257
2250
  });
2258
2251
 
@@ -2278,11 +2271,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2278
2271
  switch (_context3.prev = _context3.next) {
2279
2272
  case 0:
2280
2273
  return _context3.abrupt("return", {
2281
- totalStakedLiquidity: new sdkCore.CurrencyAmount({
2282
- currency: dummyPlyAurora,
2283
- amount: '12.1',
2284
- isRaw: false
2285
- }),
2274
+ totalStakedLiquidity: new TokenAmount(dummyPlyAurora, '12.1', false),
2286
2275
  apy: 1.21
2287
2276
  });
2288
2277
 
@@ -2312,18 +2301,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2312
2301
  break;
2313
2302
  }
2314
2303
 
2315
- return _context4.abrupt("return", new sdkCore.CurrencyAmount({
2316
- currency: DOLLAR,
2317
- amount: '1',
2318
- isRaw: false
2319
- }));
2304
+ return _context4.abrupt("return", new TokenAmount(DOLLAR, '1', false));
2320
2305
 
2321
2306
  case 2:
2322
- return _context4.abrupt("return", new sdkCore.CurrencyAmount({
2323
- currency: DOLLAR,
2324
- amount: '12.1',
2325
- isRaw: false
2326
- }));
2307
+ return _context4.abrupt("return", new TokenAmount(DOLLAR, '12.1', false));
2327
2308
 
2328
2309
  case 3:
2329
2310
  case "end":
@@ -2346,11 +2327,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2346
2327
  while (1) {
2347
2328
  switch (_context5.prev = _context5.next) {
2348
2329
  case 0:
2349
- return _context5.abrupt("return", new sdkCore.CurrencyAmount({
2350
- currency: dummyPlyAurora,
2351
- amount: '103.4',
2352
- isRaw: false
2353
- }));
2330
+ return _context5.abrupt("return", new TokenAmount(dummyPlyAurora, '103.4', false));
2354
2331
 
2355
2332
  case 1:
2356
2333
  case "end":
@@ -4057,6 +4034,20 @@ var AuToken = {
4057
4034
  abi: abi$1
4058
4035
  };
4059
4036
 
4037
+ function formatObject(object) {
4038
+ return JSON.stringify(object, null, ' ');
4039
+ }
4040
+ var decimalFactor = function decimalFactor(decimal) {
4041
+ return ethers$2.BigNumber.from(10).pow(decimal).toString();
4042
+ };
4043
+ function validateAndParseAddress(address) {
4044
+ try {
4045
+ return ethers$2.utils.getAddress(address);
4046
+ } catch (error) {
4047
+ throw new Error("Invalid address " + address);
4048
+ }
4049
+ }
4050
+
4060
4051
  var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4061
4052
  _inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
4062
4053
 
@@ -4283,7 +4274,7 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
4283
4274
  var _this3;
4284
4275
 
4285
4276
  _this3 = _BlockchainEntity.call(this) || this;
4286
- _this3.address = sdkCore.validateAndParseAddress(address);
4277
+ _this3.address = validateAndParseAddress(address);
4287
4278
  return _this3;
4288
4279
  }
4289
4280
 
@@ -4296,10 +4287,6 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
4296
4287
  return MoneyMarket;
4297
4288
  }(BlockchainEntity);
4298
4289
 
4299
- function formatObject(object) {
4300
- return JSON.stringify(object, null, ' ');
4301
- }
4302
-
4303
4290
  function sum(a, b) {
4304
4291
  return a + b;
4305
4292
  }
@@ -4317,6 +4304,7 @@ exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
4317
4304
  exports.SDK = SDK;
4318
4305
  exports.SdkRead = SdkRead;
4319
4306
  exports.SdkReadWrite = SdkReadWrite;
4307
+ exports.decimalFactor = decimalFactor;
4320
4308
  exports.dummyMarketAddress = dummyMarketAddress;
4321
4309
  exports.dummyPly = dummyPly;
4322
4310
  exports.dummyPlyAurora = dummyPlyAurora;
@@ -4328,4 +4316,5 @@ exports.dummyUserMarketDetails = dummyUserMarketDetails;
4328
4316
  exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
4329
4317
  exports.formatObject = formatObject;
4330
4318
  exports.sum = sum;
4319
+ exports.validateAndParseAddress = validateAndParseAddress;
4331
4320
  //# sourceMappingURL=sdk.cjs.development.js.map