Skip to content

Commit 9f87683

Browse files
authored
refactor!: rename plugin -> positions (#111)
This moves positions plugins to the new "hooks" terminology. Following the addition of shortcuts.
1 parent 2e38e4a commit 9f87683

15 files changed

+47
-88
lines changed

docs/position-pricing-hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ From the information provided by the hook, Valora can show the user the value of
2323

2424
### Structure
2525

26-
Hooks are organized by application. For instance the Ubeswap hook is located in [`https://github.com/valora-inc/hooks/tree/main/src/apps/ubeswap`](https://github.com/valora-inc/hooks/tree/main/src/apps/ubeswap).
26+
Hooks are organized by application. For instance Ubeswap hooks are located in [`https://github.com/valora-inc/hooks/tree/main/src/apps/ubeswap`](https://github.com/valora-inc/hooks/tree/main/src/apps/ubeswap).
2727

28-
They must implement the [`AppPlugin`](https://github.com/valora-inc/hooks/blob/main/src/plugin.ts) TypeScript interface.
28+
Position pricing hooks must implement the [`PositionsHook`](https://github.com/valora-inc/hooks/blob/main/src/positions.ts) TypeScript interface.
2929

3030
### Creating a Position Pricing Hook
3131

scripts/getPositions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-console */
33
import yargs from 'yargs'
44
import BigNumber from 'bignumber.js'
5-
import { Token } from '../src/plugin'
5+
import { Token } from '../src/positions'
66
import { getPositions } from '../src/getPositions'
77

88
const argv = yargs(process.argv.slice(2))

src/apps/halofi/plugin.e2e.ts renamed to src/apps/halofi/positions.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import plugin from './plugin'
1+
import hook from './positions'
22

33
describe('getPositionDefinitions', () => {
44
it('should get the address definitions successfully', async () => {
5-
const positions = await plugin.getPositionDefinitions(
5+
const positions = await hook.getPositionDefinitions(
66
'celo',
77
'0x2b8441ef13333ffa955c9ea5ab5b3692da95260d',
88
)

src/apps/halofi/plugin.ts renamed to src/apps/halofi/positions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import BigNumber from 'bignumber.js'
22
import { DecimalNumber } from '../../numbers'
33
import {
4-
AppPlugin,
4+
PositionsHook,
55
ContractPositionDefinition,
66
TokenDefinition,
7-
} from '../../plugin'
7+
} from '../../positions'
88
import got from 'got'
99

1010
// User-Agent header is required by the HaloFi API
@@ -100,7 +100,7 @@ type Reward = {
100100
type: string
101101
}
102102

103-
const plugin: AppPlugin = {
103+
const hook: PositionsHook = {
104104
getInfo() {
105105
return {
106106
id: 'halofi',
@@ -165,4 +165,4 @@ const plugin: AppPlugin = {
165165
},
166166
}
167167

168-
export default plugin
168+
export default hook

src/apps/moola/plugin.e2e.ts renamed to src/apps/locked-celo/positions.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import plugin from './plugin'
1+
import hook from './positions'
22

33
describe('getPositionDefinitions', () => {
44
it('should get the address definitions successfully', async () => {
5-
const positions = await plugin.getPositionDefinitions(
5+
const positions = await hook.getPositionDefinitions(
66
'celo',
77
'0x2b8441ef13333ffa955c9ea5ab5b3692da95260d',
88
)

src/apps/locked-celo/plugin.test.ts renamed to src/apps/locked-celo/positions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import plugin from './plugin'
1+
import hook from './positions'
22

33
jest.mock('viem', () => ({
44
...jest.requireActual('viem'),
@@ -15,7 +15,7 @@ describe('getPositionDefinitions', () => {
1515
12n * 10n ** 18n, // 12 locked celo
1616
[[], []], // pending withdrawals
1717
])
18-
const positions = await plugin.getPositionDefinitions(
18+
const positions = await hook.getPositionDefinitions(
1919
'celo',
2020
'0x2b8441ef13333ffa955c9ea5ab5b3692da95260d',
2121
)
@@ -28,7 +28,7 @@ describe('getPositionDefinitions', () => {
2828
0n, // 0 locked celo
2929
[[], []], // pending withdrawals
3030
])
31-
const positions = await plugin.getPositionDefinitions(
31+
const positions = await hook.getPositionDefinitions(
3232
'celo',
3333
'0x2b8441ef13333ffa955c9ea5ab5b3692da95260d',
3434
)

src/apps/locked-celo/plugin.ts renamed to src/apps/locked-celo/positions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppPlugin, ContractPositionDefinition } from '../../plugin'
1+
import { PositionsHook, ContractPositionDefinition } from '../../positions'
22
import {
33
Address,
44
ContractFunctionExecutionError,
@@ -33,7 +33,7 @@ function zip<A, B>(as: readonly A[], bs: readonly B[]) {
3333
return res
3434
}
3535

36-
const plugin: AppPlugin = {
36+
const hook: PositionsHook = {
3737
getInfo() {
3838
return {
3939
id: 'locked-celo',
@@ -121,4 +121,4 @@ const plugin: AppPlugin = {
121121
},
122122
}
123123

124-
export default plugin
124+
export default hook

src/apps/locked-celo/plugin.e2e.ts renamed to src/apps/moola/positions.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import plugin from './plugin'
1+
import hook from './positions'
22

33
describe('getPositionDefinitions', () => {
44
it('should get the address definitions successfully', async () => {
5-
const positions = await plugin.getPositionDefinitions(
5+
const positions = await hook.getPositionDefinitions(
66
'celo',
77
'0x2b8441ef13333ffa955c9ea5ab5b3692da95260d',
88
)

src/apps/moola/plugin.test.ts renamed to src/apps/moola/positions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import plugin from './plugin'
1+
import hook from './positions'
22

33
jest.mock('viem', () => ({
44
...jest.requireActual('viem'),
@@ -24,7 +24,7 @@ describe('getPositionDefinitions', () => {
2424
0n, // 0 cREAL stable debt
2525
2n * 10n ** 18n, // 2 CELO stable debt
2626
])
27-
const positions = await plugin.getPositionDefinitions(
27+
const positions = await hook.getPositionDefinitions(
2828
mockNetwork,
2929
mockAddress,
3030
)
@@ -57,7 +57,7 @@ describe('getPositionDefinitions', () => {
5757
0n, // 0 cREAL stable debt
5858
0n, // 0 CELO stable debt
5959
])
60-
const positions = await plugin.getPositionDefinitions(
60+
const positions = await hook.getPositionDefinitions(
6161
mockNetwork,
6262
mockAddress,
6363
)

src/apps/moola/plugin.ts renamed to src/apps/moola/positions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppPlugin, AppTokenPositionDefinition } from '../../plugin'
1+
import { PositionsHook, AppTokenPositionDefinition } from '../../positions'
22
import { Address, createPublicClient, http } from 'viem'
33
import { celo } from 'viem/chains'
44
import { erc20Abi } from '../../abis/erc-20'
@@ -29,7 +29,7 @@ function getAppTokenPositionDefinition(
2929
}
3030
}
3131

32-
const plugin: AppPlugin = {
32+
const hook: PositionsHook = {
3333
getInfo() {
3434
return {
3535
id: 'moola',
@@ -59,4 +59,4 @@ const plugin: AppPlugin = {
5959
},
6060
}
6161

62-
export default plugin
62+
export default hook

0 commit comments

Comments
 (0)