Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion programs/bid_wall/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub mod usdc_mint {
declare_id!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
}

pub const FEE_BPS: u16 = 100;
pub const FEE_BPS: u16 = 300;

pub const TOKEN_SCALE: u64 = 1_000_000;
/// 10M tokens with 6 decimals - the exact amount of tokens that end up in floating supply at launch
Expand Down
4 changes: 2 additions & 2 deletions tests/bidWall/unit/cancelBidWall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ export default function suite() {
authorityUsdcBalanceAfter,
authorityUsdcBalanceBefore + 50_000_000000n,
);
// Fee recipient received 500 USDC in fees
// Fee recipient received 1500 USDC in fees
assert.equal(
feeRecipientUsdcBalanceAfter,
feeRecipientUsdcBalanceBefore + 500_000000n,
feeRecipientUsdcBalanceBefore + 1_500_000000n,
);
});

Expand Down
12 changes: 6 additions & 6 deletions tests/bidWall/unit/closeBidWall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ export default function suite() {
authorityUsdcBalanceAfter,
authorityUsdcBalanceBefore + 50_000_000000n,
);
// Fee recipient received 500 USDC in fees
// Fee recipient received 1500 USDC in fees
assert.equal(
feeRecipientUsdcBalanceAfter,
feeRecipientUsdcBalanceBefore + 500_000000n,
feeRecipientUsdcBalanceBefore + 1_500_000000n,
);
});

Expand Down Expand Up @@ -295,10 +295,10 @@ export default function suite() {
assert.equal(bidWallUsdcBalanceAfter, 0n);
// Authority received no USDC, as none is left over from the bid wall
assert.equal(authorityUsdcBalanceAfter, authorityUsdcBalanceBefore);
// Fee recipient received 1000 USDC in fees
// Fee recipient received 3000 USDC in fees
assert.equal(
feeRecipientUsdcBalanceAfter,
feeRecipientUsdcBalanceBefore + 1_000_000000n,
feeRecipientUsdcBalanceBefore + 3_000_000000n,
);
});

Expand Down Expand Up @@ -364,10 +364,10 @@ export default function suite() {
authorityUsdcBalanceAfter,
authorityUsdcBalanceBefore + 1_000_000000n,
);
// Fee recipient received 1000 USDC in fees
// Fee recipient received 3000 USDC in fees
assert.equal(
feeRecipientUsdcBalanceAfter,
feeRecipientUsdcBalanceBefore + 1_000_000000n,
feeRecipientUsdcBalanceBefore + 3_000_000000n,
);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/bidWall/unit/collectFees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default function suite() {
METADAO_MULTISIG_VAULT,
);

const expectedFeesCollected = 1_000_000000n;
const expectedFeesCollected = 3_000_000000n;

