Skip to content

Commit 0e0c088

Browse files
committed
fix: tests
1 parent dd3cc5b commit 0e0c088

7 files changed

Lines changed: 25 additions & 43 deletions

File tree

README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,4 @@ Unfortunately, Ponder doesn't allow the same schema to be used with different co
132132
In this project, the config changes only if you add, remove, or modify a chain.
133133

134134
So, if you try to run the bot with a set of chains that's different from the one used in your initial run, indexing will fail.
135-
There are two ways to handle this:
136-
137-
### Reset the postgres database
138-
139-
This is the easiest and most direct solution, but you will lose the indexed data for the previous chains.
140-
141-
If you're using Docker to run the local Postgres database, you can simply stop and remove the container and its volume:
142-
143-
```bash
144-
docker compose down -v
145-
```
146-
147-
### Use a new database
148-
149-
This way you can have different containers storing different indexing data for different sets of chains.
150-
151-
- If you're using Docker to run the local Postgres database, just change the port both in the postgres url given to ponder (in `apps/ponder/ponder.config.ts`) and in `docker-compose.yml`.
152-
- If you are using an external postgres database, you just need to change the `POSTGRES_DATABASE_URL`.
135+
You should use another schema (this handled in `apps/client/src/script.ts`).

apps/client/src/script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function run() {
3030

3131
const ponder = spawn(
3232
"pnpm",
33-
["ponder", "start", "--schema", "ponder.schema.ts", "--config", "ponder.config.ts"],
33+
["ponder", "start", "--schema", "public", "--config", "ponder.config.ts"],
3434
{ stdio: "inherit", cwd: "apps/ponder" },
3535
);
3636

apps/client/src/strategies/apyRange/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class ApyRange implements Strategy {
8080
let idleDeposit = 0n;
8181

8282
if (idleMarket) {
83-
if (totalWithdrawableAmount > totalDepositableAmount && ALLOW_IDLE_REALLOCATION) {
83+
if (totalWithdrawableAmount > totalDepositableAmount && this.allowIdleReallocation()) {
8484
idleDeposit = min(
8585
totalWithdrawableAmount - totalDepositableAmount,
8686
idleMarket.cap - idleMarket.vaultAssets,
@@ -153,7 +153,7 @@ export class ApyRange implements Strategy {
153153
});
154154
}
155155

156-
if (idleDeposit > 0n && ALLOW_IDLE_REALLOCATION) {
156+
if (idleDeposit > 0n && this.allowIdleReallocation()) {
157157
deposits.push({
158158
marketParams: idleMarket.params,
159159
assets: maxUint256,
@@ -163,6 +163,10 @@ export class ApyRange implements Strategy {
163163
return [...withdrawals, ...deposits];
164164
}
165165

166+
protected allowIdleReallocation() {
167+
return ALLOW_IDLE_REALLOCATION;
168+
}
169+
166170
protected getApyRange(chainId: number, vaultAddress: Address, marketId: Hex) {
167171
let apyRange = DEFAULT_APY_RANGE;
168172

apps/client/src/utils/maths.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ export const utilizationToRate = (utilization: bigint, rateAtTarget: bigint): bi
110110

111111
if (utilization >= WAD) {
112112
rate = maxRate;
113-
} else if (utilization >= rateAtTarget) {
113+
} else if (utilization >= TARGET_UTILIZATION) {
114114
rate =
115115
rateAtTarget +
116116
mulDivDown(
117117
maxRate - rateAtTarget,
118118
utilization - TARGET_UTILIZATION,
119119
WAD - TARGET_UTILIZATION,
120120
);
121-
} else if (utilization > minRate) {
121+
} else if (utilization > 0n) {
122122
rate = minRate + mulDivDown(rateAtTarget - minRate, utilization, TARGET_UTILIZATION);
123123
}
124124
return rate;

apps/client/test/vitest/strategies/apyRange.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class MinRatesTest extends ApyRange {
5656
this.config = testConfig;
5757
}
5858

59+
allowIdleReallocation() {
60+
return this.config.ALLOW_IDLE_REALLOCATION;
61+
}
62+
5963
getApyRange(chainId: number, vaultAddress: Address, marketId: Hex) {
6064
let apyRange = this.config.DEFAULT_APY_RANGE;
6165

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
]
1919
},
2020
"dependencies": {
21-
"ponder": "^0.10.13",
21+
"ponder": "^0.10.30",
2222
"tsx": "^4.19.3",
2323
"viem": "^2.23.2"
2424
},

pnpm-lock.yaml

Lines changed: 10 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)