Skip to content

Commit 8cbb71a

Browse files
committed
Bump set-protocol-v2 package and run unit tests
1 parent 4039843 commit 8cbb71a

File tree

6 files changed

+15
-100
lines changed

6 files changed

+15
-100
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@0xproject/types": "^1.1.4",
5959
"@0xproject/typescript-typings": "^3.0.2",
6060
"@0xproject/utils": "^2.0.2",
61-
"@setprotocol/set-protocol-v2": "^0.1.9",
61+
"@setprotocol/set-protocol-v2": "^0.1.10",
6262
"@types/chai-as-promised": "^7.1.3",
6363
"@types/jest": "^26.0.5",
6464
"@types/web3": "^1.2.2",

src/api/PerpV2LeverageViewerAPI.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
'use strict';
1818

19-
import { ContractTransaction } from 'ethers';
2019
import { Provider } from '@ethersproject/providers';
2120
import { Address } from '@setprotocol/set-protocol-v2/utils/types';
22-
import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain';
2321
import { BigNumber } from 'ethers/lib/ethers';
2422
import { VAssetDisplayInfo } from '../types';
2523

@@ -49,29 +47,6 @@ export default class PerpV2LeverageViewerAPI {
4947
this.assert = assertions || new Assertions();
5048
}
5149