assert.equal(
bidWallUsdcBalanceAfter,
Expand Down
56 changes: 28 additions & 28 deletions tests/bidWall/unit/sellTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default function suite() {
// Active supply = 10_000_000_000000 META (10M)
// Price = 200_000_000000 / 10_000_000_000000 = ~0.02 USDC per META
// Assume user sells 5M META
// User will receive ~100_000 USDC (5M * 0.02) minus 1% fee, rounded down.
// User will receive ~100_000 USDC (5M * 0.02) minus 3% fee, rounded down.

await bidWallClient
.sellTokensIx({
Expand All @@ -216,15 +216,15 @@ export default function suite() {
this.payer.publicKey,
);

// Seller received 99_000_000000 USDC (99K), which is 100_000_000000 - 1_000_000000 (fee)
assert.equal(usdcBalanceAfter, usdcBalanceBefore + 99_000_000000n);
// Seller received 97_000_000000 USDC (97K), which is 100_000_000000 - 3_000_000000 (fee)
assert.equal(usdcBalanceAfter, usdcBalanceBefore + 97_000_000000n);
assert.equal(metaBalanceAfter, 5_000_000_000000n);

// Bid wall collected 1_000_000000 USDC (1K) in fees
// Bid wall collected 3_000_000000 USDC (3K) in fees
const bidWallAccount = await bidWallClient.fetchBidWall(bidWall);
assert.equal(
bidWallAccount.feesCollected.toString(),
new BN(1_000_000000).toString(),
new BN(3_000_000000).toString(),
);
});

Expand All @@ -250,7 +250,7 @@ export default function suite() {
// Active supply = 10_000_000_000000 META (10M)
// Price = 200_000_000000 / 10_000_000_000000 = ~0.02 USDC per META
// Assume user sells 2M META
// User will receive ~40_000 USDC (2M * 0.02) minus 1% fee, rounded down.
// User will receive ~40_000 USDC (2M * 0.02) minus 3% fee, rounded down.

await bidWallClient
.sellTokensIx({
Expand All @@ -273,24 +273,24 @@ export default function suite() {
this.payer.publicKey,
);

// Seller received 39_600_000000 USDC (39.6K), which is 40_000_000000 - 400_000000 (fee)
assert.equal(usdcBalanceAfterFirstSell, usdcBalanceBefore + 39_600_000000n);
// Seller received 38_800_000000 USDC (38.8K), which is 40_000_000000 - 1_200_000000 (fee)
assert.equal(usdcBalanceAfterFirstSell, usdcBalanceBefore + 38_800_000000n);
assert.equal(metaBalanceAfterFirstSell, 8_000_000_000000n);

// Bid wall collected 400_000000 USDC (0.4K) in fees
// Bid wall collected 1_200_000000 USDC (1.2K) in fees
let bidWallAccount = await bidWallClient.fetchBidWall(bidWall);
assert.equal(
bidWallAccount.feesCollected.toString(),
new BN(400_000000).toString(),
new BN(1_200_000000).toString(),
);

const bidWallUsdcBalanceAfterFirstSell = await this.getTokenBalance(
MAINNET_USDC,
bidWall,
);
// Bid wall should have 60.4K USDC after the first sell
// That is 100k (initial bid wall balance) reduced by 40k (bought) minus the fee (400)
assert.equal(bidWallUsdcBalanceAfterFirstSell, 60_400_000000n);
// Bid wall should have 61.2K USDC after the first sell
// That is 100k (initial bid wall balance) reduced by 40k (bought) plus the fee retained (1.2K)
assert.equal(bidWallUsdcBalanceAfterFirstSell, 61_200_000000n);

const daoTreasuryQuoteTokenAccountAddress = getAssociatedTokenAddressSync(
MAINNET_USDC,
Expand Down Expand Up @@ -335,7 +335,7 @@ export default function suite() {
// Active supply = 8_000_000_000000 META (8M)
// Price = 100_000_000000 / 8_000_000_000000 = ~0.0125 USDC per META
// Assume user sells 2M META
// User will receive 24_750 USDC, which is 25_000 USDC (2M * 0.0125) minus 1% fee (250 USDC), rounded down.
// User will receive 24_250 USDC, which is 25_000 USDC (2M * 0.0125) minus 3% fee (750 USDC), rounded down.

await bidWallClient
.sellTokensIx({
Expand All @@ -361,24 +361,24 @@ export default function suite() {
);
assert.equal(
usdcBalanceAfterSecondSell,
usdcBalanceAfterFirstSell + 24_750_000000n,
usdcBalanceAfterFirstSell + 24_250_000000n,
);
assert.equal(metaBalanceAfterSecondSell, 6_000_000_000000n);

// Bid wall collected an additional 250_000000 USDC (250) in fees, totalling 650 USDC
// Bid wall collected an additional 750_000000 USDC (750) in fees, totalling 1.95K USDC
bidWallAccount = await bidWallClient.fetchBidWall(bidWall);
assert.equal(
bidWallAccount.feesCollected.toString(),
new BN(650_000000).toString(),
new BN(1_950_000000).toString(),
);

const bidWallUsdcBalanceAfterSecondSell = await this.getTokenBalance(
MAINNET_USDC,
bidWall,
);
// Bid wall should have 35_650 USDC after the second sell
// That is 60_400 (after first sell) reduced by 25_000 (bought) minus the fee (250)
assert.equal(bidWallUsdcBalanceAfterSecondSell, 35_650_000_000n);
// Bid wall should have 36_950 USDC after the second sell
// That is 61_200 (after first sell) reduced by 25_000 (bought) plus the fee retained (750)
assert.equal(bidWallUsdcBalanceAfterSecondSell, 36_950_000000n);

// Confirm that a third sell would get the same price per token as the second sell
await bidWallClient
Expand All @@ -405,24 +405,24 @@ export default function suite() {
);
assert.equal(
usdcBalanceAfterThirdSell,
usdcBalanceAfterSecondSell + 24_750_000000n,
usdcBalanceAfterSecondSell + 24_250_000000n,
);
assert.equal(metaBalanceAfterThirdSell, 4_000_000_000000n);

// Bid wall collected an additional 250 USDC in fees, totalling 900 USDC
// Bid wall collected an additional 750 USDC in fees, totalling 2.7K USDC
bidWallAccount = await bidWallClient.fetchBidWall(bidWall);
assert.equal(
bidWallAccount.feesCollected.toString(),
new BN(900_000000).toString(),
new BN(2_700_000000).toString(),
);

const bidWallUsdcBalanceAfterThirdSell = await this.getTokenBalance(
MAINNET_USDC,
bidWall,
);
// Bid wall should have 10_900 USDC after the third sell
// That is 35_650 (after second sell) reduced by 25_000 (bought) minus the fee (250)
assert.equal(bidWallUsdcBalanceAfterThirdSell, 10_900_000000n);
// Bid wall should have 12_700 USDC after the third sell
// That is 36_950 (after second sell) reduced by 25_000 (bought) plus the fee retained (750)
assert.equal(bidWallUsdcBalanceAfterThirdSell, 12_700_000000n);
});

it("sending quote tokens to a bid wall beyond what was originally allocated doesn't change the NAV per token", async function () {
Expand Down Expand Up @@ -450,10 +450,10 @@ export default function suite() {
this.payer.publicKey,
);

// User received 99_000_000000 USDC (99K), which is 100_000_000000 - 1_000_000000 (fee)
// User received 97_000_000000 USDC (97K), which is 100_000_000000 - 3_000_000000 (fee)
// This is the same case as in the "successfully sells tokens into a bid wall" test
// Bid wall remains unaffected by the transfer of USDC into it
assert.equal(usdcBalanceAfter, usdcBalanceBefore + 99_000_000000n);
assert.equal(usdcBalanceAfter, usdcBalanceBefore + 97_000_000000n);
});

it("fails to sell tokens into a bid wall when bid wall is expired", async function () {
Expand Down
Loading