52-
/**
53-
* Initializes the PerpV2LeverageModuleViewer to the SetToken. Only callable by the SetToken's manager.
54-
*
55-
* @param setTokenAddress Address of the SetToken to initialize
56-
* @param callerAddress The address of user transferring from (optional)
57-
* @param txOpts Overrides for transaction (optional)
58-
*
59-
* @return Transaction hash of the initialize transaction
60-
*/
61-
public async initializeAsync(
62-
setTokenAddress: Address,
63-
callerAddress: Address = undefined,
64-
txOpts: TransactionOverrides = {}
65-
): Promise<ContractTransaction> {
66-
this.assert.schema.isValidAddress('setTokenAddress', setTokenAddress);
67-
68-
return await this.perpV2LeverageModuleViewerWrapper.initialize(
69-
setTokenAddress,
70-
callerAddress,
71-
txOpts,
72-
);
73-
}
74-
7550
/**
7651
* Gets the address of the collateral token
7752
*

src/types/common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export enum ModuleState {
9494
// For PerpV2LeverageModuleViewerWrapper
9595
export type VAssetDisplayInfo = {
9696
symbol: string;
97-
address: Address;
98-
positionUnit: BigNumber;
99-
indexPrice: BigNumber;
100-
currentLeverageRatio: BigNumber;
97+
vAssetAddress: Address;
98+
positionUnit: BigNumber; // 10^18 decimals
99+
indexPrice: BigNumber; // 10^18 decimals
100+
currentLeverageRatio: BigNumber; // 10^18 decimals
101101
};

src/wrappers/set-protocol-v2/PerpV2LeverageModuleViewerWrapper.ts

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
'use strict';
1515

1616
import { Address } from '@setprotocol/set-protocol-v2/utils/types';
17-
import { BigNumber, ContractTransaction } from 'ethers';
18-
import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain';
17+
import { BigNumber } from 'ethers';
1918
import { Provider } from '@ethersproject/providers';
20-
import { generateTxOpts } from '../../utils/transactions';
2119
import { VAssetDisplayInfo } from '../../types';
2220

2321
import ContractWrapper from './ContractWrapper';
@@ -41,30 +39,6 @@ export default class PerpV2LeverageModuleViewerWrapper {
4139
this.perpV2LeverageModuleViewerAddress = perpV2LeverageModuleViewerAddress;
4240
}
4341

44-
/**
45-
* Initializes this module to the SetToken. Only callable by the SetToken's manager.
46-
*
47-
* @param setTokenAddress Address of the SetToken to initialize
48-
* @param callerAddress Address of caller (optional)
49-
* @param txOpts Overrides for transaction (optional)
50-
*/
51-
public async initialize(
52-
setTokenAddress: Address,
53-
callerAddress: Address = undefined,
54-
txOpts: TransactionOverrides = {}
55-
): Promise<ContractTransaction> {
56-
const txOptions = await generateTxOpts(txOpts);
57-
const perpV2LeverageModuleViewerInstance = await this.contracts.loadPerpV2LeverageModuleViewerAsync(
58-
this.perpV2LeverageModuleViewerAddress,
59-
callerAddress
60-
);
61-
62-
return await perpV2LeverageModuleViewerInstance.initialize(
63-
setTokenAddress,
64-
txOptions,
65-
);
66-
}
67-
6842
/**
6943
* Gets the address of the collateral token
7044
*
@@ -94,7 +68,7 @@ export default class PerpV2LeverageModuleViewerWrapper {
9468
* @param slippage Expected slippage from entering position in precise units (1% = 10^16)
9569
* @param callerAddress Address of the method caller
9670
*
97-
* @return Maximum amount of Sets that can be issued
71+
* @return Maximum amount of Sets that can be issued (10^18 decimals)
9872
*/
9973
public async getMaximumSetTokenIssueAmount(
10074
setTokenAddress: Address,
@@ -119,7 +93,7 @@ export default class PerpV2LeverageModuleViewerWrapper {
11993
* @param callerAddress Address of the method caller
12094
*
12195
* @return Collateral token address
122-
* @return Total collateral value position unit
96+
* @return Total collateral value position unit (10^18 decimals)
12397
*/
12498
public async getTotalCollateralUnit(
12599
setTokenAddress: Address,
@@ -143,7 +117,7 @@ export default class PerpV2LeverageModuleViewerWrapper {
143117
* @param setTokenAddress Instance of the SetToken
144118
* @param callerAddress Address of the method caller
145119
*
146-
* @return Array of info concerning size and leverage of current vAsset positions
120+
* @return VAssetDisplayInfo array containing size/leverage of current vAsset positions
147121
*/
148122
public async getVirtualAssetsDisplayInfo(
149123
setTokenAddress: Address,

test/api/PerpV2LeverageViewerAPI.spec.ts

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { ethers } from 'ethers';
18-
import { BigNumber, ContractTransaction } from 'ethers/lib/ethers';
18+
import { BigNumber } from 'ethers/lib/ethers';
1919
import { Address } from '@setprotocol/set-protocol-v2/utils/types';
2020
import { ether } from '@setprotocol/set-protocol-v2/dist/utils/common';
2121
import { VAssetDisplayInfo } from '@src/types';
@@ -30,17 +30,13 @@ jest.mock('@src/wrappers/set-protocol-v2/PerpV2LeverageModuleViewerWrapper');
3030

3131
describe('PerpV2LeverageViewerAPI', () => {
3232
let perpV2LeverageModuleViewerAddress: Address;
33-
let setTokenAddress: Address;
34-
let owner: Address;
3533

3634
let perpV2LeverageViewerAPI: PerpV2LeverageViewerAPI;
3735
let perpV2LeverageModuleViewerWrapper: PerpV2LeverageModuleViewerWrapper;
3836

3937
beforeEach(async () => {
4038
[
41-
owner,
4239
perpV2LeverageModuleViewerAddress,
43-
setTokenAddress,
4440
] = await provider.listAccounts();
4541

4642
perpV2LeverageViewerAPI = new PerpV2LeverageViewerAPI(provider, perpV2LeverageModuleViewerAddress);
@@ -51,37 +47,6 @@ describe('PerpV2LeverageViewerAPI', () => {
5147
(PerpV2LeverageModuleViewerWrapper as any).mockClear();
5248
});
5349

54-
describe('#initializeAsync', () => {
55-
let subjectSetTokenAddress: Address;
56-
let subjectCallerAddress: Address;
57-
58-
let subjectTransactionOptions: any;
59-
60-
beforeEach(async () => {
61-
subjectSetTokenAddress = setTokenAddress;
62-
subjectCallerAddress = owner;
63-
subjectTransactionOptions = {};
64-
});
65-
66-
async function subject(): Promise<ContractTransaction> {
67-
return perpV2LeverageViewerAPI.initializeAsync(
68-
subjectSetTokenAddress,
69-
subjectCallerAddress,
70-
subjectTransactionOptions,
71-
);
72-
}
73-
74-
it('should call initialize on the PerpV2LeverageModuleViewerWrapper', async () => {
75-
await subject();
76-
77-
expect(perpV2LeverageModuleViewerWrapper.initialize).to.have.beenCalledWith(
78-
subjectSetTokenAddress,
79-
subjectCallerAddress,
80-
subjectTransactionOptions,
81-
);
82-
});
83-
});
84-
8550
describe('#getCollateralTokenAsync', () => {
8651
let nullCallerAddress: Address;
8752

@@ -126,6 +91,7 @@ describe('PerpV2LeverageViewerAPI', () => {
12691

12792
expect(perpV2LeverageModuleViewerWrapper.getMaximumSetTokenIssueAmount).to.have.beenCalledWith(
12893
subjectTokenAddress,
94+
slippage,
12995
nullCallerAddress,
13096
);
13197
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,10 +1016,10 @@
10161016
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1-solc-0.7-2.tgz#371c67ebffe50f551c3146a9eec5fe6ffe862e92"
10171017
integrity sha512-tAG9LWg8+M2CMu7hIsqHPaTyG4uDzjr6mhvH96LvOpLZZj6tgzTluBt+LsCf1/QaYrlis6pITvpIaIhE+iZB+Q==
10181018

1019-
"@setprotocol/set-protocol-v2@^0.1.9":
1020-
version "0.1.9"
1021-
resolved "https://registry.yarnpkg.com/@setprotocol/set-protocol-v2/-/set-protocol-v2-0.1.9.tgz#1b0eef8667d01405f0b259bc5129986e5db7b53b"
1022-
integrity sha512-sPbCD6ngw4yIosXyOT+ytFZbFeMyHNOgDA6hdhrXkllsSKoJ2thc9Y6SqzF5kCPkK+bKmVhNF+cMTDMX0lemZg==
1019+
"@setprotocol/set-protocol-v2@^0.1.10":
1020+
version "0.1.10"
1021+
resolved "https://registry.yarnpkg.com/@setprotocol/set-protocol-v2/-/set-protocol-v2-0.1.10.tgz#a8135e3e57cbdb857392bcf3cfe98d23bdc91333"
1022+
integrity sha512-PoDRg+ZeNk7eATvfqPxe1yMLTFoIgAfGA8oUmC8FTIM7F5Ya6wJCpzoJFaLcbd3lWK9+GUkoh6D1onLCatU5hw==
10231023
dependencies:
10241024
"@uniswap/v3-sdk" "^3.5.1"
10251025
ethers "^5.5.2"

0 commit comments

Comments
 (0)